diff options
author | Aakash Sasidharan <asasidharan@marvell.com> | 2022-05-10 13:15:04 +0530 |
---|---|---|
committer | Matias Elo <matias.elo@nokia.com> | 2022-05-23 15:39:42 +0300 |
commit | e3ff8f74f1f200c0e14b1ab22a8e6904d1c87589 (patch) | |
tree | b8dc273521fcec727594154ca679f489b5791d2f /test | |
parent | 4bda1edb1bb667f3ba6923282d6ad127b43e39a0 (diff) |
validation: crypto: fix test_auth_hash_in_auth_range
Handle session creation failure with test_auth_hash_in_auth_range().
Allow the test to continue when crypto_op fails so that the session is
freed appropriately.
Fixes: b7d520dfa0af ("validation: crypto: test hash result overlap with auth range")
Signed-off-by: Aakash Sasidharan <asasidharan@marvell.com>
Reviewed-by: Janne Peltonen <janne.peltonen@nokia.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/validation/api/crypto/odp_crypto_test_inp.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/test/validation/api/crypto/odp_crypto_test_inp.c b/test/validation/api/crypto/odp_crypto_test_inp.c index 6b27280cf..bf06fb007 100644 --- a/test/validation/api/crypto/odp_crypto_test_inp.c +++ b/test/validation/api/crypto/odp_crypto_test_inp.c @@ -1178,11 +1178,11 @@ static void test_capability(void) * operation with hash_result_offset outside the auth_range and by * copying the hash in the ciphertext packet. */ -static void create_hash_test_reference(odp_auth_alg_t auth, - const odp_crypto_auth_capability_t *capa, - crypto_test_reference_t *ref, - uint32_t digest_offset, - uint8_t digest_fill_byte) +static int create_hash_test_reference(odp_auth_alg_t auth, + const odp_crypto_auth_capability_t *capa, + crypto_test_reference_t *ref, + uint32_t digest_offset, + uint8_t digest_fill_byte) { odp_crypto_session_t session; int rc; @@ -1220,12 +1220,12 @@ static void create_hash_test_reference(odp_auth_alg_t auth, session = session_create(ODP_CRYPTO_OP_ENCODE, ODP_CIPHER_ALG_NULL, auth, ref, PACKET_IV, HASH_NO_OVERLAP); + if (session == ODP_CRYPTO_SESSION_INVALID) + return -1; - if (crypto_op(pkt, &ok, session, - ref->cipher_iv, ref->auth_iv, - &cipher_range, &auth_range, - ref->aad, enc_digest_offset)) - return; + rc = crypto_op(pkt, &ok, session, ref->cipher_iv, ref->auth_iv, + &cipher_range, &auth_range, ref->aad, enc_digest_offset); + CU_ASSERT(rc == 0); CU_ASSERT(ok); rc = odp_crypto_session_destroy(session); @@ -1246,6 +1246,8 @@ static void create_hash_test_reference(odp_auth_alg_t auth, CU_ASSERT(rc == 0); odp_packet_free(pkt); + + return 0; } static void test_auth_hash_in_auth_range(odp_auth_alg_t auth, @@ -1258,7 +1260,8 @@ static void test_auth_hash_in_auth_range(odp_auth_alg_t auth, * Create test packets with auth hash in the authenticated range and * zeroes in the hash location in the plaintext packet. */ - create_hash_test_reference(auth, capa, &ref, digest_offset, 0); + if (create_hash_test_reference(auth, capa, &ref, digest_offset, 0)) + return; /* * Decode the ciphertext packet. @@ -1280,7 +1283,8 @@ static void test_auth_hash_in_auth_range(odp_auth_alg_t auth, * Create test packets with auth hash in the authenticated range and * ones in the hash location in the plaintext packet. */ - create_hash_test_reference(auth, capa, &ref, digest_offset, 1); + if (create_hash_test_reference(auth, capa, &ref, digest_offset, 1)) + return; /* * Encode the plaintext packet. |