diff --git a/test/test/test_cryptodev.c b/test/test/test_cryptodev.c index 4c750f6790..83b8ee7f3e 100644 --- a/test/test/test_cryptodev.c +++ b/test/test/test_cryptodev.c @@ -58,7 +58,7 @@ #include "test_cryptodev_snow3g_test_vectors.h" #include "test_cryptodev_snow3g_hash_test_vectors.h" #include "test_cryptodev_zuc_test_vectors.h" -#include "test_cryptodev_gcm_test_vectors.h" +#include "test_cryptodev_aead_test_vectors.h" #include "test_cryptodev_hmac_test_vectors.h" static int gbl_driver_id; @@ -4842,10 +4842,11 @@ test_3DES_cipheronly_openssl_all(void) return TEST_SUCCESS; } -/* ***** AES-GCM Tests ***** */ +/* ***** AEAD algorithm Tests ***** */ static int -create_gcm_session(uint8_t dev_id, enum rte_crypto_aead_operation op, +create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo, + enum rte_crypto_aead_operation op, const uint8_t *key, const uint8_t key_len, const uint16_t aad_len, const uint8_t auth_len, uint8_t iv_len) @@ -4860,7 +4861,7 @@ create_gcm_session(uint8_t dev_id, enum rte_crypto_aead_operation op, /* Setup AEAD Parameters */ ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD; ut_params->aead_xform.next = NULL; - ut_params->aead_xform.aead.algo = RTE_CRYPTO_AEAD_AES_GCM; + ut_params->aead_xform.aead.algo = algo; ut_params->aead_xform.aead.op = op; ut_params->aead_xform.aead.key.data = aead_key; ut_params->aead_xform.aead.key.length = key_len; @@ -4884,7 +4885,8 @@ create_gcm_session(uint8_t dev_id, enum rte_crypto_aead_operation op, } static int -create_gcm_xforms(struct rte_crypto_op *op, +create_aead_xform(struct rte_crypto_op *op, + enum rte_crypto_aead_algorithm algo, enum rte_crypto_aead_operation aead_op, uint8_t *key, const uint8_t key_len, const uint8_t aad_len, const uint8_t auth_len, @@ -4898,7 +4900,7 @@ create_gcm_xforms(struct rte_crypto_op *op, /* Setup AEAD Parameters */ sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD; sym_op->xform->next = NULL; - sym_op->xform->aead.algo = RTE_CRYPTO_AEAD_AES_GCM; + sym_op->xform->aead.algo = algo; sym_op->xform->aead.op = aead_op; sym_op->xform->aead.key.data = key; sym_op->xform->aead.key.length = key_len; @@ -4913,8 +4915,8 @@ create_gcm_xforms(struct rte_crypto_op *op, } static int -create_gcm_operation(enum rte_crypto_aead_operation op, - const struct gcm_test_data *tdata) +create_aead_operation(enum rte_crypto_aead_operation op, + const struct aead_test_data *tdata) { struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -5033,7 +5035,7 @@ create_gcm_operation(enum rte_crypto_aead_operation op, } static int -test_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata) +test_authenticated_encryption(const struct aead_test_data *tdata) { struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -5043,8 +5045,9 @@ test_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata) uint16_t plaintext_pad_len; uint32_t i; - /* Create GCM session */ - retval = create_gcm_session(ts_params->valid_devs[0], + /* Create AEAD session */ + retval = create_aead_session(ts_params->valid_devs[0], + tdata->algo, RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata->key.data, tdata->key.len, tdata->aad.len, tdata->auth_tag.len, @@ -5055,7 +5058,7 @@ test_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata) if (tdata->aad.len > MBUF_SIZE) { ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool); /* Populate full size of add data */ - for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32) + for (i = 32; i < MAX_AAD_LENGTH; i += 32) memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32); } else ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); @@ -5064,8 +5067,8 @@ test_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata) memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, rte_pktmbuf_tailroom(ut_params->ibuf)); - /* Create GCM operation */ - retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata); + /* Create AEAD operation */ + retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata); if (retval < 0) return retval; @@ -5102,13 +5105,13 @@ test_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata) ciphertext, tdata->ciphertext.data, tdata->ciphertext.len, - "GCM Ciphertext data not as expected"); + "Ciphertext data not as expected"); TEST_ASSERT_BUFFERS_ARE_EQUAL( auth_tag, tdata->auth_tag.data, tdata->auth_tag.len, - "GCM Generated auth tag not as expected"); + "Generated auth tag not as expected"); return 0; @@ -5117,143 +5120,143 @@ test_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata) static int test_AES_GCM_authenticated_encryption_test_case_1(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_1); + return test_authenticated_encryption(&gcm_test_case_1); } static int test_AES_GCM_authenticated_encryption_test_case_2(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_2); + return test_authenticated_encryption(&gcm_test_case_2); } static int test_AES_GCM_authenticated_encryption_test_case_3(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_3); + return test_authenticated_encryption(&gcm_test_case_3); } static int test_AES_GCM_authenticated_encryption_test_case_4(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_4); + return test_authenticated_encryption(&gcm_test_case_4); } static int test_AES_GCM_authenticated_encryption_test_case_5(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_5); + return test_authenticated_encryption(&gcm_test_case_5); } static int test_AES_GCM_authenticated_encryption_test_case_6(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_6); + return test_authenticated_encryption(&gcm_test_case_6); } static int test_AES_GCM_authenticated_encryption_test_case_7(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_7); + return test_authenticated_encryption(&gcm_test_case_7); } static int test_AES_GCM_auth_encryption_test_case_192_1(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_1); + return test_authenticated_encryption(&gcm_test_case_192_1); } static int test_AES_GCM_auth_encryption_test_case_192_2(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_2); + return test_authenticated_encryption(&gcm_test_case_192_2); } static int test_AES_GCM_auth_encryption_test_case_192_3(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_3); + return test_authenticated_encryption(&gcm_test_case_192_3); } static int test_AES_GCM_auth_encryption_test_case_192_4(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_4); + return test_authenticated_encryption(&gcm_test_case_192_4); } static int test_AES_GCM_auth_encryption_test_case_192_5(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_5); + return test_authenticated_encryption(&gcm_test_case_192_5); } static int test_AES_GCM_auth_encryption_test_case_192_6(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_6); + return test_authenticated_encryption(&gcm_test_case_192_6); } static int test_AES_GCM_auth_encryption_test_case_192_7(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_7); + return test_authenticated_encryption(&gcm_test_case_192_7); } static int test_AES_GCM_auth_encryption_test_case_256_1(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_1); + return test_authenticated_encryption(&gcm_test_case_256_1); } static int test_AES_GCM_auth_encryption_test_case_256_2(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_2); + return test_authenticated_encryption(&gcm_test_case_256_2); } static int test_AES_GCM_auth_encryption_test_case_256_3(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_3); + return test_authenticated_encryption(&gcm_test_case_256_3); } static int test_AES_GCM_auth_encryption_test_case_256_4(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_4); + return test_authenticated_encryption(&gcm_test_case_256_4); } static int test_AES_GCM_auth_encryption_test_case_256_5(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_5); + return test_authenticated_encryption(&gcm_test_case_256_5); } static int test_AES_GCM_auth_encryption_test_case_256_6(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_6); + return test_authenticated_encryption(&gcm_test_case_256_6); } static int test_AES_GCM_auth_encryption_test_case_256_7(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_7); + return test_authenticated_encryption(&gcm_test_case_256_7); } static int test_AES_GCM_auth_encryption_test_case_aad_1(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_aad_1); + return test_authenticated_encryption(&gcm_test_case_aad_1); } static int test_AES_GCM_auth_encryption_test_case_aad_2(void) { - return test_AES_GCM_authenticated_encryption(&gcm_test_case_aad_2); + return test_authenticated_encryption(&gcm_test_case_aad_2); } static int -test_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata) +test_authenticated_decryption(const struct aead_test_data *tdata) { struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -5262,8 +5265,9 @@ test_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata) uint8_t *plaintext; uint32_t i; - /* Create GCM session */ - retval = create_gcm_session(ts_params->valid_devs[0], + /* Create AEAD session */ + retval = create_aead_session(ts_params->valid_devs[0], + tdata->algo, RTE_CRYPTO_AEAD_OP_DECRYPT, tdata->key.data, tdata->key.len, tdata->aad.len, tdata->auth_tag.len, @@ -5275,7 +5279,7 @@ test_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata) if (tdata->aad.len > MBUF_SIZE) { ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool); /* Populate full size of add data */ - for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32) + for (i = 32; i < MAX_AAD_LENGTH; i += 32) memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32); } else ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); @@ -5283,8 +5287,8 @@ test_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata) memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, rte_pktmbuf_tailroom(ut_params->ibuf)); - /* Create GCM operation */ - retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata); + /* Create AEAD operation */ + retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata); if (retval < 0) return retval; @@ -5314,154 +5318,154 @@ test_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata) plaintext, tdata->plaintext.data, tdata->plaintext.len, - "GCM plaintext data not as expected"); + "Plaintext data not as expected"); TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS, - "GCM authentication failed"); + "Authentication failed"); return 0; } static int test_AES_GCM_authenticated_decryption_test_case_1(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_1); + return test_authenticated_decryption(&gcm_test_case_1); } static int test_AES_GCM_authenticated_decryption_test_case_2(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_2); + return test_authenticated_decryption(&gcm_test_case_2); } static int test_AES_GCM_authenticated_decryption_test_case_3(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_3); + return test_authenticated_decryption(&gcm_test_case_3); } static int test_AES_GCM_authenticated_decryption_test_case_4(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_4); + return test_authenticated_decryption(&gcm_test_case_4); } static int test_AES_GCM_authenticated_decryption_test_case_5(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_5); + return test_authenticated_decryption(&gcm_test_case_5); } static int test_AES_GCM_authenticated_decryption_test_case_6(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_6); + return test_authenticated_decryption(&gcm_test_case_6); } static int test_AES_GCM_authenticated_decryption_test_case_7(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_7); + return test_authenticated_decryption(&gcm_test_case_7); } static int test_AES_GCM_auth_decryption_test_case_192_1(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_1); + return test_authenticated_decryption(&gcm_test_case_192_1); } static int test_AES_GCM_auth_decryption_test_case_192_2(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_2); + return test_authenticated_decryption(&gcm_test_case_192_2); } static int test_AES_GCM_auth_decryption_test_case_192_3(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_3); + return test_authenticated_decryption(&gcm_test_case_192_3); } static int test_AES_GCM_auth_decryption_test_case_192_4(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_4); + return test_authenticated_decryption(&gcm_test_case_192_4); } static int test_AES_GCM_auth_decryption_test_case_192_5(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_5); + return test_authenticated_decryption(&gcm_test_case_192_5); } static int test_AES_GCM_auth_decryption_test_case_192_6(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_6); + return test_authenticated_decryption(&gcm_test_case_192_6); } static int test_AES_GCM_auth_decryption_test_case_192_7(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_7); + return test_authenticated_decryption(&gcm_test_case_192_7); } static int test_AES_GCM_auth_decryption_test_case_256_1(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_1); + return test_authenticated_decryption(&gcm_test_case_256_1); } static int test_AES_GCM_auth_decryption_test_case_256_2(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_2); + return test_authenticated_decryption(&gcm_test_case_256_2); } static int test_AES_GCM_auth_decryption_test_case_256_3(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_3); + return test_authenticated_decryption(&gcm_test_case_256_3); } static int test_AES_GCM_auth_decryption_test_case_256_4(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_4); + return test_authenticated_decryption(&gcm_test_case_256_4); } static int test_AES_GCM_auth_decryption_test_case_256_5(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_5); + return test_authenticated_decryption(&gcm_test_case_256_5); } static int test_AES_GCM_auth_decryption_test_case_256_6(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_6); + return test_authenticated_decryption(&gcm_test_case_256_6); } static int test_AES_GCM_auth_decryption_test_case_256_7(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_7); + return test_authenticated_decryption(&gcm_test_case_256_7); } static int test_AES_GCM_auth_decryption_test_case_aad_1(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_aad_1); + return test_authenticated_decryption(&gcm_test_case_aad_1); } static int test_AES_GCM_auth_decryption_test_case_aad_2(void) { - return test_AES_GCM_authenticated_decryption(&gcm_test_case_aad_2); + return test_authenticated_decryption(&gcm_test_case_aad_2); } static int -test_AES_GCM_authenticated_encryption_oop(const struct gcm_test_data *tdata) +test_authenticated_encryption_oop(const struct aead_test_data *tdata) { struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -5470,8 +5474,9 @@ test_AES_GCM_authenticated_encryption_oop(const struct gcm_test_data *tdata) uint8_t *ciphertext, *auth_tag; uint16_t plaintext_pad_len; - /* Create GCM session */ - retval = create_gcm_session(ts_params->valid_devs[0], + /* Create AEAD session */ + retval = create_aead_session(ts_params->valid_devs[0], + tdata->algo, RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata->key.data, tdata->key.len, tdata->aad.len, tdata->auth_tag.len, @@ -5488,8 +5493,8 @@ test_AES_GCM_authenticated_encryption_oop(const struct gcm_test_data *tdata) memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0, rte_pktmbuf_tailroom(ut_params->obuf)); - /* Create GCM operation */ - retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata); + /* Create AEAD operation */ + retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata); if (retval < 0) return retval; @@ -5519,13 +5524,13 @@ test_AES_GCM_authenticated_encryption_oop(const struct gcm_test_data *tdata) ciphertext, tdata->ciphertext.data, tdata->ciphertext.len, - "GCM Ciphertext data not as expected"); + "Ciphertext data not as expected"); TEST_ASSERT_BUFFERS_ARE_EQUAL( auth_tag, tdata->auth_tag.data, tdata->auth_tag.len, - "GCM Generated auth tag not as expected"); + "Generated auth tag not as expected"); return 0; @@ -5534,11 +5539,11 @@ test_AES_GCM_authenticated_encryption_oop(const struct gcm_test_data *tdata) static int test_AES_GCM_authenticated_encryption_oop_test_case_1(void) { - return test_AES_GCM_authenticated_encryption_oop(&gcm_test_case_5); + return test_authenticated_encryption_oop(&gcm_test_case_5); } static int -test_AES_GCM_authenticated_decryption_oop(const struct gcm_test_data *tdata) +test_authenticated_decryption_oop(const struct aead_test_data *tdata) { struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -5546,8 +5551,9 @@ test_AES_GCM_authenticated_decryption_oop(const struct gcm_test_data *tdata) int retval; uint8_t *plaintext; - /* Create GCM session */ - retval = create_gcm_session(ts_params->valid_devs[0], + /* Create AEAD session */ + retval = create_aead_session(ts_params->valid_devs[0], + tdata->algo, RTE_CRYPTO_AEAD_OP_DECRYPT, tdata->key.data, tdata->key.len, tdata->aad.len, tdata->auth_tag.len, @@ -5564,8 +5570,8 @@ test_AES_GCM_authenticated_decryption_oop(const struct gcm_test_data *tdata) memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0, rte_pktmbuf_tailroom(ut_params->obuf)); - /* Create GCM operation */ - retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata); + /* Create AEAD operation */ + retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata); if (retval < 0) return retval; @@ -5591,23 +5597,23 @@ test_AES_GCM_authenticated_decryption_oop(const struct gcm_test_data *tdata) plaintext, tdata->plaintext.data, tdata->plaintext.len, - "GCM plaintext data not as expected"); + "Plaintext data not as expected"); TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS, - "GCM authentication failed"); + "Authentication failed"); return 0; } static int test_AES_GCM_authenticated_decryption_oop_test_case_1(void) { - return test_AES_GCM_authenticated_decryption_oop(&gcm_test_case_5); + return test_authenticated_decryption_oop(&gcm_test_case_5); } static int -test_AES_GCM_authenticated_encryption_sessionless( - const struct gcm_test_data *tdata) +test_authenticated_encryption_sessionless( + const struct aead_test_data *tdata) { struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -5623,14 +5629,15 @@ test_AES_GCM_authenticated_encryption_sessionless( memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, rte_pktmbuf_tailroom(ut_params->ibuf)); - /* Create GCM operation */ - retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata); + /* Create AEAD operation */ + retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata); if (retval < 0) return retval; - /* Create GCM xforms */ + /* Create GCM xform */ memcpy(key, tdata->key.data, tdata->key.len); - retval = create_gcm_xforms(ut_params->op, + retval = create_aead_xform(ut_params->op, + tdata->algo, RTE_CRYPTO_AEAD_OP_ENCRYPT, key, tdata->key.len, tdata->aad.len, tdata->auth_tag.len, @@ -5667,13 +5674,13 @@ test_AES_GCM_authenticated_encryption_sessionless( ciphertext, tdata->ciphertext.data, tdata->ciphertext.len, - "GCM Ciphertext data not as expected"); + "Ciphertext data not as expected"); TEST_ASSERT_BUFFERS_ARE_EQUAL( auth_tag, tdata->auth_tag.data, tdata->auth_tag.len, - "GCM Generated auth tag not as expected"); + "Generated auth tag not as expected"); return 0; @@ -5682,13 +5689,13 @@ test_AES_GCM_authenticated_encryption_sessionless( static int test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void) { - return test_AES_GCM_authenticated_encryption_sessionless( + return test_authenticated_encryption_sessionless( &gcm_test_case_5); } static int -test_AES_GCM_authenticated_decryption_sessionless( - const struct gcm_test_data *tdata) +test_authenticated_decryption_sessionless( + const struct aead_test_data *tdata) { struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -5703,14 +5710,15 @@ test_AES_GCM_authenticated_decryption_sessionless( memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, rte_pktmbuf_tailroom(ut_params->ibuf)); - /* Create GCM operation */ - retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata); + /* Create AEAD operation */ + retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata); if (retval < 0) return retval; - /* Create GCM xforms */ + /* Create AEAD xform */ memcpy(key, tdata->key.data, tdata->key.len); - retval = create_gcm_xforms(ut_params->op, + retval = create_aead_xform(ut_params->op, + tdata->algo, RTE_CRYPTO_AEAD_OP_DECRYPT, key, tdata->key.len, tdata->aad.len, tdata->auth_tag.len, @@ -5743,18 +5751,18 @@ test_AES_GCM_authenticated_decryption_sessionless( plaintext, tdata->plaintext.data, tdata->plaintext.len, - "GCM plaintext data not as expected"); + "Plaintext data not as expected"); TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS, - "GCM authentication failed"); + "Authentication failed"); return 0; } static int test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void) { - return test_AES_GCM_authenticated_decryption_sessionless( + return test_authenticated_decryption_sessionless( &gcm_test_case_5); } @@ -7463,8 +7471,8 @@ test_authenticated_decryption_fail_when_corruption( } static int -create_gcm_operation_SGL(enum rte_crypto_aead_operation op, - const struct gcm_test_data *tdata, +create_aead_operation_SGL(enum rte_crypto_aead_operation op, + const struct aead_test_data *tdata, void *digest_mem, uint64_t digest_phys) { struct crypto_testsuite_params *ts_params = &testsuite_params; @@ -7525,7 +7533,7 @@ create_gcm_operation_SGL(enum rte_crypto_aead_operation op, #define SGL_MAX_NO 16 static int -test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata, +test_authenticated_encryption_SGL(const struct aead_test_data *tdata, const int oop, uint32_t fragsz, uint32_t fragsz_oop) { struct crypto_testsuite_params *ts_params = &testsuite_params; @@ -7570,8 +7578,9 @@ test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata, buf_oop = ut_params->obuf; } - /* Create GCM session */ - retval = create_gcm_session(ts_params->valid_devs[0], + /* Create AEAD session */ + retval = create_aead_session(ts_params->valid_devs[0], + tdata->algo, RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata->key.data, tdata->key.len, tdata->aad.len, tdata->auth_tag.len, @@ -7700,8 +7709,8 @@ test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata, tdata->plaintext.len); } - /* Create GCM opertaion */ - retval = create_gcm_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT, + /* Create AEAD operation */ + retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata, digest_mem, digest_phys); if (retval < 0) @@ -7735,7 +7744,7 @@ test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata, ciphertext, tdata->ciphertext.data, fragsz, - "GCM Ciphertext data not as expected"); + "Ciphertext data not as expected"); buf = ut_params->op->sym->m_src->next; if (oop) @@ -7752,7 +7761,7 @@ test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata, ciphertext, tdata->ciphertext.data + off, to_trn_tbl[ecx], - "GCM Ciphertext data not as expected"); + "Ciphertext data not as expected"); off += to_trn_tbl[ecx++]; buf = buf->next; @@ -7763,7 +7772,7 @@ test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata, auth_tag, tdata->auth_tag.data, tdata->auth_tag.len, - "GCM Generated auth tag not as expected"); + "Generated auth tag not as expected"); return 0; } @@ -7774,21 +7783,21 @@ test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata, static int test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void) { - return test_AES_GCM_authenticated_encryption_SGL( + return test_authenticated_encryption_SGL( &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400); } static int test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void) { - return test_AES_GCM_authenticated_encryption_SGL( + return test_authenticated_encryption_SGL( &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000); } static int test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void) { - return test_AES_GCM_authenticated_encryption_SGL( + return test_authenticated_encryption_SGL( &gcm_test_case_8, OUT_OF_PLACE, 400, gcm_test_case_8.plaintext.len); } @@ -7797,7 +7806,7 @@ static int test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void) { - return test_AES_GCM_authenticated_encryption_SGL( + return test_authenticated_encryption_SGL( &gcm_test_case_SGL_1, IN_PLACE, 1500, 0); } diff --git a/test/test/test_cryptodev_gcm_test_vectors.h b/test/test/test_cryptodev_aead_test_vectors.h similarity index 97% rename from test/test/test_cryptodev_gcm_test_vectors.h rename to test/test/test_cryptodev_aead_test_vectors.h index 7879c35b45..e9f13dd7c2 100644 --- a/test/test/test_cryptodev_gcm_test_vectors.h +++ b/test/test/test_cryptodev_aead_test_vectors.h @@ -1,7 +1,7 @@ /*- * BSD LICENSE * - * Copyright(c) 2015 Intel Corporation. All rights reserved. + * Copyright(c) 2015-2017 Intel Corporation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -30,23 +30,25 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef TEST_CRYPTODEV_GCM_TEST_VECTORS_H_ -#define TEST_CRYPTODEV_GCM_TEST_VECTORS_H_ +#ifndef TEST_CRYPTODEV_AEAD_TEST_VECTORS_H_ +#define TEST_CRYPTODEV_AEAD_TEST_VECTORS_H_ #define GMAC_LARGE_PLAINTEXT_LENGTH 65344 -#define GCM_MAX_AAD_LENGTH 65536 +#define MAX_AAD_LENGTH 65536 #define GCM_LARGE_AAD_LENGTH 65296 -static uint8_t gcm_aad_zero_text[GCM_MAX_AAD_LENGTH] = { 0 }; +static uint8_t gcm_aad_zero_text[MAX_AAD_LENGTH] = { 0 }; -static uint8_t gcm_aad_text[GCM_MAX_AAD_LENGTH] = { +static uint8_t gcm_aad_text[MAX_AAD_LENGTH] = { 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0x00, 0xf1, 0xe2, 0xd3, 0xc4, 0xb5, 0xa6, 0x97, 0x88, 0x79, 0x6a, 0x5b, 0x4c, 0x3d, 0x2e, 0x1f }; -struct gcm_test_data { +struct aead_test_data { + enum rte_crypto_aead_algorithm algo; + struct { uint8_t data[64]; unsigned len; @@ -101,8 +103,9 @@ struct gmac_test_data { }; -/** AES-128 Test Vectors */ -static const struct gcm_test_data gcm_test_case_1 = { +/** AES-GCM-128 Test Vectors */ +static const struct aead_test_data gcm_test_case_1 = { + .algo = RTE_CRYPTO_AEAD_AES_GCM, .key = { .data = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -138,8 +141,8 @@ static const struct gcm_test_data gcm_test_case_1 = { } }; -/** AES-128 Test Vectors */ -static const struct gcm_test_data gcm_test_case_2 = { +static const struct aead_test_data gcm_test_case_2 = { + .algo = RTE_CRYPTO_AEAD_AES_GCM, .key = { .data = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -176,8 +179,8 @@ static const struct gcm_test_data gcm_test_case_2 = { } }; -/** AES-128 Test Vectors */ -static const struct gcm_test_data gcm_test_case_3 = { +static const struct aead_test_data gcm_test_case_3 = { + .algo = RTE_CRYPTO_AEAD_AES_GCM, .key = { .data = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, @@ -227,8 +230,8 @@ static const struct gcm_test_data gcm_test_case_3 = { } }; -/** AES-128 Test Vectors */ -static const struct gcm_test_data gcm_test_case_4 = { +static const struct aead_test_data gcm_test_case_4 = { + .algo = RTE_CRYPTO_AEAD_AES_GCM, .key = { .data = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, @@ -282,8 +285,8 @@ static const struct gcm_test_data gcm_test_case_4 = { }; -/** AES-128 Test Vectors */ -static const struct gcm_test_data gcm_test_case_5 = { +static const struct aead_test_data gcm_test_case_5 = { + .algo = RTE_CRYPTO_AEAD_AES_GCM, .key = { .data = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, @@ -337,8 +340,8 @@ static const struct gcm_test_data gcm_test_case_5 = { }; -/** AES-128 Test Vectors */ -static const struct gcm_test_data gcm_test_case_6 = { +static const struct aead_test_data gcm_test_case_6 = { + .algo = RTE_CRYPTO_AEAD_AES_GCM, .key = { .data = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, @@ -392,8 +395,8 @@ static const struct gcm_test_data gcm_test_case_6 = { } }; -/** AES-128 Test Vectors */ -static const struct gcm_test_data gcm_test_case_7 = { +static const struct aead_test_data gcm_test_case_7 = { + .algo = RTE_CRYPTO_AEAD_AES_GCM, .key = { .data = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, @@ -447,7 +450,8 @@ static const struct gcm_test_data gcm_test_case_7 = { } }; -static const struct gcm_test_data gcm_test_case_8 = { +static const struct aead_test_data gcm_test_case_8 = { + .algo = RTE_CRYPTO_AEAD_AES_GCM, .key = { .data = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, @@ -997,8 +1001,9 @@ static const struct gcm_test_data gcm_test_case_8 = { } }; -/** AES-192 Test Vectors */ -static const struct gcm_test_data gcm_test_case_192_1 = { +/** AES-GCM-192 Test Vectors */ +static const struct aead_test_data gcm_test_case_192_1 = { + .algo = RTE_CRYPTO_AEAD_AES_GCM, .key = { .data = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -1035,7 +1040,8 @@ static const struct gcm_test_data gcm_test_case_192_1 = { } }; -static const struct gcm_test_data gcm_test_case_192_2 = { +static const struct aead_test_data gcm_test_case_192_2 = { + .algo = RTE_CRYPTO_AEAD_AES_GCM, .key = { .data = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -1079,7 +1085,8 @@ static const struct gcm_test_data gcm_test_case_192_2 = { } }; -static const struct gcm_test_data gcm_test_case_192_3 = { +static const struct aead_test_data gcm_test_case_192_3 = { + .algo = RTE_CRYPTO_AEAD_AES_GCM, .key = { .data = { 0xFE, 0xFF, 0xE9, 0x92, 0x86, 0x65, 0x73, 0x1C, @@ -1134,7 +1141,8 @@ static const struct gcm_test_data gcm_test_case_192_3 = { } }; -static const struct gcm_test_data gcm_test_case_192_4 = { +static const struct aead_test_data gcm_test_case_192_4 = { + .algo = RTE_CRYPTO_AEAD_AES_GCM, .key = { .data = { 0xFE, 0xFF, 0xE9, 0x92, 0x86, 0x65, 0x73, 0x1C, @@ -1189,7 +1197,8 @@ static const struct gcm_test_data gcm_test_case_192_4 = { } }; -static const struct gcm_test_data gcm_test_case_192_5 = { +static const struct aead_test_data gcm_test_case_192_5 = { + .algo = RTE_CRYPTO_AEAD_AES_GCM, .key = { .data = { 0xFE, 0xFF, 0xE9, 0x92, 0x86, 0x65, 0x73, 0x1C, @@ -1244,7 +1253,8 @@ static const struct gcm_test_data gcm_test_case_192_5 = { } }; -static const struct gcm_test_data gcm_test_case_192_6 = { +static const struct aead_test_data gcm_test_case_192_6 = { + .algo = RTE_CRYPTO_AEAD_AES_GCM, .key = { .data = { 0xFE, 0xFF, 0xE9, 0x92, 0x86, 0x65, 0x73, 0x1C, @@ -1299,7 +1309,8 @@ static const struct gcm_test_data gcm_test_case_192_6 = { } }; -static const struct gcm_test_data gcm_test_case_192_7 = { +static const struct aead_test_data gcm_test_case_192_7 = { + .algo = RTE_CRYPTO_AEAD_AES_GCM, .key = { .data = { 0xFE, 0xFF, 0xE9, 0x92, 0x86, 0x65, 0x73, 0x1C, @@ -1354,8 +1365,9 @@ static const struct gcm_test_data gcm_test_case_192_7 = { } }; -/** AES-256 Test Vectors */ -static const struct gcm_test_data gcm_test_case_256_1 = { +/** AES-GCM-256 Test Vectors */ +static const struct aead_test_data gcm_test_case_256_1 = { + .algo = RTE_CRYPTO_AEAD_AES_GCM, .key = { .data = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -1390,8 +1402,8 @@ static const struct gcm_test_data gcm_test_case_256_1 = { } }; -/** AES-256 Test Vectors */ -static const struct gcm_test_data gcm_test_case_256_2 = { +static const struct aead_test_data gcm_test_case_256_2 = { + .algo = RTE_CRYPTO_AEAD_AES_GCM, .key = { .data = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -1430,8 +1442,8 @@ static const struct gcm_test_data gcm_test_case_256_2 = { } }; -/** AES-256 Test Vectors */ -static const struct gcm_test_data gcm_test_case_256_3 = { +static const struct aead_test_data gcm_test_case_256_3 = { + .algo = RTE_CRYPTO_AEAD_AES_GCM, .key = { .data = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, @@ -1482,8 +1494,8 @@ static const struct gcm_test_data gcm_test_case_256_3 = { } }; -/** AES-256 Test Vectors */ -static const struct gcm_test_data gcm_test_case_256_4 = { +static const struct aead_test_data gcm_test_case_256_4 = { + .algo = RTE_CRYPTO_AEAD_AES_GCM, .key = { .data = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, @@ -1535,8 +1547,8 @@ static const struct gcm_test_data gcm_test_case_256_4 = { }; -/** AES-256 Test Vectors */ -static const struct gcm_test_data gcm_test_case_256_5 = { +static const struct aead_test_data gcm_test_case_256_5 = { + .algo = RTE_CRYPTO_AEAD_AES_GCM, .key = { .data = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, @@ -1588,8 +1600,8 @@ static const struct gcm_test_data gcm_test_case_256_5 = { }; -/** AES-256 Test Vectors */ -static const struct gcm_test_data gcm_test_case_256_6 = { +static const struct aead_test_data gcm_test_case_256_6 = { + .algo = RTE_CRYPTO_AEAD_AES_GCM, .key = { .data = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, @@ -1640,8 +1652,8 @@ static const struct gcm_test_data gcm_test_case_256_6 = { } }; -/** AES-256 Test Vectors */ -static const struct gcm_test_data gcm_test_case_256_7 = { +static const struct aead_test_data gcm_test_case_256_7 = { + .algo = RTE_CRYPTO_AEAD_AES_GCM, .key = { .data = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, @@ -1692,8 +1704,9 @@ static const struct gcm_test_data gcm_test_case_256_7 = { } }; -/** variable AAD AES-128 Test Vectors */ -static const struct gcm_test_data gcm_test_case_aad_1 = { +/** variable AAD AES-GCM-128 Test Vectors */ +static const struct aead_test_data gcm_test_case_aad_1 = { + .algo = RTE_CRYPTO_AEAD_AES_GCM, .key = { .data = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, @@ -1744,8 +1757,9 @@ static const struct gcm_test_data gcm_test_case_aad_1 = { } }; -/** variable AAD AES-256 Test Vectors */ -static const struct gcm_test_data gcm_test_case_aad_2 = { +/** variable AAD AES-GCM-256 Test Vectors */ +static const struct aead_test_data gcm_test_case_aad_2 = { + .algo = RTE_CRYPTO_AEAD_AES_GCM, .key = { .data = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, @@ -2567,7 +2581,8 @@ static const struct gmac_test_data gmac_test_case_4 = { } }; -static const struct gcm_test_data gcm_test_case_SGL_1 = { +static const struct aead_test_data gcm_test_case_SGL_1 = { + .algo = RTE_CRYPTO_AEAD_AES_GCM, .key = { .data = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, @@ -3384,4 +3399,4 @@ static const struct gcm_test_data gcm_test_case_SGL_1 = { } }; -#endif /* TEST_CRYPTODEV_GCM_TEST_VECTORS_H_ */ +#endif /* TEST_CRYPTODEV_AEAD_TEST_VECTORS_H_ */