Lines Matching refs:recp

208 static void BN_RECP_CTX_init(BN_RECP_CTX *recp) {  in BN_RECP_CTX_init()  argument
209 BN_init(&recp->N); in BN_RECP_CTX_init()
210 BN_init(&recp->Nr); in BN_RECP_CTX_init()
211 recp->num_bits = 0; in BN_RECP_CTX_init()
212 recp->flags = 0; in BN_RECP_CTX_init()
215 static void BN_RECP_CTX_free(BN_RECP_CTX *recp) { in BN_RECP_CTX_free() argument
216 if (recp == NULL) { in BN_RECP_CTX_free()
220 BN_free(&recp->N); in BN_RECP_CTX_free()
221 BN_free(&recp->Nr); in BN_RECP_CTX_free()
224 static int BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *d, BN_CTX *ctx) { in BN_RECP_CTX_set() argument
225 if (!BN_copy(&(recp->N), d)) { in BN_RECP_CTX_set()
228 BN_zero(&recp->Nr); in BN_RECP_CTX_set()
229 recp->num_bits = BN_num_bits(d); in BN_RECP_CTX_set()
230 recp->shift = 0; in BN_RECP_CTX_set()
265 BN_RECP_CTX *recp, BN_CTX *ctx) { in BN_div_recp() argument
288 if (BN_ucmp(m, &recp->N) < 0) { in BN_div_recp()
303 j = recp->num_bits << 1; in BN_div_recp()
309 if (i != recp->shift) { in BN_div_recp()
310 recp->shift = in BN_div_recp()
311 BN_reciprocal(&(recp->Nr), &(recp->N), i, in BN_div_recp()
315 if (recp->shift == -1) { in BN_div_recp()
325 if (!BN_rshift(a, m, recp->num_bits)) { in BN_div_recp()
328 if (!BN_mul(b, a, &(recp->Nr), ctx)) { in BN_div_recp()
331 if (!BN_rshift(d, b, i - recp->num_bits)) { in BN_div_recp()
336 if (!BN_mul(b, &(recp->N), d, ctx)) { in BN_div_recp()
345 while (BN_ucmp(r, &(recp->N)) >= 0) { in BN_div_recp()
350 if (!BN_usub(r, r, &(recp->N))) { in BN_div_recp()
359 d->neg = m->neg ^ recp->N.neg; in BN_div_recp()
368 BN_RECP_CTX *recp, BN_CTX *ctx) { in BN_mod_mul_reciprocal() argument
394 ret = BN_div_recp(NULL, r, ca, recp, ctx); in BN_mod_mul_reciprocal()
437 BN_RECP_CTX recp; in mod_exp_recp() local
463 BN_RECP_CTX_init(&recp); in mod_exp_recp()
470 if (BN_RECP_CTX_set(&recp, aa, ctx) <= 0) { in mod_exp_recp()
474 if (BN_RECP_CTX_set(&recp, m, ctx) <= 0) { in mod_exp_recp()
490 if (!BN_mod_mul_reciprocal(aa, val[0], val[0], &recp, ctx)) { in mod_exp_recp()
496 !BN_mod_mul_reciprocal(val[i], val[i - 1], aa, &recp, ctx)) { in mod_exp_recp()
517 if (!BN_mod_mul_reciprocal(r, r, r, &recp, ctx)) { in mod_exp_recp()
550 if (!BN_mod_mul_reciprocal(r, r, r, &recp, ctx)) { in mod_exp_recp()
557 if (!BN_mod_mul_reciprocal(r, r, val[wvalue >> 1], &recp, ctx)) { in mod_exp_recp()
572 BN_RECP_CTX_free(&recp); in mod_exp_recp()