get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/46073/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 46073,
    "url": "http://patches.dpdk.org/api/patches/46073/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20181004131249.26726-5-roy.fan.zhang@intel.com/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20181004131249.26726-5-roy.fan.zhang@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20181004131249.26726-5-roy.fan.zhang@intel.com",
    "date": "2018-10-04T13:12:45",
    "name": "[v3,4/8] examples: add TDES parser and enablement for test types",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "91f47a9c7db064f3367dc8dbe57243081752c2ba",
    "submitter": {
        "id": 304,
        "url": "http://patches.dpdk.org/api/people/304/?format=api",
        "name": "Fan Zhang",
        "email": "roy.fan.zhang@intel.com"
    },
    "delegate": {
        "id": 6690,
        "url": "http://patches.dpdk.org/api/users/6690/?format=api",
        "username": "akhil",
        "first_name": "akhil",
        "last_name": "goyal",
        "email": "gakhil@marvell.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20181004131249.26726-5-roy.fan.zhang@intel.com/mbox/",
    "series": [
        {
            "id": 1692,
            "url": "http://patches.dpdk.org/api/series/1692/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1692",
            "date": "2018-10-04T13:12:41",
            "name": "FIPS validation capability",
            "version": 3,
            "mbox": "http://patches.dpdk.org/series/1692/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/46073/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/46073/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 9494C1B43A;\n\tThu,  4 Oct 2018 15:28:23 +0200 (CEST)",
            "from mga03.intel.com (mga03.intel.com [134.134.136.65])\n\tby dpdk.org (Postfix) with ESMTP id 5FFC75699\n\tfor <dev@dpdk.org>; Thu,  4 Oct 2018 15:28:11 +0200 (CEST)",
            "from orsmga003.jf.intel.com ([10.7.209.27])\n\tby orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t04 Oct 2018 06:28:09 -0700",
            "from silpixa00398673.ir.intel.com (HELO\n\tsilpixa00398673.ger.corp.intel.com) ([10.237.223.54])\n\tby orsmga003.jf.intel.com with ESMTP; 04 Oct 2018 06:27:50 -0700"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.54,338,1534834800\"; d=\"scan'208\";a=\"89141186\"",
        "From": "Fan Zhang <roy.fan.zhang@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "akhil.goyal@nxp.com,\n\tMarko Kovacevic <marko.kovacevic@intel.com>",
        "Date": "Thu,  4 Oct 2018 14:12:45 +0100",
        "Message-Id": "<20181004131249.26726-5-roy.fan.zhang@intel.com>",
        "X-Mailer": "git-send-email 2.13.6",
        "In-Reply-To": "<20181004131249.26726-1-roy.fan.zhang@intel.com>",
        "References": "<20181004094015.46264-1-roy.fan.zhang@intel.com>\n\t<20181004131249.26726-1-roy.fan.zhang@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v3 4/8] examples: add TDES parser and enablement\n\tfor test types",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "From: Marko Kovacevic <marko.kovacevic@intel.com>\n\nAdded enablement for TDES parser, to allow the\napplication to parser the TDES request files and to validate all\ntest types supported.\n\nSigned-off-by: Marko Kovacevic <marko.kovacevic@intel.com>\nSigned-off-by: Fan Zhang <roy.fan.zhang@intel.com>\n---\n examples/cryptodev_fips_validate/Makefile          |   1 +\n .../cryptodev_fips_parse_3des.c                    | 259 +++++++++++++++++++++\n .../cryptodev_fips_parse_aes.c                     |   2 +\n .../cryptodev_fips_parse_validate.c                |   5 +\n .../cryptodev_fips_validate.h                      |  21 ++\n examples/cryptodev_fips_validate/main.c            | 175 ++++++++++++++\n examples/cryptodev_fips_validate/meson.build       |   1 +\n 7 files changed, 464 insertions(+)\n create mode 100644 examples/cryptodev_fips_validate/cryptodev_fips_parse_3des.c",
    "diff": "diff --git a/examples/cryptodev_fips_validate/Makefile b/examples/cryptodev_fips_validate/Makefile\nindex 50be23cf5..54ea43ffd 100644\n--- a/examples/cryptodev_fips_validate/Makefile\n+++ b/examples/cryptodev_fips_validate/Makefile\n@@ -7,6 +7,7 @@ APP = cryptodev_fips_validate_app\n # all source are stored in SRCS-y\n SRCS-y := cryptodev_fips_parse_aes.c\n SRCS-y += cryptodev_fips_parse_hmac.c\n+SRCS-y += cryptodev_fips_parse_3des.c\n SRCS-y += cryptodev_fips_parse_validate.c\n SRCS-y += main.c\n \ndiff --git a/examples/cryptodev_fips_validate/cryptodev_fips_parse_3des.c b/examples/cryptodev_fips_validate/cryptodev_fips_parse_3des.c\nnew file mode 100644\nindex 000000000..82e9132a7\n--- /dev/null\n+++ b/examples/cryptodev_fips_validate/cryptodev_fips_parse_3des.c\n@@ -0,0 +1,259 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2018 Intel Corporation\n+ */\n+\n+#include <string.h>\n+#include <stdio.h>\n+\n+#include <rte_malloc.h>\n+#include <rte_cryptodev.h>\n+\n+#include \"cryptodev_fips_validate.h\"\n+\n+#define NEW_LINE_STR\t\"#\"\n+#define TEST_TYPE_KEY\t\" for CBC\"\n+#define TEST_CBCI_KEY\t\" for CBCI\"\n+\n+#define ENC_STR\t\t\"[ENCRYPT]\"\n+#define DEC_STR\t\t\"[DECRYPT]\"\n+\n+#define COUNT_STR\t\"COUNT = \"\n+#define KEY1_STR\t\"KEY1 = \"\n+#define KEY2_STR\t\"KEY2 = \"\n+#define KEY3_STR\t\"KEY3 = \"\n+\n+#define KEYS_STR\t\"KEYs = \"\n+#define IV_STR\t\t\"IV = \"\n+#define PT_STR\t\t\"PLAINTEXT = \"\n+#define CT_STR\t\t\"CIPHERTEXT = \"\n+#define NK_STR\t\t\"NumKeys = \"\n+\n+#define SET_STR\t\t\" = \"\n+\n+#define PLAIN_TEXT\t0\n+#define CIPHER_TEXT\t1\n+#define KEY_TEXT\t2\n+#define IV_TEXT\t\t3\n+\n+#define DEVICE_STR\t\"# Config Info for : \"\n+\n+struct {\n+\tuint32_t type;\n+\tconst char *desc;\n+} test_types[] = {\n+\t\t{TDES_INVERSE_PERMUTATION, \"INVERSE PERMUTATION\"},\n+\t\t{TDES_PERMUTATION, \"PERMUTATION OPERATION\"},\n+\t\t{TDES_SUBSTITUTION_TABLE, \"SUBSTITUTION TABLE\"},\n+\t\t{TDES_VARIABLE_KEY, \"VARIABLE KEY\"},\n+\t\t{TDES_VARIABLE_TEXT, \"VARIABLE PLAINTEXT/CIPHERTEXT\"},\n+\t\t{TDES_VARIABLE_TEXT, \"KAT\"},\n+\t\t{TDES_MCT, \"Monte Carlo (Modes) Test\"},\n+\t\t{TDES_MMT, \"Multi block Message Test\"},\n+};\n+\n+static int\n+writeback_tdes_hex_str(const char *key, char *dst, struct fips_val *val);\n+\n+static int\n+parse_3des_uint8_hex_str(const char *key, char *src, struct fips_val *val);\n+\n+static int\n+parse_tdes_interim(const char *key,\n+\t\t__attribute__((__unused__)) char *text,\n+\t\tstruct fips_val *val);\n+\n+struct fips_test_callback tdes_tests_vectors[] = {\n+\t\t{KEYS_STR, parse_3des_uint8_hex_str, &vec.cipher_auth.key},\n+\t\t{KEY1_STR, parse_3des_uint8_hex_str, &vec.cipher_auth.key},\n+\t\t{KEY2_STR, parse_3des_uint8_hex_str, &vec.cipher_auth.key},\n+\t\t{KEY3_STR, parse_3des_uint8_hex_str, &vec.cipher_auth.key},\n+\t\t{IV_STR, parse_uint8_hex_str, &vec.iv},\n+\t\t{PT_STR, parse_uint8_hex_str, &vec.pt},\n+\t\t{CT_STR, parse_uint8_hex_str, &vec.ct},\n+\t\t{NULL, NULL, NULL} /**< end pointer */\n+};\n+\n+struct fips_test_callback tdes_tests_interim_vectors[] = {\n+\t\t{ENC_STR, parse_tdes_interim, NULL},\n+\t\t{DEC_STR, parse_tdes_interim, NULL},\n+\t\t{NULL, NULL, NULL} /**< end pointer */\n+};\n+\n+struct fips_test_callback tdes_writeback_callbacks[] = {\n+\t\t/** First element is used to pass COUNT string */\n+\t\t{COUNT_STR, NULL, NULL},\n+\t\t{IV_STR, writeback_hex_str, &vec.iv},\n+\t\t{KEY1_STR, writeback_tdes_hex_str, &vec.cipher_auth.key},\n+\t\t{KEY2_STR, writeback_tdes_hex_str, &vec.cipher_auth.key},\n+\t\t{KEY3_STR, writeback_tdes_hex_str, &vec.cipher_auth.key},\n+\t\t{KEYS_STR, writeback_tdes_hex_str, &vec.cipher_auth.key},\n+\t\t{PT_STR, writeback_hex_str, &vec.pt},\n+\t\t{CT_STR, writeback_hex_str, &vec.ct},\n+\t\t{NULL, NULL, NULL} /**< end pointer */\n+};\n+\n+static int\n+parse_tdes_interim(const char *key,\n+\t\t__attribute__((__unused__)) char *text,\n+\t\t__attribute__((__unused__)) struct fips_val *val)\n+{\n+\tif (strstr(key, ENC_STR))\n+\t\tinfo.op = FIPS_TEST_ENC_AUTH_GEN;\n+\telse if (strstr(key, DEC_STR))\n+\t\tinfo.op = FIPS_TEST_DEC_AUTH_VERIF;\n+\telse if (strstr(NK_STR, \"NumKeys = 1\"))\n+\t\tinfo.interim_info.tdes_data.nb_keys = 1;\n+\telse if (strstr(NK_STR, \"NumKeys = 2\"))\n+\t\tinfo.interim_info.tdes_data.nb_keys = 2;\n+\telse if (strstr(NK_STR, \"NumKeys = 3\"))\n+\t\tinfo.interim_info.tdes_data.nb_keys = 3;\n+\telse\n+\t\treturn -EINVAL;\n+\n+\treturn 0;\n+}\n+\n+static int\n+parse_3des_uint8_hex_str(const char *key, char *src, struct fips_val *val)\n+{\n+\tuint8_t tmp_key[24] = {0};\n+\tuint32_t len, i;\n+\n+\tsrc += strlen(key);\n+\n+\tlen = strlen(src) / 2;\n+\n+\tif (val->val) {\n+\t\tmemcpy(tmp_key, val->val, val->len);\n+\t\trte_free(val->val);\n+\t}\n+\n+\tval->val = rte_zmalloc(NULL, 24, 0);\n+\tif (!val->val)\n+\t\treturn -1;\n+\n+\tmemcpy(val->val, tmp_key, 24);\n+\n+\tif (strstr(key, KEYS_STR)) {\n+\t\tfor (i = 0; i < len; i++) {\n+\t\t\tchar byte[3] = {src[i * 2], src[i * 2 + 1], '\\0'};\n+\n+\t\t\tif (parser_read_uint8_hex(&val->val[i], byte) < 0)\n+\t\t\t\treturn -EINVAL;\n+\t\t}\n+\n+\t\tmemcpy(val->val + 8, val->val, 8);\n+\t\tmemcpy(val->val + 16, val->val, 8);\n+\n+\t} else if (strstr(key, KEY1_STR)) {\n+\t\tfor (i = 0; i < len; i++) {\n+\t\t\tchar byte[3] = {src[i * 2], src[i * 2 + 1], '\\0'};\n+\n+\t\t\tif (parser_read_uint8_hex(&val->val[i], byte) < 0)\n+\t\t\t\treturn -EINVAL;\n+\t\t}\n+\n+\t\tif (info.interim_info.tdes_data.nb_keys == 2)\n+\t\t\tmemcpy(val->val + 16, val->val, 8);\n+\n+\t} else if (strstr(key, KEY2_STR)) {\n+\t\tfor (i = 0; i < len; i++) {\n+\t\t\tchar byte[3] = {src[i * 2], src[i * 2 + 1], '\\0'};\n+\n+\t\t\tif (parser_read_uint8_hex(&val->val[i + 8], byte) < 0)\n+\t\t\t\treturn -EINVAL;\n+\t\t}\n+\n+\t} else if (strstr(key, KEY3_STR)) {\n+\t\tfor (i = 0; i < len; i++) {\n+\t\t\tchar byte[3] = {src[i * 2], src[i * 2 + 1], '\\0'};\n+\n+\t\t\tif (parser_read_uint8_hex(&val->val[i + 16], byte) < 0)\n+\t\t\t\treturn -EINVAL;\n+\t\t}\n+\t} else\n+\t\treturn -EINVAL;\n+\n+\tval->len = 24;\n+\n+\treturn 0;\n+}\n+\n+static int\n+parse_test_tdes_writeback(struct fips_val *val)\n+{\n+\n+\tif (info.op == FIPS_TEST_ENC_AUTH_GEN)\n+\t\tfprintf(info.fp_wr, \"%s\", CT_STR);\n+\telse\n+\t\tfprintf(info.fp_wr, \"%s\", PT_STR);\n+\n+\tparse_write_hex_str(val);\n+\n+\treturn 0;\n+\n+}\n+\n+static int\n+writeback_tdes_hex_str(const char *key, char *dst, struct fips_val *val)\n+{\n+\tstruct fips_val tmp_val;\n+\n+\ttmp_val.len = 8;\n+\n+\tif (strstr(key, KEY1_STR))\n+\t\ttmp_val.val = val->val;\n+\telse if (strstr(key, KEY2_STR))\n+\t\ttmp_val.val = val->val + 8;\n+\telse if (strstr(key, KEY3_STR))\n+\t\ttmp_val.val = val->val + 16;\n+\n+\treturn writeback_hex_str(key, dst, &tmp_val);\n+}\n+\n+static int\n+rsp_test_tdes_check(struct fips_val *val)\n+{\n+\tstruct fips_val *data;\n+\n+\tif (info.op == FIPS_TEST_ENC_AUTH_GEN)\n+\t\tdata = &vec.ct;\n+\telse\n+\t\tdata = &vec.pt;\n+\n+\tif (memcmp(val->val, data->val, val->len) == 0)\n+\t\tfprintf(info.fp_wr, \"Success\\n\");\n+\telse\n+\t\tfprintf(info.fp_wr, \"Failed\\n\");\n+\n+\treturn 0;\n+}\n+\n+int\n+parse_test_tdes_init(void)\n+{\n+\tuint32_t i;\n+\n+\tfor (i = 0; i < info.nb_vec_lines; i++) {\n+\t\tchar *line = info.vec[i];\n+\t\tuint32_t j;\n+\n+\t\tif (strstr(line, TEST_CBCI_KEY))\n+\t\t\treturn -EPERM;\n+\n+\t\tfor (j = 0; j < RTE_DIM(test_types); j++)\n+\t\t\tif (strstr(line, test_types[j].desc)) {\n+\t\t\t\tinfo.interim_info.tdes_data.test_type =\n+\t\t\t\t\t\ttest_types[j].type;\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t}\n+\n+\tinfo.parse_writeback = parse_test_tdes_writeback;\n+\tinfo.callbacks = tdes_tests_vectors;\n+\tinfo.interim_callbacks = tdes_tests_interim_vectors;\n+\tinfo.writeback_callbacks = tdes_writeback_callbacks;\n+\tinfo.kat_check = rsp_test_tdes_check;\n+\n+\treturn 0;\n+}\ndiff --git a/examples/cryptodev_fips_validate/cryptodev_fips_parse_aes.c b/examples/cryptodev_fips_validate/cryptodev_fips_parse_aes.c\nindex 39dbd6ff9..cc2775428 100644\n--- a/examples/cryptodev_fips_validate/cryptodev_fips_parse_aes.c\n+++ b/examples/cryptodev_fips_validate/cryptodev_fips_parse_aes.c\n@@ -33,6 +33,8 @@ struct {\n \t\t{AESAVS_TYPE_KEYSBOX, \"KeySbox\"},\n \t\t{AESAVS_TYPE_VARKEY, \"VarKey\"},\n \t\t{AESAVS_TYPE_VARTXT, \"VarTxt\"},\n+\t\t{TDES_VARIABLE_TEXT, \"VARIABLE PLAINTEXT/CIPHERTEXT\"},\n+\t\t{TDES_VARIABLE_TEXT, \"KAT\"},\n \t\t{AESAVS_TYPE_MMT, \"MMT\"},\n \t\t{AESAVS_TYPE_MCT, \"MCT\"},\n };\ndiff --git a/examples/cryptodev_fips_validate/cryptodev_fips_parse_validate.c b/examples/cryptodev_fips_validate/cryptodev_fips_parse_validate.c\nindex f1cd80253..bb396e54d 100644\n--- a/examples/cryptodev_fips_validate/cryptodev_fips_parse_validate.c\n+++ b/examples/cryptodev_fips_validate/cryptodev_fips_parse_validate.c\n@@ -114,6 +114,11 @@ fips_test_parse_header(void)\n \t\t\tret = parse_test_hmac_init();\n \t\t\tif (ret < 0)\n \t\t\t\treturn ret;\n+\t\t} else if (strstr(info.vec[i], \"TDES\")) {\n+\t\t\tinfo.algo = FIPS_TEST_ALGO_TDES;\n+\t\t\tret = parse_test_tdes_init();\n+\t\t\tif (ret < 0)\n+\t\t\t\treturn 0;\n \t\t}\n \n \t\ttmp = strstr(info.vec[i], \"# Config info for \");\ndiff --git a/examples/cryptodev_fips_validate/cryptodev_fips_validate.h b/examples/cryptodev_fips_validate/cryptodev_fips_validate.h\nindex 3cda9fe87..c9b11dda2 100644\n--- a/examples/cryptodev_fips_validate/cryptodev_fips_validate.h\n+++ b/examples/cryptodev_fips_validate/cryptodev_fips_validate.h\n@@ -25,6 +25,7 @@\n enum fips_test_algorithms {\n \t\tFIPS_TEST_ALGO_AES = 0,\n \t\tFIPS_TEST_ALGO_HMAC,\n+\t\tFIPS_TEST_ALGO_TDES,\n \t\tFIPS_TEST_ALGO_MAX\n };\n \n@@ -88,6 +89,17 @@ enum fips_aesavs_test_types {\n \tAESAVS_TYPE_MCT,\n };\n \n+enum fips_tdes_test_types {\n+\tTDES_INVERSE_PERMUTATION = 0,\n+\tTDES_PERMUTATION,\n+\tTDES_SUBSTITUTION_TABLE,\n+\tTDES_VARIABLE_KEY,\n+\tTDES_VARIABLE_TEXT,\n+\tTDES_KAT,\n+\tTDES_MCT, /* Monte Carlo (Modes) Test */\n+\tTDES_MMT /* Multi block Message Test */\n+};\n+\n struct aesavs_interim_data {\n \tenum fips_aesavs_test_types test_type;\n \tuint32_t cipher_algo;\n@@ -98,6 +110,11 @@ struct hmac_interim_data {\n \tenum rte_crypto_auth_algorithm algo;\n };\n \n+struct tdes_interim_data {\n+\tenum fips_tdes_test_types test_type;\n+\tuint32_t nb_keys;\n+};\n+\n struct fips_test_interim_info {\n \tFILE *fp_rd;\n \tFILE *fp_wr;\n@@ -112,6 +129,7 @@ struct fips_test_interim_info {\n \tunion {\n \t\tstruct aesavs_interim_data aes_data;\n \t\tstruct hmac_interim_data hmac_data;\n+\t\tstruct tdes_interim_data tdes_data;\n \n \t} interim_info;\n \n@@ -148,6 +166,9 @@ int\n parse_test_aes_init(void);\n \n int\n+parse_test_tdes_init(void);\n+\n+int\n parse_test_hmac_init(void);\n \n int\ndiff --git a/examples/cryptodev_fips_validate/main.c b/examples/cryptodev_fips_validate/main.c\nindex a16557655..9696fa895 100644\n--- a/examples/cryptodev_fips_validate/main.c\n+++ b/examples/cryptodev_fips_validate/main.c\n@@ -502,6 +502,46 @@ prepare_aes_xform(struct rte_crypto_sym_xform *xform)\n }\n \n static int\n+prepare_tdes_xform(struct rte_crypto_sym_xform *xform)\n+{\n+\tconst struct rte_cryptodev_symmetric_capability *cap;\n+\tstruct rte_cryptodev_sym_capability_idx cap_idx;\n+\tstruct rte_crypto_cipher_xform *cipher_xform = &xform->cipher;\n+\n+\txform->type = RTE_CRYPTO_SYM_XFORM_CIPHER;\n+\n+\tcipher_xform->algo = RTE_CRYPTO_CIPHER_3DES_CBC;\n+\tcipher_xform->op = (info.op == FIPS_TEST_ENC_AUTH_GEN) ?\n+\t\t\tRTE_CRYPTO_CIPHER_OP_ENCRYPT :\n+\t\t\tRTE_CRYPTO_CIPHER_OP_DECRYPT;\n+\tcipher_xform->key.data = vec.cipher_auth.key.val;\n+\tcipher_xform->key.length = vec.cipher_auth.key.len;\n+\tcipher_xform->iv.length = vec.iv.len;\n+\tcipher_xform->iv.offset = IV_OFF;\n+\n+\tcap_idx.algo.cipher = RTE_CRYPTO_CIPHER_3DES_CBC;\n+\tcap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;\n+\n+\tcap = rte_cryptodev_sym_capability_get(env.dev_id, &cap_idx);\n+\tif (!cap) {\n+\t\tRTE_LOG(ERR, USER1, \"Failed to get capability for cdev %u\\n\",\n+\t\t\t\tenv.dev_id);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (rte_cryptodev_sym_capability_check_cipher(cap,\n+\t\t\tcipher_xform->key.length,\n+\t\t\tcipher_xform->iv.length) != 0) {\n+\t\tRTE_LOG(ERR, USER1, \"PMD %s key length %u IV length %u\\n\",\n+\t\t\t\tinfo.device_name, cipher_xform->key.length,\n+\t\t\t\tcipher_xform->iv.length);\n+\t\treturn -EPERM;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static int\n prepare_hmac_xform(struct rte_crypto_sym_xform *xform)\n {\n \tconst struct rte_cryptodev_symmetric_capability *cap;\n@@ -640,6 +680,133 @@ fips_generic_test(void)\n }\n \n static int\n+fips_mct_tdes_test(void)\n+{\n+#define TDES_BLOCK_SIZE\t\t16\n+#define TDES_EXTERN_ITER\t400\n+#define TDES_INTERN_ITER\t10000\n+\tstruct fips_val val, val_key;\n+\tuint8_t prev_out[TDES_BLOCK_SIZE];\n+\tuint8_t prev_prev_out[TDES_BLOCK_SIZE];\n+\tuint8_t prev_in[TDES_BLOCK_SIZE];\n+\tuint32_t i, j, k;\n+\tint ret;\n+\n+\tfor (i = 0; i < TDES_EXTERN_ITER; i++) {\n+\t\tif (i != 0)\n+\t\t\tupdate_info_vec(i);\n+\n+\t\tfips_test_write_one_case();\n+\n+\t\tfor (j = 0; j < TDES_INTERN_ITER; j++) {\n+\t\t\tret = fips_run_test();\n+\t\t\tif (ret < 0) {\n+\t\t\t\tif (ret == -EPERM) {\n+\t\t\t\t\tfprintf(info.fp_wr, \"Bypass\\n\");\n+\t\t\t\t\treturn 0;\n+\t\t\t\t}\n+\n+\t\t\t\treturn ret;\n+\t\t\t}\n+\n+\t\t\tget_writeback_data(&val);\n+\n+\t\t\tif (info.op == FIPS_TEST_DEC_AUTH_VERIF)\n+\t\t\t\tmemcpy(prev_in, vec.ct.val, TDES_BLOCK_SIZE);\n+\n+\t\t\tif (j == 0) {\n+\t\t\t\tmemcpy(prev_out, val.val, TDES_BLOCK_SIZE);\n+\n+\t\t\t\tif (info.op == FIPS_TEST_ENC_AUTH_GEN) {\n+\t\t\t\t\tmemcpy(vec.pt.val, vec.iv.val,\n+\t\t\t\t\t\t\tTDES_BLOCK_SIZE);\n+\t\t\t\t\tmemcpy(vec.iv.val, val.val,\n+\t\t\t\t\t\t\tTDES_BLOCK_SIZE);\n+\t\t\t\t} else {\n+\t\t\t\t\tmemcpy(vec.iv.val, vec.ct.val,\n+\t\t\t\t\t\t\tTDES_BLOCK_SIZE);\n+\t\t\t\t\tmemcpy(vec.ct.val, val.val,\n+\t\t\t\t\t\t\tTDES_BLOCK_SIZE);\n+\t\t\t\t}\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\n+\t\t\tif (info.op == FIPS_TEST_ENC_AUTH_GEN) {\n+\t\t\t\tmemcpy(vec.iv.val, val.val, TDES_BLOCK_SIZE);\n+\t\t\t\tmemcpy(vec.pt.val, prev_out, TDES_BLOCK_SIZE);\n+\t\t\t} else {\n+\t\t\t\tmemcpy(vec.iv.val, vec.ct.val, TDES_BLOCK_SIZE);\n+\t\t\t\tmemcpy(vec.ct.val, val.val, TDES_BLOCK_SIZE);\n+\t\t\t}\n+\n+\t\t\tif (j == TDES_INTERN_ITER - 1)\n+\t\t\t\tcontinue;\n+\n+\t\t\tmemcpy(prev_out, val.val, TDES_BLOCK_SIZE);\n+\n+\t\t\tif (j == TDES_INTERN_ITER - 3)\n+\t\t\t\tmemcpy(prev_prev_out, val.val, TDES_BLOCK_SIZE);\n+\t\t}\n+\n+\t\tinfo.parse_writeback(&val);\n+\t\tfprintf(info.fp_wr, \"\\n\");\n+\n+\t\tif (i == TDES_EXTERN_ITER - 1)\n+\t\t\tcontinue;\n+\n+\t\t/** update key */\n+\t\tmemcpy(&val_key, &vec.cipher_auth.key, sizeof(val_key));\n+\n+\t\tif (info.interim_info.tdes_data.nb_keys == 0) {\n+\t\t\tif (memcmp(val_key.val, val_key.val + 8, 8) == 0)\n+\t\t\t\tinfo.interim_info.tdes_data.nb_keys = 1;\n+\t\t\telse if (memcmp(val_key.val, val_key.val + 16, 8) == 0)\n+\t\t\t\tinfo.interim_info.tdes_data.nb_keys = 2;\n+\t\t\telse\n+\t\t\t\tinfo.interim_info.tdes_data.nb_keys = 3;\n+\n+\t\t}\n+\n+\t\tfor (k = 0; k < TDES_BLOCK_SIZE; k++) {\n+\n+\t\t\tswitch (info.interim_info.tdes_data.nb_keys) {\n+\t\t\tcase 3:\n+\t\t\t\tval_key.val[k] ^= val.val[k];\n+\t\t\t\tval_key.val[k + 8] ^= prev_out[k];\n+\t\t\t\tval_key.val[k + 16] ^= prev_prev_out[k];\n+\t\t\t\tbreak;\n+\t\t\tcase 2:\n+\t\t\t\tval_key.val[k] ^= val.val[k];\n+\t\t\t\tval_key.val[k + 8] ^= prev_out[k];\n+\t\t\t\tval_key.val[k + 16] ^= val.val[k];\n+\t\t\t\tbreak;\n+\t\t\tdefault: /* case 1 */\n+\t\t\t\tval_key.val[k] ^= val.val[k];\n+\t\t\t\tval_key.val[k + 8] ^= val.val[k];\n+\t\t\t\tval_key.val[k + 16] ^= val.val[k];\n+\t\t\t\tbreak;\n+\t\t\t}\n+\n+\t\t}\n+\n+\t\tfor (k = 0; k < 24; k++)\n+\t\t\tval_key.val[k] = (__builtin_popcount(val_key.val[k]) &\n+\t\t\t\t\t0x1) ?\n+\t\t\t\t\tval_key.val[k] : (val_key.val[k] ^ 0x1);\n+\n+\t\tif (info.op == FIPS_TEST_ENC_AUTH_GEN) {\n+\t\t\tmemcpy(vec.iv.val, val.val, TDES_BLOCK_SIZE);\n+\t\t\tmemcpy(vec.pt.val, prev_out, TDES_BLOCK_SIZE);\n+\t\t} else {\n+\t\t\tmemcpy(vec.iv.val, prev_out, TDES_BLOCK_SIZE);\n+\t\t\tmemcpy(vec.ct.val, val.val, TDES_BLOCK_SIZE);\n+\t\t}\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static int\n fips_mct_aes_test(void)\n {\n #define AES_BLOCK_SIZE\t16\n@@ -758,6 +925,14 @@ init_test_ops(void)\n \t\ttest_ops.prepare_xform = prepare_hmac_xform;\n \t\ttest_ops.test = fips_generic_test;\n \t\tbreak;\n+\tcase FIPS_TEST_ALGO_TDES:\n+\t\ttest_ops.prepare_op = prepare_cipher_op;\n+\t\ttest_ops.prepare_xform  = prepare_tdes_xform;\n+\t\tif (info.interim_info.tdes_data.test_type == TDES_MCT)\n+\t\t\ttest_ops.test = fips_mct_tdes_test;\n+\t\telse\n+\t\t\ttest_ops.test = fips_generic_test;\n+\t\tbreak;\n \n \tdefault:\n \t\treturn -1;\ndiff --git a/examples/cryptodev_fips_validate/meson.build b/examples/cryptodev_fips_validate/meson.build\nindex dcf90bbbb..a18e76d4b 100644\n--- a/examples/cryptodev_fips_validate/meson.build\n+++ b/examples/cryptodev_fips_validate/meson.build\n@@ -11,6 +11,7 @@ allow_experimental_apis = true\n sources = files(\n \t'cryptodev_fips_parse_aes.c',\n \t'cryptodev_fips_parse_hmac.c',\n+\t'cryptodev_fips_parse_3des.c',\n \t'cryptodev_fips_parse_validate.c',\n \t'main.c'\n )\n",
    "prefixes": [
        "v3",
        "4/8"
    ]
}