From patchwork Thu Sep 19 12:15:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Shamis X-Patchwork-Id: 59456 X-Patchwork-Delegate: gakhil@marvell.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 069731EF31; Thu, 19 Sep 2019 13:56:46 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id 3525B1ED22 for ; Thu, 19 Sep 2019 13:56:43 +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 x8JBu9Qa006990; Thu, 19 Sep 2019 04:56:42 -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=uoolYJqTZtYxJpF7r5DUAtSVLrJJOc4vBr3OFodIJkE=; b=difCoDIKRFgYP7JeKgo297K07oz5rSRiAnS35fHafkkDvfXWwDmjVYv2X03OEaIiHt0c iorltZVVTpI9dHkLx5/ILjPVvhmcXZW5crTC1aqAkU41oQioNLh7dUOSn2tyFpJl0kFb rvXYhF3YczCcUQf/gdJkXT3W2dctOVnAEFl5CjSQ9ISXtUhj/N9nTblLAoBIGW0uqiwn njrlUxI1YaiVl+BhIcanoPpVj2MvF7SyX5DW9cWOk35hLxTp2P7M+PENFxRtLykRPrYM A/xy/fGHoBHCtsBiYed7wY0zgwWaJ+SojyTp3462JZ+hKZnS7jkyOHtoHVc1vDZx35to Lg== Received: from sc-exch04.marvell.com ([199.233.58.184]) by mx0a-0016f401.pphosted.com with ESMTP id 2v3vcdtre4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 19 Sep 2019 04:56:42 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 19 Sep 2019 04:56:41 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 19 Sep 2019 04:56:41 -0700 Received: from vvenus375.il.marvell.com (unknown [10.5.120.75]) by maili.marvell.com (Postfix) with ESMTP id 8C2363F7041; Thu, 19 Sep 2019 04:56:39 -0700 (PDT) From: To: CC: , , , Date: Thu, 19 Sep 2019 15:15:08 +0300 Message-ID: <20190919121510.4911-2-michaelsh@marvell.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190919121510.4911-1-michaelsh@marvell.com> References: <20190826094120.22590-1-michaelsh@marvell.com> <20190919121510.4911-1-michaelsh@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.70,1.0.8 definitions=2019-09-19_04:2019-09-19,2019-09-19 signatures=0 Subject: [dpdk-dev] [PATCH v2 1/3] examples/fips_validation: added support for TDES ECB 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 --- examples/fips_validation/fips_validation.c | 1 + examples/fips_validation/fips_validation.h | 7 +++++ .../fips_validation/fips_validation_tdes.c | 7 +++++ examples/fips_validation/main.c | 27 ++++++++++++++++--- 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/examples/fips_validation/fips_validation.c b/examples/fips_validation/fips_validation.c index 8d43b267e..07ffa62e9 100644 --- a/examples/fips_validation/fips_validation.c +++ b/examples/fips_validation/fips_validation.c @@ -257,6 +257,7 @@ fips_test_init(const char *req_file_path, const char *rsp_file_path, fips_test_clear(); + strcpy(info.file_name, req_file_path); info.algo = FIPS_TEST_ALGO_MAX; if (parse_file_type(req_file_path) < 0) { RTE_LOG(ERR, USER1, "File %s type not supported\n", diff --git a/examples/fips_validation/fips_validation.h b/examples/fips_validation/fips_validation.h index b604db9ec..d487fb005 100644 --- a/examples/fips_validation/fips_validation.h +++ b/examples/fips_validation/fips_validation.h @@ -105,6 +105,11 @@ enum fips_tdes_test_types { TDES_MMT /* Multi block Message Test */ }; +enum fips_tdes_test_mode { + TDES_MODE_CBC = 0, + TDES_MODE_ECB +}; + enum fips_ccm_test_types { CCM_VADT = 1, /* Variable Associated Data Test */ CCM_VPT, /* Variable Payload Test */ @@ -130,6 +135,7 @@ struct hmac_interim_data { struct tdes_interim_data { enum fips_tdes_test_types test_type; + enum fips_tdes_test_mode test_mode; uint32_t nb_keys; }; @@ -156,6 +162,7 @@ struct fips_test_interim_info { char *vec[MAX_LINE_PER_VECTOR]; uint32_t nb_vec_lines; char device_name[MAX_STRING_SIZE]; + char file_name[MAX_STRING_SIZE]; union { struct aesavs_interim_data aes_data; diff --git a/examples/fips_validation/fips_validation_tdes.c b/examples/fips_validation/fips_validation_tdes.c index 15ee434e1..d7f4d58b0 100644 --- a/examples/fips_validation/fips_validation_tdes.c +++ b/examples/fips_validation/fips_validation_tdes.c @@ -12,6 +12,7 @@ #define NEW_LINE_STR "#" #define TEST_TYPE_KEY " for CBC" +#define TEST_TYPE_ECB_KEY " for ECB" #define TEST_CBCI_KEY " for CBCI" #define ENC_STR "[ENCRYPT]" @@ -250,6 +251,12 @@ parse_test_tdes_init(void) if (strstr(line, test_types[j].desc)) { info.interim_info.tdes_data.test_type = test_types[j].type; + if (strstr(line, TEST_TYPE_ECB_KEY)) + info.interim_info.tdes_data.test_mode = + TDES_MODE_ECB; + else + info.interim_info.tdes_data.test_mode = + TDES_MODE_CBC; break; } } diff --git a/examples/fips_validation/main.c b/examples/fips_validation/main.c index 813534068..7a379bc99 100644 --- a/examples/fips_validation/main.c +++ b/examples/fips_validation/main.c @@ -689,16 +689,24 @@ prepare_tdes_xform(struct rte_crypto_sym_xform *xform) xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER; - cipher_xform->algo = RTE_CRYPTO_CIPHER_3DES_CBC; + if (info.interim_info.tdes_data.test_mode == TDES_MODE_CBC) + cipher_xform->algo = RTE_CRYPTO_CIPHER_3DES_CBC; + else + cipher_xform->algo = RTE_CRYPTO_CIPHER_3DES_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_3DES_CBC; + if (cipher_xform->algo == RTE_CRYPTO_CIPHER_3DES_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); @@ -1387,6 +1395,17 @@ init_test_ops(void) test_ops.test = fips_generic_test; break; default: + if (strstr(info.file_name, "TECB") || + strstr(info.file_name, "TCBC")) { + info.algo = FIPS_TEST_ALGO_TDES; + test_ops.prepare_op = prepare_cipher_op; + test_ops.prepare_xform = prepare_tdes_xform; + if (info.interim_info.tdes_data.test_type == TDES_MCT) + test_ops.test = fips_mct_tdes_test; + else + test_ops.test = fips_generic_test; + break; + } return -1; } From patchwork Thu Sep 19 12:15:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Shamis X-Patchwork-Id: 59457 X-Patchwork-Delegate: gakhil@marvell.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 1F9B61EF6D; Thu, 19 Sep 2019 13:56:49 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 919881ED22 for ; Thu, 19 Sep 2019 13:56:45 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x8JBoiv5028444; Thu, 19 Sep 2019 04:56:45 -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=H8fhMhIAR0kyK88WIFQGBbyyH64kStBnwbkV27ycKNUnUYDFfyKgZ+/vdKoB2V4vakSv lwUac11B9pP49bLh2FFB1E/4wLIBW3Ksb+15V19RV01bH4C8dDecZ+NDMZqLgVw9YM4a TIiWKWUUO7VlTadv/PDpkwJh51G82ExZUMiqKox3d2Kjz6aq6ar1Jin7AsR3Gf+q0Ebo v19oZ2acBJExYtWaOZeifZdxxwAQGe4VyjsEzi3MhYTKojSCPvszRLjVoFAoqdT9EohO SVnnF6Tr+Jzn0r8DHryWD4teDvZxhc5c2OXSrkzzwAM5BqvP3BSfvHSfCiGwCI/XUtIE FA== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0b-0016f401.pphosted.com with ESMTP id 2v3vcfjnfj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 19 Sep 2019 04:56:45 -0700 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 19 Sep 2019 04:56:43 -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; Thu, 19 Sep 2019 04:56:43 -0700 Received: from vvenus375.il.marvell.com (unknown [10.5.120.75]) by maili.marvell.com (Postfix) with ESMTP id 606A13F7043; Thu, 19 Sep 2019 04:56:41 -0700 (PDT) From: To: CC: , , , Date: Thu, 19 Sep 2019 15:15:09 +0300 Message-ID: <20190919121510.4911-3-michaelsh@marvell.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190919121510.4911-1-michaelsh@marvell.com> References: <20190826094120.22590-1-michaelsh@marvell.com> <20190919121510.4911-1-michaelsh@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.70,1.0.8 definitions=2019-09-19_04:2019-09-19,2019-09-19 signatures=0 Subject: [dpdk-dev] [PATCH v2 2/3] examples/fips_validation: added support AES ECB 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); From patchwork Thu Sep 19 12:15:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Shamis X-Patchwork-Id: 59458 X-Patchwork-Delegate: gakhil@marvell.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 7D1581EFA5; Thu, 19 Sep 2019 13:56:51 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 875581EF80 for ; Thu, 19 Sep 2019 13:56:47 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x8JBoiv6028444; Thu, 19 Sep 2019 04:56:47 -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=fStioubPl6iiidXGoZ/AIsG0X6VqkZUwqs26PkHxMVs=; b=LMMEunosgnF6haKUAyWNt0CG4NIfDsfp2cTqJ+9bR48V847rpaQzhqCD2X3j559wclkt Hmg99ZxYlfsKUZtY1Usz5I4n9vW0jF/TOnuu5xFV+bzzdWoBsfAgcQgoH9Bdx0lfnMtd G4eZPrnXjYZspgRINinJ/IaHVZ7dLuJf468HMszbM/tE3T7YoXzv4+wbGNE58r3HOTBg 3etGVyMP6mAt98XtrwM5B5bflAISf38/dQO59YBbZEs/DIcb0ROwKEKHVIZV8T0B50gj cnvrq8XQ/+bWIXDYLrJUZ9tz4xeiCgv7Ek3TbX8ydcXtn0GVhOWEVB15MCdGnYpNwPY/ Vg== Received: from sc-exch04.marvell.com ([199.233.58.184]) by mx0b-0016f401.pphosted.com with ESMTP id 2v3vcfjnfr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 19 Sep 2019 04:56:46 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 19 Sep 2019 04:56:45 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 19 Sep 2019 04:56:45 -0700 Received: from vvenus375.il.marvell.com (unknown [10.5.120.75]) by maili.marvell.com (Postfix) with ESMTP id 7A0993F7041; Thu, 19 Sep 2019 04:56:43 -0700 (PDT) From: To: CC: , , , Date: Thu, 19 Sep 2019 15:15:10 +0300 Message-ID: <20190919121510.4911-4-michaelsh@marvell.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190919121510.4911-1-michaelsh@marvell.com> References: <20190826094120.22590-1-michaelsh@marvell.com> <20190919121510.4911-1-michaelsh@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.70,1.0.8 definitions=2019-09-19_04:2019-09-19,2019-09-19 signatures=0 Subject: [dpdk-dev] [PATCH v2 3/3] examples/fips_validation: separated init for TDES ECB and CBC 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 TDES: IV, PT and CT are initiated according to ECB or CBC cipher mode now Signed-off-by: Michael Shamis --- examples/fips_validation/main.c | 66 +++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 16 deletions(-) diff --git a/examples/fips_validation/main.c b/examples/fips_validation/main.c index c83763b13..f8694ef96 100644 --- a/examples/fips_validation/main.c +++ b/examples/fips_validation/main.c @@ -1053,6 +1053,7 @@ fips_mct_tdes_test(void) uint8_t prev_in[TDES_BLOCK_SIZE] = {0}; uint32_t i, j, k; int ret; + int test_mode = info.interim_info.tdes_data.test_mode; for (i = 0; i < TDES_EXTERN_ITER; i++) { if (i != 0) @@ -1079,25 +1080,50 @@ fips_mct_tdes_test(void) memcpy(prev_out, val.val, TDES_BLOCK_SIZE); if (info.op == FIPS_TEST_ENC_AUTH_GEN) { - memcpy(vec.pt.val, vec.iv.val, - TDES_BLOCK_SIZE); - memcpy(vec.iv.val, val.val, - TDES_BLOCK_SIZE); + if (test_mode == TDES_MODE_ECB) { + memcpy(vec.pt.val, val.val, + TDES_BLOCK_SIZE); + } else { + memcpy(vec.pt.val, vec.iv.val, + TDES_BLOCK_SIZE); + memcpy(vec.iv.val, val.val, + TDES_BLOCK_SIZE); + } + } else { - memcpy(vec.iv.val, vec.ct.val, - TDES_BLOCK_SIZE); - memcpy(vec.ct.val, val.val, - TDES_BLOCK_SIZE); + if (test_mode == TDES_MODE_ECB) { + memcpy(vec.ct.val, val.val, + TDES_BLOCK_SIZE); + } else { + memcpy(vec.iv.val, vec.ct.val, + TDES_BLOCK_SIZE); + memcpy(vec.ct.val, val.val, + TDES_BLOCK_SIZE); + } } continue; } if (info.op == FIPS_TEST_ENC_AUTH_GEN) { - memcpy(vec.iv.val, val.val, TDES_BLOCK_SIZE); - memcpy(vec.pt.val, prev_out, TDES_BLOCK_SIZE); + if (test_mode == TDES_MODE_ECB) { + memcpy(vec.pt.val, val.val, + TDES_BLOCK_SIZE); + } else { + memcpy(vec.iv.val, val.val, + TDES_BLOCK_SIZE); + memcpy(vec.pt.val, prev_out, + TDES_BLOCK_SIZE); + } } else { - memcpy(vec.iv.val, vec.ct.val, TDES_BLOCK_SIZE); - memcpy(vec.ct.val, val.val, TDES_BLOCK_SIZE); + if (test_mode == TDES_MODE_ECB) { + memcpy(vec.ct.val, val.val, + TDES_BLOCK_SIZE); + } else { + memcpy(vec.iv.val, vec.ct.val, + TDES_BLOCK_SIZE); + memcpy(vec.ct.val, val.val, + TDES_BLOCK_SIZE); + } } if (j == TDES_INTERN_ITER - 1) @@ -1156,11 +1182,19 @@ fips_mct_tdes_test(void) val_key.val[k] : (val_key.val[k] ^ 0x1); if (info.op == FIPS_TEST_ENC_AUTH_GEN) { - memcpy(vec.iv.val, val.val, TDES_BLOCK_SIZE); - memcpy(vec.pt.val, prev_out, TDES_BLOCK_SIZE); + if (test_mode == TDES_MODE_ECB) { + memcpy(vec.pt.val, val.val, TDES_BLOCK_SIZE); + } else { + memcpy(vec.iv.val, val.val, TDES_BLOCK_SIZE); + memcpy(vec.pt.val, prev_out, TDES_BLOCK_SIZE); + } } else { - memcpy(vec.iv.val, prev_out, TDES_BLOCK_SIZE); - memcpy(vec.ct.val, val.val, TDES_BLOCK_SIZE); + if (test_mode == TDES_MODE_ECB) { + memcpy(vec.ct.val, val.val, TDES_BLOCK_SIZE); + } else { + memcpy(vec.iv.val, prev_out, TDES_BLOCK_SIZE); + memcpy(vec.ct.val, val.val, TDES_BLOCK_SIZE); + } } }