[openssl] master update

Dr. Paul Dale pauli at openssl.org
Tue Feb 1 03:02:19 UTC 2022


The branch master has been updated
       via  9927749ec2b8fc4b6146f0bd54cb6a44b8295974 (commit)
      from  e180bf641ed23010073b0882d63d5dfd48409602 (commit)


- Log -----------------------------------------------------------------
commit 9927749ec2b8fc4b6146f0bd54cb6a44b8295974
Author: Juergen Christ <jchrist at linux.ibm.com>
Date:   Fri Jan 28 10:53:43 2022 +0100

    Fix endianness problem in params_api_test
    
    On a big endian machine, we get test failures in params_api_test like
    
            # ERROR: (memory) 'buf1 == buf2' failed @ test/params_api_test.c:473
            # --- buf1
            # +++ buf2
            # 0000:-e901
            # 0000:+01e9
            #       ^^^^
            #
            # OPENSSL_TEST_RAND_ORDER=1643313367
            not ok 157 - iteration 3
    
    They are due to an additional conversion copy.  Remove this copy to solve the
    problem.
    
    Signed-off-by: Juergen Christ <jchrist at linux.ibm.com>
    
    Reviewed-by: Tomas Mraz <tomas at openssl.org>
    Reviewed-by: Paul Dale <pauli at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/17608)

-----------------------------------------------------------------------

Summary of changes:
 test/params_api_test.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/test/params_api_test.c b/test/params_api_test.c
index d073477d5a..8aa6676e32 100644
--- a/test/params_api_test.c
+++ b/test/params_api_test.c
@@ -428,14 +428,15 @@ static int test_param_bignum(int n)
     int ret = 0;
 
     param.data = bnbuf;
-    param.data_size = len;
+    param.data_size = sizeof(bnbuf);
 
-    le_copy(buf, len, raw_values[n].value, len);
     if (!TEST_ptr(b = BN_lebin2bn(raw_values[n].value, (int)len, NULL)))
         goto err;
 
-    if (!TEST_true(OSSL_PARAM_set_BN(&param, b))
-        || !TEST_mem_eq(bnbuf, param.return_size, buf, param.return_size))
+    if (!TEST_true(OSSL_PARAM_set_BN(&param, b)))
+        goto err;
+    le_copy(buf, len, bnbuf, sizeof(bnbuf));
+    if (!TEST_mem_eq(raw_values[n].value, len, buf, len))
         goto err;
     param.data_size = param.return_size;
     if (!TEST_true(OSSL_PARAM_get_BN(&param, &c))
@@ -451,7 +452,7 @@ err:
 
 static int test_param_signed_bignum(int n)
 {
-    unsigned char buf1[MAX_LEN], buf2[MAX_LEN], bnbuf[MAX_LEN];
+    unsigned char buf[MAX_LEN], bnbuf[MAX_LEN];
     const size_t len = raw_values[n].len;
     BIGNUM *b = NULL, *c = NULL;
     OSSL_PARAM param = OSSL_PARAM_DEFN("bn", OSSL_PARAM_INTEGER, NULL, 0);
@@ -460,7 +461,6 @@ static int test_param_signed_bignum(int n)
     param.data = bnbuf;
     param.data_size = sizeof(bnbuf);
 
-    le_copy(buf1, len, raw_values[n].value, len);
     if (!TEST_ptr(b = BN_signed_lebin2bn(raw_values[n].value, (int)len, NULL)))
         goto err;
 
@@ -469,8 +469,8 @@ static int test_param_signed_bignum(int n)
         goto err;
     if (!TEST_true(OSSL_PARAM_set_BN(&param, b)))
         goto err;
-    le_copy(buf2, len, bnbuf, sizeof(bnbuf));
-    if (!TEST_mem_eq(buf1, len, buf2, len))
+    le_copy(buf, len, bnbuf, sizeof(bnbuf));
+    if (!TEST_mem_eq(raw_values[n].value, len, buf, len))
         goto err;
     param.data_size = param.return_size;
     if (!TEST_true(OSSL_PARAM_get_BN(&param, &c))


More information about the openssl-commits mailing list