diff options
author | Juergen Christ <jchrist@linux.ibm.com> | 2022-01-28 10:53:43 +0100 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2022-02-01 14:01:51 +1100 |
commit | 9927749ec2b8fc4b6146f0bd54cb6a44b8295974 (patch) | |
tree | 5979a206531f9d18e4f9abfe926a5213c56d9b3e | |
parent | e180bf641ed23010073b0882d63d5dfd48409602 (diff) |
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@linux.ibm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17608)
-rw-r--r-- | test/params_api_test.c | 16 |
1 files 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(¶m, b)) - || !TEST_mem_eq(bnbuf, param.return_size, buf, param.return_size)) + if (!TEST_true(OSSL_PARAM_set_BN(¶m, 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(¶m, &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(¶m, 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(¶m, &c)) |