From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4D1B8A2F6B for ; Tue, 8 Oct 2019 14:52:44 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1BE3B1C1F8; Tue, 8 Oct 2019 14:52:40 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id B66D91BEB3 for ; Tue, 8 Oct 2019 14:52:36 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Oct 2019 05:52:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,270,1566889200"; d="scan'208";a="206629513" Received: from adamdybx-mobl.ger.corp.intel.com (HELO addy-VirtualBox.isw.intel.com) ([10.103.104.111]) by fmsmga001.fm.intel.com with ESMTP; 08 Oct 2019 05:52:34 -0700 From: Adam Dybkowski To: dev@dpdk.org, fiona.trahe@intel.com, arkadiuszx.kusztal@intel.com, akhil.goyal@nxp.com Cc: Adam Dybkowski Date: Tue, 8 Oct 2019 14:44:31 +0200 Message-Id: <20191008124433.22304-2-adamx.dybkowski@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191008124433.22304-1-adamx.dybkowski@intel.com> References: <20190927154739.26404-1-adamx.dybkowski@intel.com> <20191008124433.22304-1-adamx.dybkowski@intel.com> Subject: [dpdk-dev] [PATCH v3 1/3] test/crypto: add more AES GCM tests for QAT PMD 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" This patch adds 256-bit AES GCM tests for QAT PMD (which already existed for AESNI and OpenSSL) and also adds a number of negative unit tests for AES GCM for QAT PMD, in order to verify authenticated encryption and decryption with modified data. Signed-off-by: Adam Dybkowski --- app/test/test_cryptodev.c | 226 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 226 insertions(+) diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index 63cfa1af1..ffed298fd 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -7675,6 +7675,12 @@ test_AES_GCM_authenticated_encryption_test_case_7(void) return test_authenticated_encryption(&gcm_test_case_7); } +static int +test_AES_GCM_authenticated_encryption_test_case_8(void) +{ + return test_authenticated_encryption(&gcm_test_case_8); +} + static int test_AES_GCM_auth_encryption_test_case_192_1(void) { @@ -7771,6 +7777,93 @@ test_AES_GCM_auth_encryption_test_case_aad_2(void) return test_authenticated_encryption(&gcm_test_case_aad_2); } +static int +test_AES_GCM_auth_encryption_fail_iv_corrupt(void) +{ + struct aead_test_data tdata; + int res; + + RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n"); + memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data)); + tdata.iv.data[0] += 1; + res = test_authenticated_encryption(&tdata); + TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed"); + return TEST_SUCCESS; +} + +static int +test_AES_GCM_auth_encryption_fail_in_data_corrupt(void) +{ + struct aead_test_data tdata; + int res; + + RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n"); + memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data)); + tdata.plaintext.data[0] += 1; + res = test_authenticated_encryption(&tdata); + TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed"); + return TEST_SUCCESS; +} + +static int +test_AES_GCM_auth_encryption_fail_out_data_corrupt(void) +{ + struct aead_test_data tdata; + int res; + + RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n"); + memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data)); + tdata.ciphertext.data[0] += 1; + res = test_authenticated_encryption(&tdata); + TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed"); + return TEST_SUCCESS; +} + +static int +test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void) +{ + struct aead_test_data tdata; + int res; + + RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n"); + memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data)); + tdata.aad.len += 1; + res = test_authenticated_encryption(&tdata); + TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed"); + return TEST_SUCCESS; +} + +static int +test_AES_GCM_auth_encryption_fail_aad_corrupt(void) +{ + struct aead_test_data tdata; + uint8_t aad[gcm_test_case_7.aad.len]; + int res; + + RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n"); + memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data)); + memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len); + aad[0] += 1; + tdata.aad.data = aad; + res = test_authenticated_encryption(&tdata); + TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed"); + return TEST_SUCCESS; +} + +static int +test_AES_GCM_auth_encryption_fail_tag_corrupt(void) +{ + struct aead_test_data tdata; + int res; + + RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n"); + memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data)); + tdata.auth_tag.data[0] += 1; + res = test_authenticated_encryption(&tdata); + TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed"); + return TEST_SUCCESS; +} + static int test_authenticated_decryption(const struct aead_test_data *tdata) { @@ -7839,6 +7932,7 @@ test_authenticated_decryption(const struct aead_test_data *tdata) TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS, "Authentication failed"); + return 0; } @@ -7884,6 +7978,12 @@ test_AES_GCM_authenticated_decryption_test_case_7(void) return test_authenticated_decryption(&gcm_test_case_7); } +static int +test_AES_GCM_authenticated_decryption_test_case_8(void) +{ + return test_authenticated_decryption(&gcm_test_case_8); +} + static int test_AES_GCM_auth_decryption_test_case_192_1(void) { @@ -7980,6 +8080,88 @@ test_AES_GCM_auth_decryption_test_case_aad_2(void) return test_authenticated_decryption(&gcm_test_case_aad_2); } +static int +test_AES_GCM_auth_decryption_fail_iv_corrupt(void) +{ + struct aead_test_data tdata; + int res; + + memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data)); + tdata.iv.data[0] += 1; + res = test_authenticated_decryption(&tdata); + TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed"); + return TEST_SUCCESS; +} + +static int +test_AES_GCM_auth_decryption_fail_in_data_corrupt(void) +{ + struct aead_test_data tdata; + int res; + + RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n"); + memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data)); + tdata.plaintext.data[0] += 1; + res = test_authenticated_decryption(&tdata); + TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed"); + return TEST_SUCCESS; +} + +static int +test_AES_GCM_auth_decryption_fail_out_data_corrupt(void) +{ + struct aead_test_data tdata; + int res; + + memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data)); + tdata.ciphertext.data[0] += 1; + res = test_authenticated_decryption(&tdata); + TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed"); + return TEST_SUCCESS; +} + +static int +test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void) +{ + struct aead_test_data tdata; + int res; + + memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data)); + tdata.aad.len += 1; + res = test_authenticated_decryption(&tdata); + TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed"); + return TEST_SUCCESS; +} + +static int +test_AES_GCM_auth_decryption_fail_aad_corrupt(void) +{ + struct aead_test_data tdata; + uint8_t aad[gcm_test_case_7.aad.len]; + int res; + + memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data)); + memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len); + aad[0] += 1; + tdata.aad.data = aad; + res = test_authenticated_decryption(&tdata); + TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed"); + return TEST_SUCCESS; +} + +static int +test_AES_GCM_auth_decryption_fail_tag_corrupt(void) +{ + struct aead_test_data tdata; + int res; + + memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data)); + tdata.auth_tag.data[0] += 1; + res = test_authenticated_decryption(&tdata); + TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed"); + return TEST_SUCCESS; +} + static int test_authenticated_encryption_oop(const struct aead_test_data *tdata) { @@ -10927,6 +11109,8 @@ static struct unit_test_suite cryptodev_qat_testsuite = { test_AES_GCM_authenticated_encryption_test_case_6), TEST_CASE_ST(ut_setup, ut_teardown, test_AES_GCM_authenticated_encryption_test_case_7), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_GCM_authenticated_encryption_test_case_8), /** AES GCM Authenticated Decryption */ TEST_CASE_ST(ut_setup, ut_teardown, @@ -10943,6 +11127,8 @@ static struct unit_test_suite cryptodev_qat_testsuite = { test_AES_GCM_authenticated_decryption_test_case_6), TEST_CASE_ST(ut_setup, ut_teardown, test_AES_GCM_authenticated_decryption_test_case_7), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_GCM_authenticated_decryption_test_case_8), /** AES GCM Authenticated Encryption 192 bits key */ TEST_CASE_ST(ut_setup, ut_teardown, @@ -10992,6 +11178,22 @@ static struct unit_test_suite cryptodev_qat_testsuite = { TEST_CASE_ST(ut_setup, ut_teardown, test_AES_GCM_auth_encryption_test_case_256_7), + /** AES GCM Authenticated Decryption 256 bits key */ + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_GCM_auth_decryption_test_case_256_1), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_GCM_auth_decryption_test_case_256_2), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_GCM_auth_decryption_test_case_256_3), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_GCM_auth_decryption_test_case_256_4), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_GCM_auth_decryption_test_case_256_5), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_GCM_auth_decryption_test_case_256_6), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_GCM_auth_decryption_test_case_256_7), + /** AES GMAC Authentication */ TEST_CASE_ST(ut_setup, ut_teardown, test_AES_GMAC_authentication_test_case_1), @@ -11214,6 +11416,30 @@ static struct unit_test_suite cryptodev_qat_testsuite = { authentication_verify_HMAC_SHA1_fail_data_corrupt), TEST_CASE_ST(ut_setup, ut_teardown, authentication_verify_HMAC_SHA1_fail_tag_corrupt), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_GCM_auth_encryption_fail_iv_corrupt), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_GCM_auth_encryption_fail_in_data_corrupt), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_GCM_auth_encryption_fail_out_data_corrupt), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_GCM_auth_encryption_fail_aad_len_corrupt), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_GCM_auth_encryption_fail_aad_corrupt), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_GCM_auth_encryption_fail_tag_corrupt), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_GCM_auth_decryption_fail_iv_corrupt), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_GCM_auth_decryption_fail_in_data_corrupt), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_GCM_auth_decryption_fail_out_data_corrupt), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_GCM_auth_decryption_fail_aad_len_corrupt), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_GCM_auth_decryption_fail_aad_corrupt), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_GCM_auth_decryption_fail_tag_corrupt), TEST_CASE_ST(ut_setup, ut_teardown, authentication_verify_AES128_GMAC_fail_data_corrupt), TEST_CASE_ST(ut_setup, ut_teardown, -- 2.17.1