examples/fips_validation: add parsing for AES-CTR

Added functionality to parse algorithm for AES CTR test

Signed-off-by: Brian Dooley <brian.dooley@intel.com>
Acked-by: Kai Ji <kai.ji@intel.com>
Acked-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
This commit is contained in:
Brian Dooley 2022-10-07 16:58:29 +00:00 committed by Akhil Goyal
parent e27268bd21
commit c8956fd284
5 changed files with 17 additions and 2 deletions

View File

@ -61,6 +61,7 @@ ACVP
* AES-CBC (128,192,256) - AFT, MCT
* AES-GCM (128,192,256) - AFT
* AES-CMAC (128,192,256) - AFT
* AES-CTR (128,192,256) - AFT, CTR
* AES-GMAC (128,192,256) - AFT
* AES-XTS (128,256) - AFT
* HMAC (SHA1, SHA224, SHA256, SHA384, SHA512)

View File

@ -470,6 +470,8 @@ fips_test_parse_one_json_vector_set(void)
info.algo = FIPS_TEST_ALGO_AES_CBC;
else if (strstr(algo_str, "AES-XTS"))
info.algo = FIPS_TEST_ALGO_AES_XTS;
else if (strstr(algo_str, "AES-CTR"))
info.algo = FIPS_TEST_ALGO_AES_CTR;
else if (strstr(algo_str, "SHA"))
info.algo = FIPS_TEST_ALGO_SHA;
else if (strstr(algo_str, "TDES-CBC") ||

View File

@ -35,6 +35,7 @@
enum fips_test_algorithms {
FIPS_TEST_ALGO_AES = 0,
FIPS_TEST_ALGO_AES_CBC,
FIPS_TEST_ALGO_AES_CTR,
FIPS_TEST_ALGO_AES_GCM,
FIPS_TEST_ALGO_AES_GMAC,
FIPS_TEST_ALGO_AES_CMAC,
@ -106,6 +107,7 @@ enum fips_aesavs_test_types {
AESAVS_TYPE_MMT,
AESAVS_TYPE_MCT,
AESAVS_TYPE_AFT,
AESAVS_TYPE_CTR,
};
enum fips_tdes_test_types {

View File

@ -30,8 +30,10 @@
#define TESTTYPE_JSON_STR "testType"
#define DIR_JSON_STR "direction"
#define KEYLEN_JSON_STR "keyLen"
#define OVERFLOW_JSON_STR "overflow"
#define KEY_JSON_STR "key"
#define PAYLOADLEN_JSON_STR "payloadLen"
#define IV_JSON_STR "iv"
#define PT_JSON_STR "pt"
#define CT_JSON_STR "ct"
@ -52,6 +54,7 @@ struct {
{AESAVS_TYPE_MMT, "MMT"},
{AESAVS_TYPE_MCT, "MCT"},
{AESAVS_TYPE_AFT, "AFT"},
{AESAVS_TYPE_CTR, "CTR"},
};
struct aes_test_algo {
@ -60,6 +63,7 @@ struct aes_test_algo {
} const algo_con[] = {
{"CBC", RTE_CRYPTO_CIPHER_AES_CBC},
{"ECB", RTE_CRYPTO_CIPHER_AES_ECB},
{"CTR", RTE_CRYPTO_CIPHER_AES_CTR},
};
static int
@ -291,6 +295,7 @@ parse_test_aes_json_init(void)
case AESAVS_TYPE_MCT:
info.parse_writeback = parse_test_aes_mct_json_writeback;
break;
case AESAVS_TYPE_CTR:
case AESAVS_TYPE_AFT:
info.parse_writeback = parse_test_aes_json_writeback;
break;

View File

@ -776,9 +776,11 @@ prepare_aes_xform(struct rte_crypto_sym_xform *xform)
struct rte_crypto_cipher_xform *cipher_xform = &xform->cipher;
xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER;
if (info.interim_info.aes_data.cipher_algo == RTE_CRYPTO_CIPHER_AES_CBC)
cipher_xform->algo = RTE_CRYPTO_CIPHER_AES_CBC;
else if (info.interim_info.aes_data.cipher_algo ==
RTE_CRYPTO_CIPHER_AES_CTR)
cipher_xform->algo = RTE_CRYPTO_CIPHER_AES_CTR;
else
cipher_xform->algo = RTE_CRYPTO_CIPHER_AES_ECB;
@ -787,7 +789,8 @@ prepare_aes_xform(struct rte_crypto_sym_xform *xform)
RTE_CRYPTO_CIPHER_OP_DECRYPT;
cipher_xform->key.data = vec.cipher_auth.key.val;
cipher_xform->key.length = vec.cipher_auth.key.len;
if (cipher_xform->algo == RTE_CRYPTO_CIPHER_AES_CBC) {
if (cipher_xform->algo == RTE_CRYPTO_CIPHER_AES_CBC ||
cipher_xform->algo == RTE_CRYPTO_CIPHER_AES_CTR) {
cipher_xform->iv.length = vec.iv.len;
cipher_xform->iv.offset = IV_OFF;
} else {
@ -1818,6 +1821,7 @@ init_test_ops(void)
{
switch (info.algo) {
case FIPS_TEST_ALGO_AES_CBC:
case FIPS_TEST_ALGO_AES_CTR:
case FIPS_TEST_ALGO_AES:
test_ops.prepare_op = prepare_cipher_op;
test_ops.prepare_xform = prepare_aes_xform;
@ -2035,6 +2039,7 @@ fips_test_one_test_group(void)
ret = parse_test_xts_json_init();
break;
case FIPS_TEST_ALGO_AES_CBC:
case FIPS_TEST_ALGO_AES_CTR:
case FIPS_TEST_ALGO_AES:
ret = parse_test_aes_json_init();
break;