Add group_order_bits to EC_METHOD.
authorDr. Stephen Henson <steve@openssl.org>
Mon, 1 Feb 2016 18:52:41 +0000 (18:52 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Sun, 28 Feb 2016 22:54:53 +0000 (22:54 +0000)
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Emilia Käsper <emilia@openssl.org>
crypto/ec/ec2_smpl.c
crypto/ec/ec_lcl.h
crypto/ec/ec_lib.c
crypto/ec/ecp_mont.c
crypto/ec/ecp_nist.c
crypto/ec/ecp_nistp224.c
crypto/ec/ecp_nistp256.c
crypto/ec/ecp_nistp521.c
crypto/ec/ecp_nistz256.c
crypto/ec/ecp_smpl.c

index c2ff3f65dda99cbd371ca519c2ded6900b2523bf..4204366435a138f158c6857827a58dff7cdf376c 100644 (file)
@@ -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,
index 742e90a13b262f26871792107d77dc11ec078164..3143b4659bd01edf6b7be11ebd95dc7b7bdf4a18 100644 (file)
@@ -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 *);
     /*
index b7bbc41cdf924d45e7b527af2741b55a72ca10d7..e45cbe3607f88b5364def3ae4f0ebbd7a47b8a59 100644 (file)
@@ -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;
index 799aade01e7e47ca383a1d0e97d89be9ce218491..9217c8f7e15a5b00e95b4dad315d1f190874cedc 100644 (file)
@@ -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,
index a484be442dde56e4244dcbe29440d3d15bd72d2c..cda9a91c91f812b95c486c02b2b35b7cd4e36bbb 100644 (file)
@@ -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,
index a76b60fc31c3c0d712b62857f8e4d74e8d4d28cb..a533fa3cfbaca14647c398f492cdf036d0150b81 100644 (file)
@@ -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,
index a02af0da3e673e2f15e7ae04f146e8377074b283..db95a2d673f968d77180895a9bd18f07ede6dd94 100644 (file)
@@ -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,
index de61a8ab5e4abb6a9170368ab7c1381b3c279439..3edc21913efabe7110af13588cf8827b86b7a0d0 100644 (file)
@@ -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,
index 4b950194108bbb35b2992aa2b896950c749eb475..8ccf831c957f53ff09cf7852cc2528e363a42ffd 100644 (file)
@@ -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,
index 2a1b15d3a5c3a84ed58c48d9a20267d787fe0f3c..2ba40f40b282755364bb91e9ad6d11a2ca2f44fd 100644 (file)
@@ -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,