[test][ectest] Minor touches to custom_generator_test
authorNicola Tuveri <nic.tuv@gmail.com>
Tue, 21 Jul 2020 20:12:59 +0000 (23:12 +0300)
committerNicola Tuveri <nic.tuv@gmail.com>
Wed, 29 Jul 2020 20:46:32 +0000 (23:46 +0300)
Minor changes to `custom_generator_test`:

- this is to align to the 1.1.1 version of the test (simplify the code
  as there is no need to use `EC_GROUP_get_field_type()`)
- add comment to explain how the buffer size is computed

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/12507)

test/ectest.c

index 66da1b9e053edfffe7404ec5bc76853a4995e35d..3678c42f71ed291ba3defbb3419da3b61ebbf9ea 100644 (file)
@@ -2364,10 +2364,8 @@ static int custom_generator_test(int id)
         goto err;
 
     /* expected byte length of encoded points */
-    bsize = (EC_GROUP_get_field_type(group) == NID_X9_62_prime_field) ?
-             BN_num_bytes(EC_GROUP_get0_field(group)) :
-             (EC_GROUP_get_degree(group) + 7) / 8;
-    bsize = 2 * bsize + 1;
+    bsize = (EC_GROUP_get_degree(group) + 7) / 8;
+    bsize = 1 + 2 * bsize; /* UNCOMPRESSED_POINT format */
 
     if (!TEST_ptr(k = BN_CTX_get(ctx))
         /* fetch a testing scalar k != 0,1 */