Lines Matching defs:ctx

30 bn_div_by_two_mod_odd_n(BIGNUM *a, const BIGNUM *n, BN_CTX *ctx)
41 if (!BN_mod_ct(a, a, n, ctx))
64 const BIGNUM *n, BN_CTX *ctx)
69 BN_CTX_start(ctx);
71 if ((tmp = BN_CTX_get(ctx)) == NULL)
75 if (!BN_sqr(tmp, U, ctx))
77 if (!BN_mul(tmp, D, tmp, ctx))
81 if (!BN_mod_mul(U, U, V, n, ctx))
85 if (!BN_sqr(V, V, ctx))
89 if (!bn_div_by_two_mod_odd_n(V, n, ctx))
94 if (!BN_mul(tmp, D, U, ctx))
100 if (!bn_div_by_two_mod_odd_n(U, n, ctx))
106 if (!bn_div_by_two_mod_odd_n(V, n, ctx))
113 BN_CTX_end(ctx);
124 const BIGNUM *n, BN_CTX *ctx)
142 if (!bn_lucas_step(U, V, digit, D, n, ctx))
160 BN_CTX *ctx)
166 BN_CTX_start(ctx);
168 if ((k = BN_CTX_get(ctx)) == NULL)
170 if ((U = BN_CTX_get(ctx)) == NULL)
172 if ((V = BN_CTX_get(ctx)) == NULL)
193 if (!bn_lucas(U, V, k, D, n, ctx))
207 if (!bn_lucas_step(U, V, 0, D, n, ctx))
226 BN_CTX_end(ctx);
238 bn_strong_lucas_selfridge(int *is_pseudoprime, const BIGNUM *n, BN_CTX *ctx)
244 BN_CTX_start(ctx);
247 if (!bn_is_perfect_square(&is_perfect_square, n, ctx))
259 if ((D = BN_CTX_get(ctx)) == NULL)
261 if ((two = BN_CTX_get(ctx)) == NULL)
272 if ((jacobi_symbol = BN_kronecker(D, n, ctx)) == -2)
291 if (!bn_strong_lucas_test(is_pseudoprime, n, D, ctx))
298 BN_CTX_end(ctx);
322 const BIGNUM *k, int s, const BIGNUM *base, BN_CTX *ctx, BN_MONT_CTX *mctx)
328 BN_CTX_start(ctx);
330 if ((power = BN_CTX_get(ctx)) == NULL)
337 if (!BN_mod_exp_mont_ct(power, base, k, n, ctx, mctx))
347 if (!BN_mod_sqr(power, power, n, ctx))
373 BN_CTX_end(ctx);
384 bn_miller_rabin(int *is_pseudoprime, const BIGNUM *n, BN_CTX *ctx,
393 BN_CTX_start(ctx);
395 if ((base = BN_CTX_get(ctx)) == NULL)
397 if ((k = BN_CTX_get(ctx)) == NULL)
399 if ((n_minus_one = BN_CTX_get(ctx)) == NULL)
432 if (!BN_MONT_CTX_set(mctx, n, ctx))
442 if (!bn_fermat(is_pseudoprime, n, n_minus_one, k, s, base, ctx, mctx))
456 if (!bn_fermat(is_pseudoprime, n, n_minus_one, k, s, base, ctx,
474 BN_CTX_end(ctx);
488 BN_CTX *ctx = NULL;
513 if ((ctx = in_ctx) == NULL)
514 ctx = BN_CTX_new();
515 if (ctx == NULL)
518 if (!bn_miller_rabin(is_pseudoprime, n, ctx, rounds))
523 if (!bn_strong_lucas_selfridge(is_pseudoprime, n, ctx))
530 if (ctx != in_ctx)
531 BN_CTX_free(ctx);