Lines Matching refs:cofactor
61 ret->cofactor = BN_new();
62 if (ret->cofactor == NULL)
73 BN_free(ret->cofactor);
133 BN_free(group->cofactor);
154 BN_clear_free(group->cofactor);
239 if (!BN_copy(dest->cofactor, src->cofactor))
303 * Try computing cofactor from the generator order (n) and field cardinality (q).
313 * Otherwise, zero cofactor and return success.
321 * If the cofactor is too large, we cannot guess it.
326 BN_zero(group->cofactor);
349 if (!BN_rshift1(group->cofactor, group->order) /* n/2 */
350 || !BN_add(group->cofactor, group->cofactor, q) /* q + n/2 */
352 || !BN_add(group->cofactor, group->cofactor, BN_value_one())
354 || !BN_div(group->cofactor, NULL, group->cofactor, group->order, ctx))
364 const BIGNUM *order, const BIGNUM *cofactor)
390 * Unfortunately the cofactor is an optional field in many standards.
391 * Internally, the lib uses 0 cofactor as a marker for "unknown cofactor".
392 * So accept cofactor == NULL or cofactor >= 0.
394 if (cofactor != NULL && BN_is_negative(cofactor)) {
410 /* Either take the provided positive cofactor, or try to compute it */
411 if (cofactor != NULL && !BN_is_zero(cofactor)) {
412 if (!BN_copy(group->cofactor, cofactor))
415 BN_zero(group->cofactor);
463 int EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor,
467 if (group->cofactor == NULL)
469 if (!BN_copy(cofactor, group->cofactor))
472 return !BN_is_zero(group->cofactor);
477 return group->cofactor;
1398 * cofactor different from the one in the built-in table is just
1547 BIGNUM *p = NULL, *a = NULL, *b = NULL, *order = NULL, *cofactor = NULL;
1705 /* Optional cofactor */
1708 cofactor = BN_CTX_get(bnctx);
1709 if (cofactor == NULL || !OSSL_PARAM_get_BN(ptmp, &cofactor)) {
1715 /* set the generator, order and cofactor (if present) */
1716 if (!EC_GROUP_set_generator(group, point, order, cofactor)) {