Loading crypto/ec/ec_curve.c +8 −0 Original line number Diff line number Diff line Loading @@ -69,6 +69,10 @@ * */ #ifdef OPENSSL_FIPS #include <openssl/fips.h> #endif #include <string.h> #include "ec_lcl.h" #include <openssl/err.h> Loading Loading @@ -2508,6 +2512,10 @@ EC_GROUP *EC_GROUP_new_by_curve_name(int nid) size_t i; EC_GROUP *ret = NULL; #ifdef OPENSSL_FIPS if (FIPS_mode()) return FIPS_ec_group_new_by_curve_name(nid); #endif if (nid <= 0) return NULL; Loading crypto/ec/ec_cvt.c +13 −1 Original line number Diff line number Diff line Loading @@ -69,6 +69,10 @@ * */ #ifdef OPENSSL_FIPS #include <openssl/fips.h> #endif #include <openssl/err.h> #include "ec_lcl.h" Loading @@ -78,6 +82,10 @@ EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM const EC_METHOD *meth; EC_GROUP *ret; #ifdef OPENSSL_FIPS if (FIPS_mode()) return FIPS_ec_group_new_curve_gfp(p,a,b,ctx); #endif #if defined(OPENSSL_BN_ASM_MONT) /* * This might appear controversial, but the fact is that generic Loading Loading @@ -153,6 +161,10 @@ EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM const EC_METHOD *meth; EC_GROUP *ret; #ifdef OPENSSL_FIPS if (FIPS_mode()) return FIPS_ec_group_new_curve_gf2m(p,a,b,ctx); #endif meth = EC_GF2m_simple_method(); ret = EC_GROUP_new(meth); Loading crypto/ec/ec_lcl.h +13 −0 Original line number Diff line number Diff line Loading @@ -194,6 +194,13 @@ struct ec_group_st { int curve_name;/* optional NID for named curve */ int asn1_flag; /* flag to control the asn1 encoding */ /* * Kludge: upper bit of ans1_flag is used to denote structure * version. Is set, then last field is present. This is done * for interoperation with FIPS code. */ #define EC_GROUP_ASN1_FLAG_MASK 0x7fffffff #define EC_GROUP_VERSION(p) (p->asn1_flag&~EC_GROUP_ASN1_FLAG_MASK) point_conversion_form_t asn1_form; unsigned char *seed; /* optional seed for parameters (appears in ASN1) */ Loading Loading @@ -455,3 +462,9 @@ int ec_precompute_mont_data(EC_GROUP *); */ const EC_METHOD *EC_GFp_nistz256_method(void); #endif #ifdef OPENSSL_FIPS EC_GROUP *FIPS_ec_group_new_curve_gfp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); EC_GROUP *FIPS_ec_group_new_curve_gf2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); EC_GROUP *FIPS_ec_group_new_by_curve_name(int nid); #endif crypto/ec/ec_lib.c +12 −8 Original line number Diff line number Diff line Loading @@ -105,7 +105,7 @@ EC_GROUP *EC_GROUP_new(const EC_METHOD *meth) BN_init(&ret->cofactor); ret->curve_name = 0; ret->asn1_flag = 0; ret->asn1_flag = ~EC_GROUP_ASN1_FLAG_MASK; ret->asn1_form = POINT_CONVERSION_UNCOMPRESSED; ret->seed = NULL; Loading @@ -130,7 +130,7 @@ void EC_GROUP_free(EC_GROUP *group) EC_EX_DATA_free_all_data(&group->extra_data); if (group->mont_data) if (EC_GROUP_VERSION(group) && group->mont_data) BN_MONT_CTX_free(group->mont_data); if (group->generator != NULL) Loading @@ -156,7 +156,7 @@ void EC_GROUP_clear_free(EC_GROUP *group) EC_EX_DATA_clear_free_all_data(&group->extra_data); if (group->mont_data) if (EC_GROUP_VERSION(group) && group->mont_data) BN_MONT_CTX_free(group->mont_data); if (group->generator != NULL) Loading Loading @@ -204,7 +204,7 @@ int EC_GROUP_copy(EC_GROUP *dest, const EC_GROUP *src) return 0; } if (src->mont_data != NULL) if (EC_GROUP_VERSION(src) && src->mont_data != NULL) { if (dest->mont_data == NULL) { Loading @@ -216,7 +216,7 @@ int EC_GROUP_copy(EC_GROUP *dest, const EC_GROUP *src) else { /* src->generator == NULL */ if (dest->mont_data != NULL) if (EC_GROUP_VERSION(dest) && dest->mont_data != NULL) { BN_MONT_CTX_free(dest->mont_data); dest->mont_data = NULL; Loading Loading @@ -348,7 +348,7 @@ const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group) BN_MONT_CTX *EC_GROUP_get_mont_data(const EC_GROUP *group) { return group->mont_data; return EC_GROUP_VERSION(group) ? group->mont_data : NULL; } int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx) Loading Loading @@ -383,13 +383,14 @@ int EC_GROUP_get_curve_name(const EC_GROUP *group) void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag) { group->asn1_flag = flag; group->asn1_flag &= ~EC_GROUP_ASN1_FLAG_MASK; group->asn1_flag |= flag&EC_GROUP_ASN1_FLAG_MASK; } int EC_GROUP_get_asn1_flag(const EC_GROUP *group) { return group->asn1_flag; return group->asn1_flag&EC_GROUP_ASN1_FLAG_MASK; } Loading Loading @@ -1137,6 +1138,9 @@ int ec_precompute_mont_data(EC_GROUP *group) BN_CTX *ctx = BN_CTX_new(); int ret = 0; if (!EC_GROUP_VERSION(group)) goto err; if (group->mont_data) { BN_MONT_CTX_free(group->mont_data); Loading Loading
crypto/ec/ec_curve.c +8 −0 Original line number Diff line number Diff line Loading @@ -69,6 +69,10 @@ * */ #ifdef OPENSSL_FIPS #include <openssl/fips.h> #endif #include <string.h> #include "ec_lcl.h" #include <openssl/err.h> Loading Loading @@ -2508,6 +2512,10 @@ EC_GROUP *EC_GROUP_new_by_curve_name(int nid) size_t i; EC_GROUP *ret = NULL; #ifdef OPENSSL_FIPS if (FIPS_mode()) return FIPS_ec_group_new_by_curve_name(nid); #endif if (nid <= 0) return NULL; Loading
crypto/ec/ec_cvt.c +13 −1 Original line number Diff line number Diff line Loading @@ -69,6 +69,10 @@ * */ #ifdef OPENSSL_FIPS #include <openssl/fips.h> #endif #include <openssl/err.h> #include "ec_lcl.h" Loading @@ -78,6 +82,10 @@ EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM const EC_METHOD *meth; EC_GROUP *ret; #ifdef OPENSSL_FIPS if (FIPS_mode()) return FIPS_ec_group_new_curve_gfp(p,a,b,ctx); #endif #if defined(OPENSSL_BN_ASM_MONT) /* * This might appear controversial, but the fact is that generic Loading Loading @@ -153,6 +161,10 @@ EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM const EC_METHOD *meth; EC_GROUP *ret; #ifdef OPENSSL_FIPS if (FIPS_mode()) return FIPS_ec_group_new_curve_gf2m(p,a,b,ctx); #endif meth = EC_GF2m_simple_method(); ret = EC_GROUP_new(meth); Loading
crypto/ec/ec_lcl.h +13 −0 Original line number Diff line number Diff line Loading @@ -194,6 +194,13 @@ struct ec_group_st { int curve_name;/* optional NID for named curve */ int asn1_flag; /* flag to control the asn1 encoding */ /* * Kludge: upper bit of ans1_flag is used to denote structure * version. Is set, then last field is present. This is done * for interoperation with FIPS code. */ #define EC_GROUP_ASN1_FLAG_MASK 0x7fffffff #define EC_GROUP_VERSION(p) (p->asn1_flag&~EC_GROUP_ASN1_FLAG_MASK) point_conversion_form_t asn1_form; unsigned char *seed; /* optional seed for parameters (appears in ASN1) */ Loading Loading @@ -455,3 +462,9 @@ int ec_precompute_mont_data(EC_GROUP *); */ const EC_METHOD *EC_GFp_nistz256_method(void); #endif #ifdef OPENSSL_FIPS EC_GROUP *FIPS_ec_group_new_curve_gfp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); EC_GROUP *FIPS_ec_group_new_curve_gf2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); EC_GROUP *FIPS_ec_group_new_by_curve_name(int nid); #endif
crypto/ec/ec_lib.c +12 −8 Original line number Diff line number Diff line Loading @@ -105,7 +105,7 @@ EC_GROUP *EC_GROUP_new(const EC_METHOD *meth) BN_init(&ret->cofactor); ret->curve_name = 0; ret->asn1_flag = 0; ret->asn1_flag = ~EC_GROUP_ASN1_FLAG_MASK; ret->asn1_form = POINT_CONVERSION_UNCOMPRESSED; ret->seed = NULL; Loading @@ -130,7 +130,7 @@ void EC_GROUP_free(EC_GROUP *group) EC_EX_DATA_free_all_data(&group->extra_data); if (group->mont_data) if (EC_GROUP_VERSION(group) && group->mont_data) BN_MONT_CTX_free(group->mont_data); if (group->generator != NULL) Loading @@ -156,7 +156,7 @@ void EC_GROUP_clear_free(EC_GROUP *group) EC_EX_DATA_clear_free_all_data(&group->extra_data); if (group->mont_data) if (EC_GROUP_VERSION(group) && group->mont_data) BN_MONT_CTX_free(group->mont_data); if (group->generator != NULL) Loading Loading @@ -204,7 +204,7 @@ int EC_GROUP_copy(EC_GROUP *dest, const EC_GROUP *src) return 0; } if (src->mont_data != NULL) if (EC_GROUP_VERSION(src) && src->mont_data != NULL) { if (dest->mont_data == NULL) { Loading @@ -216,7 +216,7 @@ int EC_GROUP_copy(EC_GROUP *dest, const EC_GROUP *src) else { /* src->generator == NULL */ if (dest->mont_data != NULL) if (EC_GROUP_VERSION(dest) && dest->mont_data != NULL) { BN_MONT_CTX_free(dest->mont_data); dest->mont_data = NULL; Loading Loading @@ -348,7 +348,7 @@ const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group) BN_MONT_CTX *EC_GROUP_get_mont_data(const EC_GROUP *group) { return group->mont_data; return EC_GROUP_VERSION(group) ? group->mont_data : NULL; } int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx) Loading Loading @@ -383,13 +383,14 @@ int EC_GROUP_get_curve_name(const EC_GROUP *group) void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag) { group->asn1_flag = flag; group->asn1_flag &= ~EC_GROUP_ASN1_FLAG_MASK; group->asn1_flag |= flag&EC_GROUP_ASN1_FLAG_MASK; } int EC_GROUP_get_asn1_flag(const EC_GROUP *group) { return group->asn1_flag; return group->asn1_flag&EC_GROUP_ASN1_FLAG_MASK; } Loading Loading @@ -1137,6 +1138,9 @@ int ec_precompute_mont_data(EC_GROUP *group) BN_CTX *ctx = BN_CTX_new(); int ret = 0; if (!EC_GROUP_VERSION(group)) goto err; if (group->mont_data) { BN_MONT_CTX_free(group->mont_data); Loading