From patchwork Thu Sep 21 13:11:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "De Lara Guarch, Pablo" X-Patchwork-Id: 29080 X-Patchwork-Delegate: pablo.de.lara.guarch@intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 951E51B159; Thu, 21 Sep 2017 23:12:05 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id D4D411B1C1 for ; Thu, 21 Sep 2017 23:12:00 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Sep 2017 14:12:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,426,1500966000"; d="scan'208";a="902703330" Received: from silpixa00399464.ir.intel.com (HELO silpixa00399464.ger.corp.intel.com) ([10.237.222.157]) by FMSMGA003.fm.intel.com with ESMTP; 21 Sep 2017 14:11:58 -0700 From: Pablo de Lara To: declan.doherty@intel.com, fiona.trahe@intel.com, deepak.k.jain@intel.com, john.griffin@intel.com Cc: dev@dpdk.org, Pablo de Lara Date: Thu, 21 Sep 2017 14:11:21 +0100 Message-Id: <20170921131123.16513-9-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170921131123.16513-1-pablo.de.lara.guarch@intel.com> References: <20170818080728.43248-1-pablo.de.lara.guarch@intel.com> <20170921131123.16513-1-pablo.de.lara.guarch@intel.com> Subject: [dpdk-dev] [PATCH v2 8/9] test/crypto: rename GCM test code X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Before adding AES-CCM tests, some test code used for AES-GCM can be renamed, so it can be reused for AES-CCM, as both need similar parameters. Signed-off-by: Pablo de Lara --- test/test/test_cryptodev.c | 245 +++++++++++---------- ...ectors.h => test_cryptodev_aead_test_vectors.h} | 115 +++++----- test/test/test_cryptodev_perf.c | 2 +- 3 files changed, 193 insertions(+), 169 deletions(-) rename test/test/{test_cryptodev_gcm_test_vectors.h => test_cryptodev_aead_test_vectors.h} (97%) diff --git a/test/test/test_cryptodev.c b/test/test/test_cryptodev.c index a4116c6..0b7ca47 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; @@ -4785,10 +4785,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) @@ -4803,7 +4804,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; @@ -4827,7 +4828,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, @@ -4841,7 +4843,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; @@ -4856,8 +4858,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; @@ -4976,7 +4978,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; @@ -4986,8 +4988,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, @@ -4998,7 +5001,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); @@ -5007,8 +5010,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; @@ -5045,13 +5048,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; @@ -5060,143 +5063,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; @@ -5205,8 +5208,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, @@ -5218,7 +5222,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); @@ -5226,8 +5230,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; @@ -5257,154 +5261,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; @@ -5413,8 +5417,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, @@ -5431,8 +5436,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; @@ -5462,13 +5467,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; @@ -5477,11 +5482,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; @@ -5489,8 +5494,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, @@ -5507,8 +5513,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; @@ -5534,23 +5540,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; @@ -5566,14 +5572,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, @@ -5610,13 +5617,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; @@ -5625,13 +5632,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; @@ -5646,14 +5653,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, @@ -5686,18 +5694,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); } @@ -7406,8 +7414,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; @@ -7468,7 +7476,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; @@ -7513,8 +7521,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, @@ -7643,8 +7652,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) @@ -7678,7 +7687,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) @@ -7695,7 +7704,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; @@ -7706,7 +7715,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; } @@ -7717,21 +7726,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); } @@ -7740,7 +7749,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 7879c35..e9f13dd 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_ */ diff --git a/test/test/test_cryptodev_perf.c b/test/test/test_cryptodev_perf.c index 3b57e6d..5e35c28 100644 --- a/test/test/test_cryptodev_perf.c +++ b/test/test/test_cryptodev_perf.c @@ -41,7 +41,7 @@ #include "test.h" #include "test_cryptodev.h" -#include "test_cryptodev_gcm_test_vectors.h" +#include "test_cryptodev_aead_test_vectors.h" #define AES_CIPHER_IV_LENGTH 16 #define TRIPLE_DES_CIPHER_IV_LENGTH 8