Skip to content

Commit

Permalink
Fix endianness problem in params_api_test
Browse files Browse the repository at this point in the history
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@linux.ibm.com>

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from #17608)

(cherry picked from commit 9927749)
  • Loading branch information
juergenchrist authored and t8m committed Nov 11, 2022
1 parent 34ca334 commit e8f1d76
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions test/params_api_test.c
Expand Up @@ -424,14 +424,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, 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, bnbuf, len);
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))
Expand Down

0 comments on commit e8f1d76

Please sign in to comment.