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 C78CDA2EDB for ; Tue, 1 Oct 2019 12:14:29 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E28341B948; Tue, 1 Oct 2019 12:14:18 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id C95CD4C90 for ; Tue, 1 Oct 2019 12:14:14 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x91A5ZlZ010370; Tue, 1 Oct 2019 03:14:14 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0818; bh=rbERtIoCXVuSUbU8pwmPZXozXhVl8fztFcmngtguwow=; b=iq8k2gSY+dRGl//EpklngfsAY3wEll4YMGhqt9Bn1MNFKldjs19LuhKGPYma3k2QVcnv TRHy4HUGx2ItywRdHQwlXqf6jGoJHoVerpCeRlo1qRztuLso3Y7c0/TfU84518eF8kI0 TrvMs/q+lCUbmNAw3ftu682C3+NfT8utEeRBoAl4pOw5+uUUe8aJpCmNDhXIOli7xsnH olMZL9CltUdKZKz3z+b2fG0Uh/6jXPRA51jbczIbxXxDjJmWs8uLjG1b+G7Pc6GDsQ1K 3TmSIdmi4UqfBvZUfr1BThlNZoVvAHrYXIRJrEKi2/aQZuStkRIM0bIYreESSR+MsxuK BQ== Received: from sc-exch04.marvell.com ([199.233.58.184]) by mx0a-0016f401.pphosted.com with ESMTP id 2vbur19ncv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 01 Oct 2019 03:14:13 -0700 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 1 Oct 2019 03:14:12 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Tue, 1 Oct 2019 03:14:12 -0700 Received: from vvenus375.il.marvell.com (unknown [10.5.120.75]) by maili.marvell.com (Postfix) with ESMTP id 312813F7043; Tue, 1 Oct 2019 03:14:10 -0700 (PDT) From: To: CC: , , , Date: Tue, 1 Oct 2019 13:32:45 +0300 Message-ID: <20191001103246.29830-3-michaelsh@marvell.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191001103246.29830-1-michaelsh@marvell.com> References: <20190826094120.22590-1-michaelsh@marvell.com> <20191001103246.29830-1-michaelsh@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-10-01_05:2019-10-01,2019-10-01 signatures=0 Subject: [dpdk-dev] [PATCH v3 2/3] examples/fips_validation: add AES ECB support 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" From: Michael Shamis Signed-off-by: Michael Shamis --- .../fips_validation/fips_validation_aes.c | 1 + examples/fips_validation/main.c | 96 +++++++++++++++++-- 2 files changed, 91 insertions(+), 6 deletions(-) diff --git a/examples/fips_validation/fips_validation_aes.c b/examples/fips_validation/fips_validation_aes.c index 8cbc158eb..010a82627 100644 --- a/examples/fips_validation/fips_validation_aes.c +++ b/examples/fips_validation/fips_validation_aes.c @@ -44,6 +44,7 @@ struct aes_test_algo { enum rte_crypto_cipher_algorithm algo; } const algo_con[] = { {"CBC", RTE_CRYPTO_CIPHER_AES_CBC}, + {"ECB", RTE_CRYPTO_CIPHER_AES_ECB}, }; static int diff --git a/examples/fips_validation/main.c b/examples/fips_validation/main.c index 7a379bc99..c83763b13 100644 --- a/examples/fips_validation/main.c +++ b/examples/fips_validation/main.c @@ -649,16 +649,24 @@ prepare_aes_xform(struct rte_crypto_sym_xform *xform) xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER; - cipher_xform->algo = RTE_CRYPTO_CIPHER_AES_CBC; + if (info.interim_info.aes_data.cipher_algo == RTE_CRYPTO_CIPHER_AES_CBC) + cipher_xform->algo = RTE_CRYPTO_CIPHER_AES_CBC; + else + cipher_xform->algo = RTE_CRYPTO_CIPHER_AES_ECB; + cipher_xform->op = (info.op == FIPS_TEST_ENC_AUTH_GEN) ? RTE_CRYPTO_CIPHER_OP_ENCRYPT : RTE_CRYPTO_CIPHER_OP_DECRYPT; cipher_xform->key.data = vec.cipher_auth.key.val; cipher_xform->key.length = vec.cipher_auth.key.len; - cipher_xform->iv.length = vec.iv.len; - cipher_xform->iv.offset = IV_OFF; - - cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC; + if (cipher_xform->algo == RTE_CRYPTO_CIPHER_AES_CBC) { + cipher_xform->iv.length = vec.iv.len; + cipher_xform->iv.offset = IV_OFF; + } else { + cipher_xform->iv.length = 0; + cipher_xform->iv.offset = 0; + } + cap_idx.algo.cipher = cipher_xform->algo; cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER; cap = rte_cryptodev_sym_capability_get(env.dev_id, &cap_idx); @@ -1059,7 +1067,6 @@ fips_mct_tdes_test(void) fprintf(info.fp_wr, "Bypass\n"); return 0; } - return ret; } @@ -1160,6 +1167,80 @@ fips_mct_tdes_test(void) return 0; } +static int +fips_mct_aes_ecb_test(void) +{ +#define AES_BLOCK_SIZE 16 +#define AES_EXTERN_ITER 100 +#define AES_INTERN_ITER 1000 + struct fips_val val, val_key; + uint8_t prev_out[AES_BLOCK_SIZE] = {0}; + uint32_t i, j, k; + int ret; + + for (i = 0; i < AES_EXTERN_ITER; i++) { + if (i != 0) + update_info_vec(i); + + fips_test_write_one_case(); + + for (j = 0; j < AES_INTERN_ITER; j++) { + ret = fips_run_test(); + if (ret < 0) { + if (ret == -EPERM) { + fprintf(info.fp_wr, "Bypass\n"); + return 0; + } + + return ret; + } + + get_writeback_data(&val); + + if (info.op == FIPS_TEST_ENC_AUTH_GEN) + memcpy(vec.pt.val, val.val, AES_BLOCK_SIZE); + else + memcpy(vec.ct.val, val.val, AES_BLOCK_SIZE); + + if (j == AES_INTERN_ITER - 1) + continue; + + memcpy(prev_out, val.val, AES_BLOCK_SIZE); + } + + info.parse_writeback(&val); + fprintf(info.fp_wr, "\n"); + + if (i == AES_EXTERN_ITER - 1) + continue; + + /** update key */ + memcpy(&val_key, &vec.cipher_auth.key, sizeof(val_key)); + for (k = 0; k < vec.cipher_auth.key.len; k++) { + switch (vec.cipher_auth.key.len) { + case 16: + val_key.val[k] ^= val.val[k]; + break; + case 24: + if (k < 8) + val_key.val[k] ^= prev_out[k + 8]; + else + val_key.val[k] ^= val.val[k - 8]; + break; + case 32: + if (k < 16) + val_key.val[k] ^= prev_out[k]; + else + val_key.val[k] ^= val.val[k - 16]; + break; + default: + return -1; + } + } + } + + return 0; +} static int fips_mct_aes_test(void) { @@ -1172,6 +1253,9 @@ fips_mct_aes_test(void) uint32_t i, j, k; int ret; + if (info.interim_info.aes_data.cipher_algo == RTE_CRYPTO_CIPHER_AES_ECB) + return fips_mct_aes_ecb_test(); + for (i = 0; i < AES_EXTERN_ITER; i++) { if (i != 0) update_info_vec(i); -- 2.23.0