examples/fips_validation: add parsing for AES GMAC
PATCH 1/1 examples/fips_validation: add parsing for AES GMAC
Added functionality to parse algorithm for AES GMAC test
--- examples/fips_validation/fips_validation.c | 2 ++ examples/fips_validation/fips_validation.h | 1 + examples/fips_validation/main.c | 6 ++++++ 3 files changed, 9 insertions(+)
examples/fips_validation/fips_validation.c +2 -0
@@ -458,6 +458,8 @@ fips_test_parse_one_json_vector_set(void)/* Vector sets contain the algorithm type, and nothing else we need. */ if (strstr (algo_str,"AES-GCM" )) info.algo =FIPS_TEST_ALGO_AES_GCM ; +else if (strstr (algo_str,"AES-GMAC" )) + info.algo =FIPS_TEST_ALGO_AES_GMAC ;else if (strstr (algo_str,"HMAC" )) info.algo =FIPS_TEST_ALGO_HMAC ;else if (strstr (algo_str,"CMAC" ))
examples/fips_validation/fips_validation.h +1 -0
@@ -36,6 +36,7 @@ enum fips_test_algorithms {FIPS_TEST_ALGO_AES =0 ,FIPS_TEST_ALGO_AES_CBC ,FIPS_TEST_ALGO_AES_GCM , +FIPS_TEST_ALGO_AES_GMAC ,FIPS_TEST_ALGO_AES_CMAC ,FIPS_TEST_ALGO_AES_CCM , FIPS_TEST_ALGO_AES_XTS,
examples/fips_validation/main.c +6 -0
@@ -1817,6 +1817,11 @@ init_test_ops(void)else test_ops.test = fips_generic_test;break ; +case FIPS_TEST_ALGO_AES_GMAC : + test_ops.prepare_op = prepare_auth_op; + test_ops.prepare_xform = prepare_gmac_xform; + test_ops.test = fips_generic_test; +break ;case FIPS_TEST_ALGO_AES_GCM : test_ops.prepare_op = prepare_aead_op; test_ops.prepare_xform = prepare_gcm_xform;
@@ -1994,6 +1999,7 @@ fips_test_one_test_group(void)json_object_set_new (json_info.json_write_group,"tests" , write_tests);switch (info.algo) { +case FIPS_TEST_ALGO_AES_GMAC :case FIPS_TEST_ALGO_AES_GCM : ret =parse_test_gcm_json_init ();break ;
Signature · 1 line
2.25.1
PATCH v2 1/1 examples/fips_validation: add parsing for AES GMAC
Added functionality to parse algorithm for AES GMAC test
---
v2: add random internal iv generation
--- examples/fips_validation/fips_validation.c | 2 ++ examples/fips_validation/fips_validation.h | 1 + .../fips_validation/fips_validation_gcm.c | 13 ++++++------ examples/fips_validation/main.c | 21 +++++++++++++++++++ 4 files changed, 31 insertions(+), 6 deletions(-)
examples/fips_validation/fips_validation.c +2 -0
@@ -458,6 +458,8 @@ fips_test_parse_one_json_vector_set(void)/* Vector sets contain the algorithm type, and nothing else we need. */ if (strstr (algo_str,"AES-GCM" )) info.algo =FIPS_TEST_ALGO_AES_GCM ; +else if (strstr (algo_str,"AES-GMAC" )) + info.algo =FIPS_TEST_ALGO_AES_GMAC ;else if (strstr (algo_str,"HMAC" )) info.algo =FIPS_TEST_ALGO_HMAC ;else if (strstr (algo_str,"CMAC" ))
examples/fips_validation/fips_validation.h +1 -0
@@ -36,6 +36,7 @@ enum fips_test_algorithms {FIPS_TEST_ALGO_AES =0 ,FIPS_TEST_ALGO_AES_CBC ,FIPS_TEST_ALGO_AES_GCM , +FIPS_TEST_ALGO_AES_GMAC ,FIPS_TEST_ALGO_AES_CMAC ,FIPS_TEST_ALGO_AES_CCM , FIPS_TEST_ALGO_AES_XTS,
examples/fips_validation/fips_validation_gcm.c +7 -6
@@ -291,13 +291,14 @@ parse_test_gcm_json_writeback(struct fips_val *val)if (info.op ==FIPS_TEST_ENC_AUTH_GEN ) {json_t *ct; +if (!info.interim_info.gcm_data.is_gmac) { + tmp_val.val = val->val; + tmp_val.len = vec.pt.len; - tmp_val.val = val->val; - tmp_val.len = vec.pt.len; - -writeback_hex_str ("" , info.one_line_text, &tmp_val); - ct =json_string (info.one_line_text); -json_object_set_new (json_info.json_write_case,CT_JSON_STR , ct); +writeback_hex_str ("" , info.one_line_text, &tmp_val); + ct =json_string (info.one_line_text); +json_object_set_new (json_info.json_write_case,CT_JSON_STR , ct); + }if (info.interim_info.gcm_data.gen_iv) {json_t *iv;
examples/fips_validation/main.c +21 -0
@@ -669,6 +669,21 @@ prepare_auth_op(void)__rte_crypto_op_reset (env.op,RTE_CRYPTO_OP_TYPE_SYMMETRIC ); +if (info.interim_info.gcm_data.gen_iv ==1 ) { +uint32_t i; + +if (!vec.iv.val) { + vec.iv.val =rte_malloc (0 , vec.iv.len,0 ); +if (!vec.iv.val) +return -ENOMEM ; + } + +for (i =0 ; i < vec.iv.len; i++) { +int random =rand (); + vec.iv.val[i] = (uint8_t )random; + } + } +if (vec.iv.len) { uint8_t *iv = rte_crypto_op_ctod_offset(env.op, uint8_t *,IV_OFF );
@@ -1817,6 +1832,11 @@ init_test_ops(void)else test_ops.test = fips_generic_test;break ; +case FIPS_TEST_ALGO_AES_GMAC : + test_ops.prepare_op = prepare_auth_op; + test_ops.prepare_xform = prepare_gmac_xform; + test_ops.test = fips_generic_test; +break ;case FIPS_TEST_ALGO_AES_GCM : test_ops.prepare_op = prepare_aead_op; test_ops.prepare_xform = prepare_gcm_xform;
@@ -1994,6 +2014,7 @@ fips_test_one_test_group(void)json_object_set_new (json_info.json_write_group,"tests" , write_tests);switch (info.algo) { +case FIPS_TEST_ALGO_AES_GMAC :case FIPS_TEST_ALGO_AES_GCM : ret =parse_test_gcm_json_init ();break ;
Signature · 1 line
2.25.1
Quoted 9 lines
-----Original Message-----
From: Dooley, Brian <[email protected]>
Sent: Thursday, September 1, 2022 11:35 AM
To: Zhang, Roy Fan <[email protected]>; Dooley, Brian <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Ji, Kai <[email protected]>
Subject: [PATCH v2] examples/fips_validation: add parsing for AES GMAC
Quoted 6 lines
Added functionality to parse algorithm for AES GMAC test
Signed-off-by Brian Dooley <[email protected]>---
v2: add random internal iv generation
---
PATCH v3 1/1 examples/fips_validation: add parsing for AES GMAC
In reply to Brian DooleyAdded functionality to parse algorithm for AES GMAC test
---
v2: add random internal iv generation
---
v3: in reply to fix and patchwork CI
--- examples/fips_validation/fips_validation.c | 2 ++ examples/fips_validation/fips_validation.h | 1 + .../fips_validation/fips_validation_gcm.c | 13 ++++++------ examples/fips_validation/main.c | 21 +++++++++++++++++++ 4 files changed, 31 insertions(+), 6 deletions(-)
examples/fips_validation/fips_validation.c +2 -0
@@ -458,6 +458,8 @@ fips_test_parse_one_json_vector_set(void)/* Vector sets contain the algorithm type, and nothing else we need. */ if (strstr (algo_str,"AES-GCM" )) info.algo =FIPS_TEST_ALGO_AES_GCM ; +else if (strstr (algo_str,"AES-GMAC" )) + info.algo =FIPS_TEST_ALGO_AES_GMAC ;else if (strstr (algo_str,"HMAC" )) info.algo =FIPS_TEST_ALGO_HMAC ;else if (strstr (algo_str,"CMAC" ))
examples/fips_validation/fips_validation.h +1 -0
@@ -36,6 +36,7 @@ enum fips_test_algorithms {FIPS_TEST_ALGO_AES =0 ,FIPS_TEST_ALGO_AES_CBC ,FIPS_TEST_ALGO_AES_GCM , +FIPS_TEST_ALGO_AES_GMAC ,FIPS_TEST_ALGO_AES_CMAC ,FIPS_TEST_ALGO_AES_CCM , FIPS_TEST_ALGO_AES_XTS,
examples/fips_validation/fips_validation_gcm.c +7 -6
@@ -291,13 +291,14 @@ parse_test_gcm_json_writeback(struct fips_val *val)if (info.op ==FIPS_TEST_ENC_AUTH_GEN ) {json_t *ct; +if (!info.interim_info.gcm_data.is_gmac) { + tmp_val.val = val->val; + tmp_val.len = vec.pt.len; - tmp_val.val = val->val; - tmp_val.len = vec.pt.len; - -writeback_hex_str ("" , info.one_line_text, &tmp_val); - ct =json_string (info.one_line_text); -json_object_set_new (json_info.json_write_case,CT_JSON_STR , ct); +writeback_hex_str ("" , info.one_line_text, &tmp_val); + ct =json_string (info.one_line_text); +json_object_set_new (json_info.json_write_case,CT_JSON_STR , ct); + }if (info.interim_info.gcm_data.gen_iv) {json_t *iv;
examples/fips_validation/main.c +21 -0
@@ -669,6 +669,21 @@ prepare_auth_op(void)__rte_crypto_op_reset (env.op,RTE_CRYPTO_OP_TYPE_SYMMETRIC ); +if (info.interim_info.gcm_data.gen_iv ==1 ) { +uint32_t i; + +if (!vec.iv.val) { + vec.iv.val =rte_malloc (0 , vec.iv.len,0 ); +if (!vec.iv.val) +return -ENOMEM ; + } + +for (i =0 ; i < vec.iv.len; i++) { +int random =rand (); + vec.iv.val[i] = (uint8_t )random; + } + } +if (vec.iv.len) { uint8_t *iv = rte_crypto_op_ctod_offset(env.op, uint8_t *,IV_OFF );
@@ -1817,6 +1832,11 @@ init_test_ops(void)else test_ops.test = fips_generic_test;break ; +case FIPS_TEST_ALGO_AES_GMAC : + test_ops.prepare_op = prepare_auth_op; + test_ops.prepare_xform = prepare_gmac_xform; + test_ops.test = fips_generic_test; +break ;case FIPS_TEST_ALGO_AES_GCM : test_ops.prepare_op = prepare_aead_op; test_ops.prepare_xform = prepare_gcm_xform;
@@ -1994,6 +2014,7 @@ fips_test_one_test_group(void)json_object_set_new (json_info.json_write_group,"tests" , write_tests);switch (info.algo) { +case FIPS_TEST_ALGO_AES_GMAC :case FIPS_TEST_ALGO_AES_GCM : ret =parse_test_gcm_json_init ();break ;
Signature · 1 line
2.25.1
Tested with FIPS test vectors from NIST.
Thanks,
Gowrishankar
Quoted 137 lines
-----Original Message-----
From: Brian Dooley <[email protected]>
Sent: Friday, September 16, 2022 2:30 PM
To: Fan Zhang <[email protected]>; Brian Dooley <[email protected]>
Cc: [email protected]; Gowrishankar Muthukrishnan <[email protected]>; Akhil Goyal <[email protected]>; [email protected]
Subject: [EXT] [PATCH v3] examples/fips_validation: add parsing for AES GMACExternal Email
----------------------------------------------------------------------
Added functionality to parse algorithm for AES GMAC testSigned-off-by Brian Dooley <[email protected]>Acked-by Kai Ji <[email protected]>---
v2: add random internal iv generation
---
v3: in reply to fix and patchwork CI--- examples/fips_validation/fips_validation.c | 2 ++ examples/fips_validation/fips_validation.h | 1 + .../fips_validation/fips_validation_gcm.c | 13 ++++++------ examples/fips_validation/main.c | 21 +++++++++++++++++++ 4 files changed, 31 insertions(+), 6 deletions(-)examples/fips_validation/fips_validation.c +2
-0@@ -458,6 +458,8 @@ fips_test_parse_one_json_vector_set(void)/* Vector sets contain the algorithm type, and nothing else we need. */ if (strstr (algo_str,"AES-GCM" )) info.algo =FIPS_TEST_ALGO_AES_GCM ; +else if (strstr (algo_str,"AES-GMAC" )) + info.algo =FIPS_TEST_ALGO_AES_GMAC ;else if (strstr (algo_str,"HMAC" )) info.algo =FIPS_TEST_ALGO_HMAC ;examples/fips_validation/fips_validation.c +0
-0else if (strstr (algo_str,"CMAC" ))examples/fips_validation/fips_validation.h +1
-0@@ -36,6 +36,7 @@ enum fips_test_algorithms {FIPS_TEST_ALGO_AES =0 ,FIPS_TEST_ALGO_AES_CBC ,FIPS_TEST_ALGO_AES_GCM , +FIPS_TEST_ALGO_AES_GMAC ,FIPS_TEST_ALGO_AES_CMAC ,FIPS_TEST_ALGO_AES_CCM , FIPS_TEST_ALGO_AES_XTS,examples/fips_validation/fips_validation_gcm.c +6
-6@@ -291,13 +291,14 @@ parse_test_gcm_json_writeback(struct fips_val *val)if (info.op ==FIPS_TEST_ENC_AUTH_GEN ) {json_t *ct; +if (!info.interim_info.gcm_data.is_gmac) { + tmp_val.val = val->val; + tmp_val.len = vec.pt.len; - tmp_val.val = val->val; - tmp_val.len = vec.pt.len; - -writeback_hex_str ("" , info.one_line_text, &tmp_val); - ct =json_string (info.one_line_text); -json_object_set_new (json_info.json_write_case, CT_JSON_STR, ct); +writeback_hex_str ("" , info.one_line_text, &tmp_val); + ct =json_string (info.one_line_text); + json_object_set_new(json_info.json_write_case,
CT_JSON_STR, ct);examples/fips_validation/fips_validation_gcm.c +1
-0+ }if (info.interim_info.gcm_data.gen_iv) {json_t *iv;(quoted diff) +0
-0
b/examples/fips_validation/main.cindex8bd5a66889..9118ca4d92100644examples/fips_validation/main.c +15
-0@@ -669,6 +669,21 @@ prepare_auth_op(void)__rte_crypto_op_reset (env.op,RTE_CRYPTO_OP_TYPE_SYMMETRIC ); +if (info.interim_info.gcm_data.gen_iv ==1 ) { +uint32_t i; + +if (!vec.iv.val) { + vec.iv.val =rte_malloc (0 , vec.iv.len,0 ); +if (!vec.iv.val) +return -ENOMEM ; + } + +for (i =0 ; i < vec.iv.len; i++) { +int random =rand (); + vec.iv.val[i] = (uint8_t )random; + } + } +if (vec.iv.len) { uint8_t *iv = rte_crypto_op_ctod_offset(env.op, uint8_t *,examples/fips_validation/main.c +6
-0IV_OFF);@@ -1817,6 +1832,11 @@ init_test_ops(void)else test_ops.test = fips_generic_test;break ; +case FIPS_TEST_ALGO_AES_GMAC : + test_ops.prepare_op = prepare_auth_op; + test_ops.prepare_xform = prepare_gmac_xform; + test_ops.test = fips_generic_test; +break ;case FIPS_TEST_ALGO_AES_GCM : test_ops.prepare_op = prepare_aead_op; test_ops.prepare_xform = prepare_gcm_xform; @@ -1994,6 +2014,7 @@ fips_test_one_test_group(void) json_object_set_new(json_info.json_write_group, "tests",
write_tests);examples/fips_validation/main.c +1
-1switch (info.algo) { +case FIPS_TEST_ALGO_AES_GMAC :case FIPS_TEST_ALGO_AES_GCM : ret =parse_test_gcm_json_init ();break ; --2.25.1
Akhil Goyal
AppliedQuoted 4 lines
Added functionality to parse algorithm for AES GMAC test
Signed-off-by Brian Dooley <[email protected]>Acked-by Kai Ji <[email protected]>
Added documentation update.
Applied to dpdk-next-crypto
Thanks.