From e5b2ea0ac3b4d752847d197117d58e0f6ad8e08e Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Mon, 1 Feb 2016 18:52:41 +0000 Subject: [PATCH] Add group_order_bits to EC_METHOD. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Rich Salz Reviewed-by: Emilia Käsper --- crypto/ec/ec2_smpl.c | 1 + crypto/ec/ec_lcl.h | 1 + crypto/ec/ec_lib.c | 2 ++ crypto/ec/ecp_mont.c | 1 + crypto/ec/ecp_nist.c | 1 + crypto/ec/ecp_nistp224.c | 1 + crypto/ec/ecp_nistp256.c | 1 + crypto/ec/ecp_nistp521.c | 1 + crypto/ec/ecp_nistz256.c | 1 + crypto/ec/ecp_smpl.c | 1 + 10 files changed, 11 insertions(+) diff --git a/crypto/ec/ec2_smpl.c b/crypto/ec/ec2_smpl.c index c2ff3f65dd..4204366435 100644 --- a/crypto/ec/ec2_smpl.c +++ b/crypto/ec/ec2_smpl.c @@ -85,6 +85,7 @@ const EC_METHOD *EC_GF2m_simple_method(void) ec_GF2m_simple_group_set_curve, ec_GF2m_simple_group_get_curve, ec_GF2m_simple_group_get_degree, + 0, /* group_order_bits */ ec_GF2m_simple_group_check_discriminant, ec_GF2m_simple_point_init, ec_GF2m_simple_point_finish, diff --git a/crypto/ec/ec_lcl.h b/crypto/ec/ec_lcl.h index 742e90a13b..3143b4659b 100644 --- a/crypto/ec/ec_lcl.h +++ b/crypto/ec/ec_lcl.h @@ -112,6 +112,7 @@ struct ec_method_st { BN_CTX *); /* used by EC_GROUP_get_degree: */ int (*group_get_degree) (const EC_GROUP *); + int (*group_order_bits) (const EC_GROUP *); /* used by EC_GROUP_check: */ int (*group_check_discriminant) (const EC_GROUP *, BN_CTX *); /* diff --git a/crypto/ec/ec_lib.c b/crypto/ec/ec_lib.c index b7bbc41cdf..e45cbe3607 100644 --- a/crypto/ec/ec_lib.c +++ b/crypto/ec/ec_lib.c @@ -373,6 +373,8 @@ const BIGNUM *EC_GROUP_get0_order(const EC_GROUP *group) int EC_GROUP_order_bits(const EC_GROUP *group) { + if (group->meth->group_order_bits) + return group->meth->group_order_bits(group); if (group->order) return BN_num_bits(group->order); return 0; diff --git a/crypto/ec/ecp_mont.c b/crypto/ec/ecp_mont.c index 799aade01e..9217c8f7e1 100644 --- a/crypto/ec/ecp_mont.c +++ b/crypto/ec/ecp_mont.c @@ -76,6 +76,7 @@ const EC_METHOD *EC_GFp_mont_method(void) ec_GFp_mont_group_set_curve, ec_GFp_simple_group_get_curve, ec_GFp_simple_group_get_degree, + 0, /* group_order_bits */ ec_GFp_simple_group_check_discriminant, ec_GFp_simple_point_init, ec_GFp_simple_point_finish, diff --git a/crypto/ec/ecp_nist.c b/crypto/ec/ecp_nist.c index a484be442d..cda9a91c91 100644 --- a/crypto/ec/ecp_nist.c +++ b/crypto/ec/ecp_nist.c @@ -78,6 +78,7 @@ const EC_METHOD *EC_GFp_nist_method(void) ec_GFp_nist_group_set_curve, ec_GFp_simple_group_get_curve, ec_GFp_simple_group_get_degree, + 0, /* group_order_bits */ ec_GFp_simple_group_check_discriminant, ec_GFp_simple_point_init, ec_GFp_simple_point_finish, diff --git a/crypto/ec/ecp_nistp224.c b/crypto/ec/ecp_nistp224.c index a76b60fc31..a533fa3cfb 100644 --- a/crypto/ec/ecp_nistp224.c +++ b/crypto/ec/ecp_nistp224.c @@ -245,6 +245,7 @@ const EC_METHOD *EC_GFp_nistp224_method(void) ec_GFp_nistp224_group_set_curve, ec_GFp_simple_group_get_curve, ec_GFp_simple_group_get_degree, + 0, /* group_order_bits */ ec_GFp_simple_group_check_discriminant, ec_GFp_simple_point_init, ec_GFp_simple_point_finish, diff --git a/crypto/ec/ecp_nistp256.c b/crypto/ec/ecp_nistp256.c index a02af0da3e..db95a2d673 100644 --- a/crypto/ec/ecp_nistp256.c +++ b/crypto/ec/ecp_nistp256.c @@ -1774,6 +1774,7 @@ const EC_METHOD *EC_GFp_nistp256_method(void) ec_GFp_nistp256_group_set_curve, ec_GFp_simple_group_get_curve, ec_GFp_simple_group_get_degree, + 0, /* group_order_bits */ ec_GFp_simple_group_check_discriminant, ec_GFp_simple_point_init, ec_GFp_simple_point_finish, diff --git a/crypto/ec/ecp_nistp521.c b/crypto/ec/ecp_nistp521.c index de61a8ab5e..3edc21913e 100644 --- a/crypto/ec/ecp_nistp521.c +++ b/crypto/ec/ecp_nistp521.c @@ -1603,6 +1603,7 @@ const EC_METHOD *EC_GFp_nistp521_method(void) ec_GFp_nistp521_group_set_curve, ec_GFp_simple_group_get_curve, ec_GFp_simple_group_get_degree, + 0, /* group_order_bits */ ec_GFp_simple_group_check_discriminant, ec_GFp_simple_point_init, ec_GFp_simple_point_finish, diff --git a/crypto/ec/ecp_nistz256.c b/crypto/ec/ecp_nistz256.c index 4b95019410..8ccf831c95 100644 --- a/crypto/ec/ecp_nistz256.c +++ b/crypto/ec/ecp_nistz256.c @@ -1441,6 +1441,7 @@ const EC_METHOD *EC_GFp_nistz256_method(void) ec_GFp_mont_group_set_curve, ec_GFp_simple_group_get_curve, ec_GFp_simple_group_get_degree, + 0, /* group_order_bits */ ec_GFp_simple_group_check_discriminant, ec_GFp_simple_point_init, ec_GFp_simple_point_finish, diff --git a/crypto/ec/ecp_smpl.c b/crypto/ec/ecp_smpl.c index 2a1b15d3a5..2ba40f40b2 100644 --- a/crypto/ec/ecp_smpl.c +++ b/crypto/ec/ecp_smpl.c @@ -79,6 +79,7 @@ const EC_METHOD *EC_GFp_simple_method(void) ec_GFp_simple_group_set_curve, ec_GFp_simple_group_get_curve, ec_GFp_simple_group_get_degree, + 0, /* group_order_bits */ ec_GFp_simple_group_check_discriminant, ec_GFp_simple_point_init, ec_GFp_simple_point_finish, -- 2.34.1