Lines Matching refs:CRYPT_OK
26 @return CRYPT_OK if successful, upon error all allocated ram is freed
40 if ((err = prng_is_valid(wprng)) != CRYPT_OK) {
44 if ((err = mp_init_multi(&p, &q, &tmp1, &tmp2, NULL)) != CRYPT_OK) {
52 if ((err = rand_prime(q, -size, prng, wprng)) != CRYPT_OK) { goto done; }
53 if ((err = mp_sub_d(q, 1, tmp1)) != CRYPT_OK) { goto done; }
57 if ((err = rand_prime(p, size+1, prng, wprng)) != CRYPT_OK) { goto done; }
58 if ((err = mp_gcd(p, tmp1, tmp2)) != CRYPT_OK) { goto done; }
63 &key->qP, &key->p, &key->q, &key->pq, NULL)) != CRYPT_OK) {
68 if ((err = mp_copy( p, key->p)) != CRYPT_OK) { goto error2; }
69 if ((err = mp_copy( q, key->q)) != CRYPT_OK) { goto error2; }
70 if ((err = mp_mul(key->p, key->q, key->pq)) != CRYPT_OK) { goto error2; } /* tmp1 = pq */
71 if ((err = mp_mul(key->pq, key->p, key->N)) != CRYPT_OK) { goto error2; } /* N = p^2q */
72 if ((err = mp_sub_d( p, 1, tmp1)) != CRYPT_OK) { goto error2; } /* tmp1 = q-1 */
73 if ((err = mp_sub_d( q, 1, tmp2)) != CRYPT_OK) { goto error2; } /* tmp2 = p-1 */
74 if ((err = mp_lcm(tmp1, tmp2, key->d)) != CRYPT_OK) { goto error2; } /* tmp1 = lcd(p-1,q-1) */
75 if ((err = mp_invmod( key->N, key->d, key->d)) != CRYPT_OK) { goto error2; } /* key->d = 1/N mod pq */
79 if ((err = mp_mod( key->d, tmp1, key->dP)) != CRYPT_OK) { goto error2; } /* dP = d mod p-1 */
80 if ((err = mp_mod( key->d, tmp2, key->dQ)) != CRYPT_OK) { goto error2; } /* dQ = d mod q-1 */
81 if ((err = mp_invmod( q, p, key->qP)) != CRYPT_OK) { goto error2; } /* qP = 1/q mod p */
87 err = CRYPT_OK;