Commit e3ab8cc4 authored by Billy Brumley's avatar Billy Brumley Committed by Andy Polyakov
Browse files

Fix BN_gcd errors for some curves



Those even order that do not play nicely with Montgomery arithmetic

(back-ported from commit 3a6a4a93)

Reviewed-by: default avatarAndy Polyakov <appro@openssl.org>
Reviewed-by: default avatarRich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/6810)
parent 6a815969
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -319,12 +319,16 @@ int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator,
        BN_zero(&group->cofactor);

    /*
     * We ignore the return value because some groups have an order with
     * Some groups have an order with
     * factors of two, which makes the Montgomery setup fail.
     * |group->mont_data| will be NULL in this case.
     */
    ec_precompute_mont_data(group);
    if (BN_is_odd(&group->order)) {
        return ec_precompute_mont_data(group);
    }

    BN_MONT_CTX_free(group->mont_data);
    group->mont_data = NULL;
    return 1;
}