DPDK patches and discussions
 help / color / mirror / Atom feed
From: Marko Kovacevic <marko.kovacevic@intel.com>
To: Akhil Goyal <akhil.goyal@nxp.com>, "dev@dpdk.org" <dev@dpdk.org>
Cc: "roy.fan.zhang@intel.com" <roy.fan.zhang@intel.com>,
	"arkadiuszx.kusztal@intel.com" <arkadiuszx.kusztal@intel.com>
Subject: Re: [dpdk-dev] [PATCH v5 4/8] examples/cryptodev_fips_validate: add TDES parser and enablement for test types
Date: Wed, 24 Oct 2018 15:11:18 +0100	[thread overview]
Message-ID: <587999e2-1152-ed3d-2691-4d7f2f440cf5@intel.com> (raw)
In-Reply-To: <d7588fa4-889e-70df-b09f-eac57f80906b@nxp.com>


On 24/10/2018 13:31, Akhil Goyal wrote:
> better to be uniform with the name
> TDES or 3DES
sure will make it uniform
>
> On 10/17/2018 6:19 PM, Marko Kovacevic wrote:
>> Added enablement for TDES parser, to allow the
>> application to parser the TDES request files and to validate all
>> test types supported.
>>
>> Signed-off-by: Marko Kovacevic <marko.kovacevic@intel.com>
>> Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
>> Acked-by: Arek Kusztal <arkadiuszx.kusztal@intel.com>
>> ---
>>    examples/cryptodev_fips_validate/Makefile          |   1 +
>>    .../cryptodev_fips_parse_3des.c                    | 259 +++++++++++++++++++++
>>    .../cryptodev_fips_parse_aes.c                     |   2 +
>>    .../cryptodev_fips_parse_validate.c                |   5 +
>>    .../cryptodev_fips_validate.h                      |  21 ++
>>    examples/cryptodev_fips_validate/main.c            | 175 ++++++++++++++
>>    examples/cryptodev_fips_validate/meson.build       |   1 +
>>    7 files changed, 464 insertions(+)
>>    create mode 100644 examples/cryptodev_fips_validate/cryptodev_fips_parse_3des.c
>>
>> diff --git a/examples/cryptodev_fips_validate/Makefile b/examples/cryptodev_fips_validate/Makefile
>> index c85c76c..2ddf326 100644
>> --- a/examples/cryptodev_fips_validate/Makefile
>> +++ b/examples/cryptodev_fips_validate/Makefile
>> @@ -7,6 +7,7 @@ APP = fips_validation
>>    # all source are stored in SRCS-y
>>    SRCS-y := cryptodev_fips_parse_aes.c
>>    SRCS-y += cryptodev_fips_parse_hmac.c
>> +SRCS-y += cryptodev_fips_parse_3des.c
>>    SRCS-y += cryptodev_fips_parse_validate.c
>>    SRCS-y += main.c
>>    
>> diff --git a/examples/cryptodev_fips_validate/cryptodev_fips_parse_3des.c b/examples/cryptodev_fips_validate/cryptodev_fips_parse_3des.c
>> new file mode 100644
>> index 0000000..82e9132
>> --- /dev/null
>> +++ b/examples/cryptodev_fips_validate/cryptodev_fips_parse_3des.c
>> @@ -0,0 +1,259 @@
>> +/* SPDX-License-Identifier: BSD-3-Clause
>> + * Copyright(c) 2018 Intel Corporation
>> + */
>> +
>> +#include <string.h>
>> +#include <stdio.h>
>> +
>> +#include <rte_malloc.h>
>> +#include <rte_cryptodev.h>
>> +
>> +#include "cryptodev_fips_validate.h"
>> +
>> +#define NEW_LINE_STR	"#"
>> +#define TEST_TYPE_KEY	" for CBC"
>> +#define TEST_CBCI_KEY	" for CBCI"
>> +
>> +#define ENC_STR		"[ENCRYPT]"
>> +#define DEC_STR		"[DECRYPT]"
>> +
>> +#define COUNT_STR	"COUNT = "
>> +#define KEY1_STR	"KEY1 = "
>> +#define KEY2_STR	"KEY2 = "
>> +#define KEY3_STR	"KEY3 = "
>> +
>> +#define KEYS_STR	"KEYs = "
>> +#define IV_STR		"IV = "
>> +#define PT_STR		"PLAINTEXT = "
>> +#define CT_STR		"CIPHERTEXT = "
>> +#define NK_STR		"NumKeys = "
>> +
>> +#define SET_STR		" = "
>> +
>> +#define PLAIN_TEXT	0
>> +#define CIPHER_TEXT	1
>> +#define KEY_TEXT	2
>> +#define IV_TEXT		3
>> +
>> +#define DEVICE_STR	"# Config Info for : "
>> +
>> +struct {
>> +	uint32_t type;
>> +	const char *desc;
>> +} test_types[] = {
>> +		{TDES_INVERSE_PERMUTATION, "INVERSE PERMUTATION"},
>> +		{TDES_PERMUTATION, "PERMUTATION OPERATION"},
>> +		{TDES_SUBSTITUTION_TABLE, "SUBSTITUTION TABLE"},
>> +		{TDES_VARIABLE_KEY, "VARIABLE KEY"},
>> +		{TDES_VARIABLE_TEXT, "VARIABLE PLAINTEXT/CIPHERTEXT"},
>> +		{TDES_VARIABLE_TEXT, "KAT"},
>> +		{TDES_MCT, "Monte Carlo (Modes) Test"},
>> +		{TDES_MMT, "Multi block Message Test"},
>> +};
>> +
>> +static int
>> +writeback_tdes_hex_str(const char *key, char *dst, struct fips_val *val);
>> +
>> +static int
>> +parse_3des_uint8_hex_str(const char *key, char *src, struct fips_val *val);
>> +
>> +static int
>> +parse_tdes_interim(const char *key,
>> +		__attribute__((__unused__)) char *text,
>> +		struct fips_val *val);
>> +
>> +struct fips_test_callback tdes_tests_vectors[] = {
>> +		{KEYS_STR, parse_3des_uint8_hex_str, &vec.cipher_auth.key},
>> +		{KEY1_STR, parse_3des_uint8_hex_str, &vec.cipher_auth.key},
>> +		{KEY2_STR, parse_3des_uint8_hex_str, &vec.cipher_auth.key},
>> +		{KEY3_STR, parse_3des_uint8_hex_str, &vec.cipher_auth.key},
>> +		{IV_STR, parse_uint8_hex_str, &vec.iv},
>> +		{PT_STR, parse_uint8_hex_str, &vec.pt},
>> +		{CT_STR, parse_uint8_hex_str, &vec.ct},
>> +		{NULL, NULL, NULL} /**< end pointer */
>> +};
>> +
>> +struct fips_test_callback tdes_tests_interim_vectors[] = {
>> +		{ENC_STR, parse_tdes_interim, NULL},
>> +		{DEC_STR, parse_tdes_interim, NULL},
>> +		{NULL, NULL, NULL} /**< end pointer */
>> +};
>> +
>> +struct fips_test_callback tdes_writeback_callbacks[] = {
>> +		/** First element is used to pass COUNT string */
>> +		{COUNT_STR, NULL, NULL},
>> +		{IV_STR, writeback_hex_str, &vec.iv},
>> +		{KEY1_STR, writeback_tdes_hex_str, &vec.cipher_auth.key},
>> +		{KEY2_STR, writeback_tdes_hex_str, &vec.cipher_auth.key},
>> +		{KEY3_STR, writeback_tdes_hex_str, &vec.cipher_auth.key},
>> +		{KEYS_STR, writeback_tdes_hex_str, &vec.cipher_auth.key},
>> +		{PT_STR, writeback_hex_str, &vec.pt},
>> +		{CT_STR, writeback_hex_str, &vec.ct},
>> +		{NULL, NULL, NULL} /**< end pointer */
>> +};
>> +
>> +static int
>> +parse_tdes_interim(const char *key,
>> +		__attribute__((__unused__)) char *text,
>> +		__attribute__((__unused__)) struct fips_val *val)
>> +{
>> +	if (strstr(key, ENC_STR))
>> +		info.op = FIPS_TEST_ENC_AUTH_GEN;
>> +	else if (strstr(key, DEC_STR))
>> +		info.op = FIPS_TEST_DEC_AUTH_VERIF;
>> +	else if (strstr(NK_STR, "NumKeys = 1"))
>> +		info.interim_info.tdes_data.nb_keys = 1;
>> +	else if (strstr(NK_STR, "NumKeys = 2"))
>> +		info.interim_info.tdes_data.nb_keys = 2;
>> +	else if (strstr(NK_STR, "NumKeys = 3"))
>> +		info.interim_info.tdes_data.nb_keys = 3;
>> +	else
>> +		return -EINVAL;
>> +
>> +	return 0;
>> +}
>> +
>> +static int
>> +parse_3des_uint8_hex_str(const char *key, char *src, struct fips_val *val)
>> +{
>> +	uint8_t tmp_key[24] = {0};
>> +	uint32_t len, i;
>> +
>> +	src += strlen(key);
>> +
>> +	len = strlen(src) / 2;
>> +
>> +	if (val->val) {
>> +		memcpy(tmp_key, val->val, val->len);
>> +		rte_free(val->val);
>> +	}
>> +
>> +	val->val = rte_zmalloc(NULL, 24, 0);
>> +	if (!val->val)
>> +		return -1;
>> +
>> +	memcpy(val->val, tmp_key, 24);
>> +
>> +	if (strstr(key, KEYS_STR)) {
>> +		for (i = 0; i < len; i++) {
>> +			char byte[3] = {src[i * 2], src[i * 2 + 1], '\0'};
>> +
>> +			if (parser_read_uint8_hex(&val->val[i], byte) < 0)
>> +				return -EINVAL;
> memory leak for val->val
good catch will fix it.
>> +		}
>> +
>> +		memcpy(val->val + 8, val->val, 8);
>> +		memcpy(val->val + 16, val->val, 8);
>> +
>> +	} else if (strstr(key, KEY1_STR)) {
>> +		for (i = 0; i < len; i++) {
>> +			char byte[3] = {src[i * 2], src[i * 2 + 1], '\0'};
>> +
>> +			if (parser_read_uint8_hex(&val->val[i], byte) < 0)
>> +				return -EINVAL;
>> +		}
>> +
>> +		if (info.interim_info.tdes_data.nb_keys == 2)
>> +			memcpy(val->val + 16, val->val, 8);
>> +
>> +	} else if (strstr(key, KEY2_STR)) {
>> +		for (i = 0; i < len; i++) {
>> +			char byte[3] = {src[i * 2], src[i * 2 + 1], '\0'};
>> +
>> +			if (parser_read_uint8_hex(&val->val[i + 8], byte) < 0)
>> +				return -EINVAL;
>> +		}
>> +
>> +	} else if (strstr(key, KEY3_STR)) {
>> +		for (i = 0; i < len; i++) {
>> +			char byte[3] = {src[i * 2], src[i * 2 + 1], '\0'};
>> +
>> +			if (parser_read_uint8_hex(&val->val[i + 16], byte) < 0)
>> +				return -EINVAL;
>> +		}
>> +	} else
>> +		return -EINVAL;
>> +
>> +	val->len = 24;
>> +
>> +	return 0;
>> +}
>> +
>>

  reply	other threads:[~2018-10-24 14:11 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-12 14:44 [dpdk-dev] [PATCH v4 0/8] FIPS validation capability Marko Kovacevic
2018-10-12 14:44 ` [dpdk-dev] [PATCH v4 1/8] examples: add fips validation into examples Marko Kovacevic
2018-10-12 14:44 ` [dpdk-dev] [PATCH v4 2/8] examples: add aes parser and enablement for test types Marko Kovacevic
2018-10-12 14:44 ` [dpdk-dev] [PATCH v4 3/8] examples: add hmac parser Marko Kovacevic
2018-10-12 14:44 ` [dpdk-dev] [PATCH v4 4/8] examples: add TDES parser and enablement for test types Marko Kovacevic
2018-10-12 14:44 ` [dpdk-dev] [PATCH v4 5/8] examples: add gcm parser Marko Kovacevic
2018-10-12 14:44 ` [dpdk-dev] [PATCH v4 6/8] examples: add cmac parser and enablement for test types Marko Kovacevic
2018-10-12 14:45 ` [dpdk-dev] [PATCH v4 7/8] examples: add ccm " Marko Kovacevic
2018-10-12 14:45 ` [dpdk-dev] [PATCH v4 8/8] doc: add guides for fips validation Marko Kovacevic
2018-10-15  6:36 ` [dpdk-dev] [PATCH v4 0/8] FIPS validation capability Kusztal, ArkadiuszX
2018-10-16 14:40 ` Akhil Goyal
2018-10-17 12:49 ` [dpdk-dev] [PATCH v5 " Marko Kovacevic
2018-10-17 12:49   ` [dpdk-dev] [PATCH v5 1/8] examples/cryptodev_fips_validate: add fips validation into examples Marko Kovacevic
2018-10-24 12:13     ` Akhil Goyal
2018-10-24 14:17       ` Marko Kovacevic
2018-10-24 14:36         ` Akhil Goyal
2018-10-24 15:13           ` Marko Kovacevic
2018-10-17 12:49   ` [dpdk-dev] [PATCH v5 2/8] examples/cryptodev_fips_validate: add aes parser and enablement for test types Marko Kovacevic
2018-10-24 12:37     ` Akhil Goyal
2018-10-24 14:18       ` Marko Kovacevic
2018-10-17 12:49   ` [dpdk-dev] [PATCH v5 3/8] examples/cryptodev_fips_validate: add hmac parser Marko Kovacevic
2018-10-17 12:49   ` [dpdk-dev] [PATCH v5 4/8] examples/cryptodev_fips_validate: add TDES parser and enablement for test types Marko Kovacevic
2018-10-24 12:31     ` Akhil Goyal
2018-10-24 14:11       ` Marko Kovacevic [this message]
2018-10-17 12:49   ` [dpdk-dev] [PATCH v5 5/8] examples/cryptodev_fips_validate: add gcm parser Marko Kovacevic
2018-10-17 12:49   ` [dpdk-dev] [PATCH v5 6/8] examples/cryptodev_fips_validate: add cmac parser and enablement for test types Marko Kovacevic
2018-10-17 12:49   ` [dpdk-dev] [PATCH v5 7/8] examples/cryptodev_fips_validate: add ccm " Marko Kovacevic
2018-10-17 12:49   ` [dpdk-dev] [PATCH v5 8/8] doc/guides/sample_app_ug: add guides for fips validation Marko Kovacevic
2018-10-24 12:51     ` Akhil Goyal
2018-10-24 11:42   ` [dpdk-dev] [PATCH v5 0/8] FIPS validation capability Akhil Goyal
2018-10-26 11:07   ` [dpdk-dev] [PATCH v6 " Marko Kovacevic
2018-10-26 11:07     ` [dpdk-dev] [PATCH v6 1/8] examples/fips_validation: add cryptodev fips compliant application Marko Kovacevic
2018-10-26 11:07     ` [dpdk-dev] [PATCH v6 2/8] examples/fips_validation: support AES parsing Marko Kovacevic
2018-10-26 11:07     ` [dpdk-dev] [PATCH v6 3/8] examples/fips_validation: support HMAC parsing Marko Kovacevic
2018-10-26 11:07     ` [dpdk-dev] [PATCH v6 4/8] examples/fips_validation: support TDES parsing Marko Kovacevic
2018-10-26 11:07     ` [dpdk-dev] [PATCH v6 5/8] examples/fips_validation: support GCM parsing Marko Kovacevic
2018-10-26 11:07     ` [dpdk-dev] [PATCH v6 6/8] examples/fips_validation: support CMAC parsing Marko Kovacevic
2018-10-26 11:07     ` [dpdk-dev] [PATCH v6 7/8] examples/fips_validation: support CCM parsing Marko Kovacevic
2018-10-26 11:07     ` [dpdk-dev] [PATCH v6 8/8] doc: add fips validation application guide Marko Kovacevic
2018-11-02  9:17     ` [dpdk-dev] [PATCH v6 0/8] FIPS validation capability Akhil Goyal
2018-11-02  9:34       ` Kovacevic, Marko
2018-11-02  9:55     ` [dpdk-dev] [PATCH v7 " Kovacevic, Marko
2018-11-02  9:55       ` [dpdk-dev] [PATCH v7 1/8] examples/fips_validation: add cryptodev fips compliant application Kovacevic, Marko
2018-11-02  9:55       ` [dpdk-dev] [PATCH v7 2/8] examples/fips_validation: support AES parsing Kovacevic, Marko
2018-11-02  9:55       ` [dpdk-dev] [PATCH v7 3/8] examples/fips_validation: support HMAC parsing Kovacevic, Marko
2018-11-02  9:55       ` [dpdk-dev] [PATCH v7 4/8] examples/fips_validation: support TDES parsing Kovacevic, Marko
2018-11-02  9:55       ` [dpdk-dev] [PATCH v7 5/8] examples/fips_validation: support GCM parsing Kovacevic, Marko
2018-11-02  9:55       ` [dpdk-dev] [PATCH v7 6/8] examples/fips_validation: support CMAC parsing Kovacevic, Marko
2018-11-02  9:55       ` [dpdk-dev] [PATCH v7 7/8] examples/fips_validation: support CCM parsing Kovacevic, Marko
2018-11-02  9:55       ` [dpdk-dev] [PATCH v7 8/8] doc: add fips validation application guide Kovacevic, Marko
2018-11-02 11:23       ` [dpdk-dev] [PATCH v7 0/8] FIPS validation capability Akhil Goyal
2018-11-02 11:34         ` Akhil Goyal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=587999e2-1152-ed3d-2691-4d7f2f440cf5@intel.com \
    --to=marko.kovacevic@intel.com \
    --cc=akhil.goyal@nxp.com \
    --cc=arkadiuszx.kusztal@intel.com \
    --cc=dev@dpdk.org \
    --cc=roy.fan.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).