forked from wolfSSL/wolfssl
Fix for EC_GROUP_order_bits
and added unit test.
This commit is contained in:
@ -31463,7 +31463,6 @@ int wolfSSL_EC_GROUP_get_order(const WOLFSSL_EC_GROUP *group,
|
||||
int wolfSSL_EC_GROUP_order_bits(const WOLFSSL_EC_GROUP *group)
|
||||
{
|
||||
int ret;
|
||||
int order_bits = 0;
|
||||
mp_int order;
|
||||
|
||||
if (group == NULL || group->curve_idx < 0) {
|
||||
@ -31476,11 +31475,7 @@ int wolfSSL_EC_GROUP_order_bits(const WOLFSSL_EC_GROUP *group)
|
||||
ret = mp_read_radix(&order, ecc_sets[group->curve_idx].order,
|
||||
MP_RADIX_HEX);
|
||||
if (ret == 0)
|
||||
ret = mp_unsigned_bin_size(&order);
|
||||
if (ret >= 0)
|
||||
ret = mp_to_unsigned_bin(&order, (byte*)&order_bits);
|
||||
if (ret == 0)
|
||||
ret = order_bits;
|
||||
ret = mp_count_bits(&order);
|
||||
mp_clear(&order);
|
||||
}
|
||||
|
||||
|
@ -1678,7 +1678,7 @@ static int test_wolfSSL_SetMinVersion(void)
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/* Test function for EC_POINT_new, EC_POINT_mul, EC_POINT_free,
|
||||
EC_GROUP_new_by_curve_name
|
||||
EC_GROUP_new_by_curve_name, EC_GROUP_order_bits
|
||||
*/
|
||||
|
||||
# if defined(OPENSSL_EXTRA)
|
||||
@ -1691,6 +1691,7 @@ static void test_wolfSSL_EC(void)
|
||||
BIGNUM *k = NULL, *Gx = NULL, *Gy = NULL, *Gz = NULL;
|
||||
BIGNUM *X, *Y;
|
||||
char* hexStr;
|
||||
int group_bits;
|
||||
|
||||
const char* kTest = "F4F8338AFCC562C5C3F3E1E46A7EFECD17AF381913FF7A96314EA47055EA0FD0";
|
||||
/* NISTP256R1 Gx/Gy */
|
||||
@ -1704,6 +1705,7 @@ static void test_wolfSSL_EC(void)
|
||||
|
||||
AssertNotNull(ctx = BN_CTX_new());
|
||||
AssertNotNull(group = EC_GROUP_new_by_curve_name(NID_X9_62_prime256v1));
|
||||
AssertIntEQ((group_bits = EC_GROUP_order_bits(group)), 256);
|
||||
AssertNotNull(Gxy = EC_POINT_new(group));
|
||||
AssertNotNull(new_point = EC_POINT_new(group));
|
||||
AssertNotNull(X = BN_new());
|
||||
|
Reference in New Issue
Block a user