Home | History | Annotate | Download | only in bn

Lines Matching refs:estimate

433   BIGNUM *estimate, *tmp, *delta, *last_delta, *tmp2;
447 estimate = BN_CTX_get(ctx);
449 estimate = out_sqrt;
454 if (estimate == NULL || tmp == NULL || last_delta == NULL || delta == NULL) {
459 /* We estimate that the square root of an n-bit number is 2^{n/2}. */
460 BN_lshift(estimate, BN_value_one(), BN_num_bits(in)/2);
462 /* This is Newton's method for finding a root of the equation |estimate|^2 -
465 /* |estimate| = 1/2 * (|estimate| + |in|/|estimate|) */
466 if (!BN_div(tmp, NULL, in, estimate, ctx) ||
467 !BN_add(tmp, tmp, estimate) ||
468 !BN_rshift1(estimate, tmp) ||
469 /* |tmp| = |estimate|^2 */
470 !BN_sqr(tmp, estimate, ctx) ||
478 /* The difference between |in| and |estimate| squared is required to always
500 if (ok && out_sqrt == in && !BN_copy(out_sqrt, estimate)) {