get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 47726,
    "url": "http://patches.dpdk.org/api/patches/47726/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20181102095535.7906-6-marko.kovacevic@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": "<20181102095535.7906-6-marko.kovacevic@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20181102095535.7906-6-marko.kovacevic@intel.com",
    "date": "2018-11-02T09:55:32",
    "name": "[v7,5/8] examples/fips_validation: support GCM parsing",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "de92b9a8f9ae55424357ecdfd17e4ad380e09b37",
    "submitter": {
        "id": 853,
        "url": "http://patches.dpdk.org/api/people/853/?format=api",
        "name": "Kovacevic, Marko",
        "email": "marko.kovacevic@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/20181102095535.7906-6-marko.kovacevic@intel.com/mbox/",
    "series": [
        {
            "id": 2223,
            "url": "http://patches.dpdk.org/api/series/2223/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=2223",
            "date": "2018-11-02T09:55:27",
            "name": "FIPS validation capability",
            "version": 7,
            "mbox": "http://patches.dpdk.org/series/2223/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/47726/comments/",
    "check": "warning",
    "checks": "http://patches.dpdk.org/api/patches/47726/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 052261B3AB;\n\tFri,  2 Nov 2018 10:55:55 +0100 (CET)",
            "from mga12.intel.com (mga12.intel.com [192.55.52.136])\n\tby dpdk.org (Postfix) with ESMTP id 634611B395\n\tfor <dev@dpdk.org>; Fri,  2 Nov 2018 10:55:50 +0100 (CET)",
            "from fmsmga001.fm.intel.com ([10.253.24.23])\n\tby fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t02 Nov 2018 02:55:50 -0700",
            "from silpixa00399502.ir.intel.com (HELO\n\tsilpixa00399502.ger.corp.intel.com) ([10.237.223.218])\n\tby fmsmga001.fm.intel.com with ESMTP; 02 Nov 2018 02:55:49 -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,455,1534834800\"; d=\"scan'208\";a=\"104701212\"",
        "From": "\"Kovacevic, Marko\" <marko.kovacevic@intel.com>",
        "To": "akhil.goyal@nxp.com",
        "Cc": "dev@dpdk.org, roy.fan.zhang@intel.com, arkadiuszx.kusztal@intel.com,\n\t\"Kovacevic, Marko\" <marko.kovacevic@intel.com>",
        "Date": "Fri,  2 Nov 2018 09:55:32 +0000",
        "Message-Id": "<20181102095535.7906-6-marko.kovacevic@intel.com>",
        "X-Mailer": "git-send-email 2.9.5",
        "In-Reply-To": "<20181102095535.7906-1-marko.kovacevic@intel.com>",
        "References": "<20181026110716.42093-1-marko.kovacevic@intel.com>\n\t<20181102095535.7906-1-marko.kovacevic@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v7 5/8] examples/fips_validation: support GCM\n\tparsing",
        "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": "Added enablement for GCM parser, to allow the\napplication to parser the GCM request file and to validate all\ntests supported.\n\nSigned-off-by: Marko Kovacevic <marko.kovacevic@intel.com>\nSigned-off-by: Fan Zhang <roy.fan.zhang@intel.com>\nAcked-by: Arek Kusztal <arkadiuszx.kusztal@intel.com>\n---\n examples/fips_validation/Makefile              |   1 +\n examples/fips_validation/fips_validation.c     |   5 +\n examples/fips_validation/fips_validation.h     |   4 +\n examples/fips_validation/fips_validation_gcm.c | 125 +++++++++++++++++++++++++\n examples/fips_validation/main.c                | 116 ++++++++++++++++++++++-\n examples/fips_validation/meson.build           |   1 +\n 6 files changed, 251 insertions(+), 1 deletion(-)\n create mode 100644 examples/fips_validation/fips_validation_gcm.c",
    "diff": "diff --git a/examples/fips_validation/Makefile b/examples/fips_validation/Makefile\nindex 57cc778..6373ac3 100644\n--- a/examples/fips_validation/Makefile\n+++ b/examples/fips_validation/Makefile\n@@ -9,6 +9,7 @@ SRCS-y := fips_validation.c\n SRCS-y += fips_validation_aes.c\n SRCS-y += fips_validation_hmac.c\n SRCS-y += fips_validation_tdes.c\n+SRCS-y += fips_validation_gcm.c\n SRCS-y += main.c\n \n # Build using pkg-config variables if possible\ndiff --git a/examples/fips_validation/fips_validation.c b/examples/fips_validation/fips_validation.c\nindex 86f443d..1b926b8 100644\n--- a/examples/fips_validation/fips_validation.c\n+++ b/examples/fips_validation/fips_validation.c\n@@ -111,6 +111,11 @@ fips_test_parse_header(void)\n \t\t\tret = parse_test_aes_init();\n \t\t\tif (ret < 0)\n \t\t\t\treturn ret;\n+\t\t} else if (strstr(info.vec[i], \"GCM\")) {\n+\t\t\tinfo.algo = FIPS_TEST_ALGO_AES_GCM;\n+\t\t\tret = parse_test_gcm_init();\n+\t\t\tif (ret < 0)\n+\t\t\t\treturn ret;\n \t\t} else if (strstr(info.vec[i], \"HMAC\")) {\n \t\t\tinfo.algo = FIPS_TEST_ALGO_HMAC;\n \t\t\tret = parse_test_hmac_init();\ndiff --git a/examples/fips_validation/fips_validation.h b/examples/fips_validation/fips_validation.h\nindex 69a2116..4cceff5 100644\n--- a/examples/fips_validation/fips_validation.h\n+++ b/examples/fips_validation/fips_validation.h\n@@ -24,6 +24,7 @@\n \n enum fips_test_algorithms {\n \t\tFIPS_TEST_ALGO_AES = 0,\n+\t\tFIPS_TEST_ALGO_AES_GCM,\n \t\tFIPS_TEST_ALGO_HMAC,\n \t\tFIPS_TEST_ALGO_TDES,\n \t\tFIPS_TEST_ALGO_MAX\n@@ -171,6 +172,9 @@ int\n parse_test_hmac_init(void);\n \n int\n+parse_test_gcm_init(void);\n+\n+int\n parser_read_uint8_hex(uint8_t *value, const char *p);\n \n int\ndiff --git a/examples/fips_validation/fips_validation_gcm.c b/examples/fips_validation/fips_validation_gcm.c\nnew file mode 100644\nindex 0000000..0509b10\n--- /dev/null\n+++ b/examples/fips_validation/fips_validation_gcm.c\n@@ -0,0 +1,125 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2018 Intel Corporation\n+ */\n+\n+#include <string.h>\n+#include <time.h>\n+#include <stdio.h>\n+\n+#include <rte_cryptodev.h>\n+\n+#include \"fips_validation.h\"\n+\n+#define NEW_LINE_STR\t\"#\"\n+#define OP_STR\t\t\"GCM \"\n+\n+#define PARAM_PREFIX\t\"[\"\n+#define KEYLEN_STR\t\"Keylen = \"\n+#define IVLEN_STR\t\"IVlen = \"\n+#define PTLEN_STR\t\"PTlen = \"\n+#define AADLEN_STR\t\"AADlen = \"\n+#define TAGLEN_STR\t\"Taglen = \"\n+\n+#define COUNT_STR\t\"Count = \"\n+#define KEY_STR\t\t\"Key = \"\n+#define IV_STR\t\t\"IV = \"\n+#define PT_STR\t\t\"PT = \"\n+#define CT_STR\t\t\"CT = \"\n+#define TAG_STR\t\t\"Tag = \"\n+#define AAD_STR\t\t\"AAD = \"\n+\n+#define OP_ENC_STR\t\"Encrypt\"\n+#define OP_DEC_STR\t\"Decrypt\"\n+\n+#define NEG_TEST_STR\t\"FAIL\"\n+\n+struct fips_test_callback gcm_dec_vectors[] = {\n+\t\t{KEY_STR, parse_uint8_known_len_hex_str, &vec.cipher_auth.key},\n+\t\t{IV_STR, parse_uint8_known_len_hex_str, &vec.iv},\n+\t\t{CT_STR, parse_uint8_known_len_hex_str, &vec.ct},\n+\t\t{AAD_STR, parse_uint8_known_len_hex_str, &vec.cipher_auth.aad},\n+\t\t{TAG_STR, parse_uint8_known_len_hex_str,\n+\t\t\t\t&vec.cipher_auth.digest},\n+\t\t{NULL, NULL, NULL} /**< end pointer */\n+};\n+struct fips_test_callback gcm_interim_vectors[] = {\n+\t\t{KEYLEN_STR, parser_read_uint32_bit_val, &vec.cipher_auth.key},\n+\t\t{IVLEN_STR, parser_read_uint32_bit_val, &vec.iv},\n+\t\t{PTLEN_STR, parser_read_uint32_bit_val, &vec.pt},\n+\t\t{AADLEN_STR, parser_read_uint32_bit_val, &vec.cipher_auth.aad},\n+\t\t{TAGLEN_STR, parser_read_uint32_bit_val,\n+\t\t\t\t&vec.cipher_auth.digest},\n+\t\t{NULL, NULL, NULL} /**< end pointer */\n+};\n+\n+struct fips_test_callback gcm_enc_vectors[] = {\n+\t\t{KEY_STR, parse_uint8_known_len_hex_str, &vec.cipher_auth.key},\n+\t\t{IV_STR, parse_uint8_known_len_hex_str, &vec.iv},\n+\t\t{PT_STR, parse_uint8_known_len_hex_str, &vec.pt},\n+\t\t{AAD_STR, parse_uint8_known_len_hex_str, &vec.cipher_auth.aad},\n+\t\t{NULL, NULL, NULL} /**< end pointer */\n+};\n+\n+static int\n+parse_test_gcm_writeback(struct fips_val *val)\n+{\n+\tstruct fips_val tmp_val;\n+\n+\tif (info.op == FIPS_TEST_ENC_AUTH_GEN) {\n+\t\tfprintf(info.fp_wr, \"%s\", CT_STR);\n+\n+\t\ttmp_val.val = val->val;\n+\t\ttmp_val.len = vec.pt.len;\n+\n+\t\tparse_write_hex_str(&tmp_val);\n+\n+\t\tfprintf(info.fp_wr, \"%s\", TAG_STR);\n+\n+\t\ttmp_val.val = val->val + vec.pt.len;\n+\t\ttmp_val.len = val->len - vec.pt.len;\n+\n+\t\tparse_write_hex_str(&tmp_val);\n+\t} else {\n+\t\tif (vec.status == RTE_CRYPTO_OP_STATUS_SUCCESS) {\n+\t\t\tfprintf(info.fp_wr, \"%s\", PT_STR);\n+\n+\t\t\ttmp_val.val = val->val;\n+\t\t\ttmp_val.len = vec.pt.len;\n+\n+\t\t\tparse_write_hex_str(&tmp_val);\n+\t\t} else\n+\t\t\tfprintf(info.fp_wr, \"%s\\n\", NEG_TEST_STR);\n+\t}\n+\n+\treturn 0;\n+}\n+\n+int\n+parse_test_gcm_init(void)\n+{\n+\tchar *tmp;\n+\tuint32_t i;\n+\n+\n+\tfor (i = 0; i < info.nb_vec_lines; i++) {\n+\t\tchar *line = info.vec[i];\n+\n+\n+\t\ttmp = strstr(line, OP_STR);\n+\t\tif (tmp) {\n+\t\t\tif (strstr(line, OP_ENC_STR)) {\n+\t\t\t\tinfo.op = FIPS_TEST_ENC_AUTH_GEN;\n+\t\t\t\tinfo.callbacks = gcm_enc_vectors;\n+\t\t\t} else if (strstr(line, OP_DEC_STR)) {\n+\t\t\t\tinfo.op = FIPS_TEST_DEC_AUTH_VERIF;\n+\t\t\t\tinfo.callbacks = gcm_dec_vectors;\n+\t\t\t} else\n+\t\t\t\treturn -EINVAL;\n+\t\t}\n+\t}\n+\n+\tinfo.interim_callbacks = gcm_interim_vectors;\n+\tinfo.parse_writeback = parse_test_gcm_writeback;\n+\n+\treturn 0;\n+}\ndiff --git a/examples/fips_validation/main.c b/examples/fips_validation/main.c\nindex 3880681..c693e87 100644\n--- a/examples/fips_validation/main.c\n+++ b/examples/fips_validation/main.c\n@@ -462,6 +462,70 @@ prepare_auth_op(void)\n }\n \n static int\n+prepare_aead_op(void)\n+{\n+\tstruct rte_crypto_sym_op *sym = env.op->sym;\n+\tuint8_t *iv = rte_crypto_op_ctod_offset(env.op, uint8_t *, IV_OFF);\n+\n+\t__rte_crypto_op_reset(env.op, RTE_CRYPTO_OP_TYPE_SYMMETRIC);\n+\trte_pktmbuf_reset(env.mbuf);\n+\n+\tmemcpy(iv, vec.iv.val, vec.iv.len);\n+\n+\tsym->m_src = env.mbuf;\n+\tsym->aead.data.offset = 0;\n+\tsym->aead.aad.data = vec.aead.aad.val;\n+\tsym->aead.aad.phys_addr = rte_malloc_virt2iova(sym->aead.aad.data);\n+\n+\tif (info.op == FIPS_TEST_ENC_AUTH_GEN) {\n+\t\tuint8_t *pt;\n+\n+\t\tif (vec.pt.len > RTE_MBUF_MAX_NB_SEGS) {\n+\t\t\tRTE_LOG(ERR, USER1, \"PT len %u\\n\", vec.pt.len);\n+\t\t\treturn -EPERM;\n+\t\t}\n+\n+\t\tpt = (uint8_t *)rte_pktmbuf_append(env.mbuf,\n+\t\t\t\tvec.pt.len + vec.aead.digest.len);\n+\n+\t\tif (!pt) {\n+\t\t\tRTE_LOG(ERR, USER1, \"Error %i: MBUF too small\\n\",\n+\t\t\t\t\t-ENOMEM);\n+\t\t\treturn -ENOMEM;\n+\t\t}\n+\n+\t\tmemcpy(pt, vec.pt.val, vec.pt.len);\n+\t\tsym->aead.data.length = vec.pt.len;\n+\t\tsym->aead.digest.data = pt + vec.pt.len;\n+\t\tsym->aead.digest.phys_addr = rte_pktmbuf_mtophys_offset(\n+\t\t\t\tenv.mbuf, vec.pt.len);\n+\t} else {\n+\t\tuint8_t *ct;\n+\n+\t\tif (vec.ct.len > RTE_MBUF_MAX_NB_SEGS) {\n+\t\t\tRTE_LOG(ERR, USER1, \"CT len %u\\n\", vec.ct.len);\n+\t\t\treturn -EPERM;\n+\t\t}\n+\n+\t\tct = (uint8_t *)rte_pktmbuf_append(env.mbuf, vec.ct.len);\n+\n+\t\tif (!ct) {\n+\t\t\tRTE_LOG(ERR, USER1, \"Error %i: MBUF too small\\n\",\n+\t\t\t\t\t-ENOMEM);\n+\t\t\treturn -ENOMEM;\n+\t\t}\n+\n+\t\tmemcpy(ct, vec.ct.val, vec.ct.len);\n+\t\tsym->aead.data.length = vec.ct.len;\n+\t\tsym->aead.digest.data = vec.aead.digest.val;\n+\t\tsym->aead.digest.phys_addr = rte_malloc_virt2iova(\n+\t\t\t\tsym->aead.digest.data);\n+\t}\n+\n+\trte_crypto_op_attach_sym_session(env.op, env.sess);\n+}\n+\n+static int\n prepare_aes_xform(struct rte_crypto_sym_xform *xform)\n {\n \tconst struct rte_cryptodev_symmetric_capability *cap;\n@@ -578,6 +642,52 @@ prepare_hmac_xform(struct rte_crypto_sym_xform *xform)\n \treturn 0;\n }\n \n+static int\n+prepare_gcm_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_aead_xform *aead_xform = &xform->aead;\n+\n+\txform->type = RTE_CRYPTO_SYM_XFORM_AEAD;\n+\n+\taead_xform->algo = RTE_CRYPTO_AEAD_AES_GCM;\n+\taead_xform->aad_length = vec.aead.aad.len;\n+\taead_xform->digest_length = vec.aead.digest.len;\n+\taead_xform->iv.offset = IV_OFF;\n+\taead_xform->iv.length = vec.iv.len;\n+\taead_xform->key.data = vec.aead.key.val;\n+\taead_xform->key.length = vec.aead.key.len;\n+\taead_xform->op = (info.op == FIPS_TEST_ENC_AUTH_GEN) ?\n+\t\t\tRTE_CRYPTO_AEAD_OP_ENCRYPT :\n+\t\t\tRTE_CRYPTO_AEAD_OP_DECRYPT;\n+\n+\tcap_idx.algo.aead = aead_xform->algo;\n+\tcap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;\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_aead(cap,\n+\t\t\taead_xform->key.length,\n+\t\t\taead_xform->digest_length, aead_xform->aad_length,\n+\t\t\taead_xform->iv.length) != 0) {\n+\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\"PMD %s key_len %u tag_len %u aad_len %u iv_len %u\\n\",\n+\t\t\t\tinfo.device_name, aead_xform->key.length,\n+\t\t\t\taead_xform->digest_length,\n+\t\t\t\taead_xform->aad_length,\n+\t\t\t\taead_xform->iv.length);\n+\t\treturn -EPERM;\n+\t}\n+\n+\treturn 0;\n+}\n+\n static void\n get_writeback_data(struct fips_val *val)\n {\n@@ -933,7 +1043,11 @@ init_test_ops(void)\n \t\telse\n \t\t\ttest_ops.test = fips_generic_test;\n \t\tbreak;\n-\n+\tcase FIPS_TEST_ALGO_AES_GCM:\n+\t\ttest_ops.prepare_op = prepare_aead_op;\n+\t\ttest_ops.prepare_xform = prepare_gcm_xform;\n+\t\ttest_ops.test = fips_generic_test;\n+\t\tbreak;\n \tdefault:\n \t\treturn -1;\n \t}\ndiff --git a/examples/fips_validation/meson.build b/examples/fips_validation/meson.build\nindex 781ad5f..0cc8bc4 100644\n--- a/examples/fips_validation/meson.build\n+++ b/examples/fips_validation/meson.build\n@@ -13,5 +13,6 @@ sources = files(\n \t'fips_validation.c',\n \t'fips_validation_hmac.c',\n \t'fips_validation_tdes.c',\n+\t'fips_validation_gcm.c',\n \t'main.c'\n )\n",
    "prefixes": [
        "v7",
        "5/8"
    ]
}