For tests, rename ASSERT_ALLOC() to TEST_CALLOC_OR_FAIL()

Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
This commit is contained in:
Tom Cosgrove 2023-07-20 16:48:18 +01:00
parent 65cd8519f7
commit f9ffd11e7a
40 changed files with 347 additions and 347 deletions

View file

@ -124,9 +124,9 @@ void mpi_core_random_basic(int min, char *bound_bytes, int expected_ret)
TEST_EQUAL(0, mbedtls_test_read_mpi_core(&upper_bound, &limbs,
bound_bytes));
ASSERT_ALLOC(lower_bound, limbs);
TEST_CALLOC_OR_FAIL(lower_bound, limbs);
lower_bound[0] = min;
ASSERT_ALLOC(result, limbs);
TEST_CALLOC_OR_FAIL(result, limbs);
TEST_EQUAL(expected_ret,
mbedtls_mpi_core_random(result, min, upper_bound, limbs,
@ -159,7 +159,7 @@ void mpi_legacy_random_values(int min, char *max_hex)
TEST_EQUAL(0, mbedtls_test_read_mpi(&max_legacy, max_hex));
size_t limbs = max_legacy.n;
ASSERT_ALLOC(R_core, limbs);
TEST_CALLOC_OR_FAIL(R_core, limbs);
/* Call the legacy function and the core function with the same random
* stream. */
@ -209,9 +209,9 @@ void mpi_mod_random_values(int min, char *max_hex, int rep)
mbedtls_mpi_mod_modulus_init(&N);
TEST_EQUAL(mbedtls_test_read_mpi_modulus(&N, max_hex, rep), 0);
ASSERT_ALLOC(R_core, N.limbs);
ASSERT_ALLOC(R_mod_raw, N.limbs);
ASSERT_ALLOC(R_mod_digits, N.limbs);
TEST_CALLOC_OR_FAIL(R_core, N.limbs);
TEST_CALLOC_OR_FAIL(R_mod_raw, N.limbs);
TEST_CALLOC_OR_FAIL(R_mod_digits, N.limbs);
TEST_EQUAL(mbedtls_mpi_mod_residue_setup(&R_mod, &N,
R_mod_digits, N.limbs),
0);
@ -287,7 +287,7 @@ void mpi_random_many(int min, char *bound_hex, int iterations)
TEST_EQUAL(0, mbedtls_test_read_mpi_core(&upper_bound, &limbs,
bound_hex));
ASSERT_ALLOC(result, limbs);
TEST_CALLOC_OR_FAIL(result, limbs);
n_bits = mbedtls_mpi_core_bitlen(upper_bound, limbs);
/* Consider a bound "small" if it's less than 2^5. This value is chosen
@ -302,7 +302,7 @@ void mpi_random_many(int min, char *bound_hex, int iterations)
full_stats = 0;
stats_len = n_bits;
}
ASSERT_ALLOC(stats, stats_len);
TEST_CALLOC_OR_FAIL(stats, stats_len);
for (i = 0; i < (size_t) iterations; i++) {
mbedtls_test_set_step(i);
@ -340,7 +340,7 @@ void mpi_random_many(int min, char *bound_hex, int iterations)
}
} else {
bound_bytes.len = limbs * sizeof(mbedtls_mpi_uint);
ASSERT_ALLOC(bound_bytes.x, bound_bytes.len);
TEST_CALLOC_OR_FAIL(bound_bytes.x, bound_bytes.len);
mbedtls_mpi_core_write_be(upper_bound, limbs,
bound_bytes.x, bound_bytes.len);
int statistically_safe_all_the_way =
@ -416,7 +416,7 @@ void mpi_mod_random_validation(int min, char *bound_hex,
MBEDTLS_MPI_MOD_REP_OPT_RED),
0);
size_t result_limbs = N.limbs + result_limbs_delta;
ASSERT_ALLOC(result_digits, result_limbs);
TEST_CALLOC_OR_FAIL(result_digits, result_limbs);
/* Build a reside that might not match the modulus, to test that
* the library function rejects that as expected. */
mbedtls_mpi_mod_residue result = { result_digits, result_limbs };