[v1,08/10] examples/fips_validation: fix AES GCM validation tests

Message ID 24a928d04200ab33b4ce19c109e5ed905871f993.1675693844.git.gmuthukrishn@marvell.com (mailing list archive)
State Changes Requested, archived
Delegated to: akhil goyal
Headers
Series fips_validation application improvements |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Gowrishankar Muthukrishnan Feb. 6, 2023, 2:46 p.m. UTC
  AES GCM validation tests fail in FIPS validation due to incorrect
fields populated in response file. This patch fixes them.

Fixes: 5b540bebac8e ("examples/fips_validation: fix GMAC decryption output")

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 examples/fips_validation/fips_validation_gcm.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
  

Comments

Brian Dooley Feb. 27, 2023, 9:29 a.m. UTC | #1
> -----Original Message-----
> From: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> Sent: Monday 6 February 2023 14:46
> To: dev@dpdk.org
> Cc: Anoob Joseph <anoobj@marvell.com>; jerinj@marvell.com; Akhil Goyal
> <gakhil@marvell.com>; Dooley, Brian <brian.dooley@intel.com>;
> Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> Subject: [v1, 08/10] examples/fips_validation: fix AES GCM validation tests
> 
> AES GCM validation tests fail in FIPS validation due to incorrect fields
> populated in response file. This patch fixes them.
> 
> Fixes: 5b540bebac8e ("examples/fips_validation: fix GMAC decryption
> output")
> 
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> ---
>  examples/fips_validation/fips_validation_gcm.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/examples/fips_validation/fips_validation_gcm.c
> b/examples/fips_validation/fips_validation_gcm.c
> index a80d8b3e4d..bf08d1b995 100644
> --- a/examples/fips_validation/fips_validation_gcm.c
> +++ b/examples/fips_validation/fips_validation_gcm.c
> @@ -79,7 +79,7 @@ parser_read_gcm_pt_len(const char *key, char *src,
>  	if (ret < 0)
>  		return ret;
> 
> -	if (vec.pt.len == 0) {
> +	if (info.algo == FIPS_TEST_ALGO_AES_GMAC && vec.pt.len == 0) {
>  		info.interim_info.gcm_data.is_gmac = 1;
>  		test_ops.prepare_sym_op = prepare_auth_op;
>  		test_ops.prepare_sym_xform = prepare_gmac_xform; @@ -
> 296,6 +296,7 @@ parse_test_gcm_json_writeback(struct fips_val *val)
>  			tmp_val.val = val->val;
>  			tmp_val.len = vec.pt.len;
> 
> +			info.one_line_text[0] = '\0';
>  			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); @@ -326,6 +327,7 @@
> parse_test_gcm_json_writeback(struct fips_val *val)
>  				tmp_val.val = val->val;
>  				tmp_val.len = vec.pt.len;
> 
> +				info.one_line_text[0] = '\0';
>  				writeback_hex_str("", info.one_line_text,
> &tmp_val);
> 
> 	json_object_set_new(json_info.json_write_case, PT_JSON_STR,
>  					json_string(info.one_line_text));
> @@ -334,12 +336,8 @@ parse_test_gcm_json_writeback(struct fips_val
> *val)
>  					json_true());
>  			}
>  		} else {
> -			if (!info.interim_info.gcm_data.is_gmac)
> -
> 	json_object_set_new(json_info.json_write_case, PT_JSON_STR,
> -					json_string(""));
> -			else
> -
> 	json_object_set_new(json_info.json_write_case, "testPassed",
> -					json_false());
> +			json_object_set_new(json_info.json_write_case,
> "testPassed",
> +				json_false());
>  		}
>  	}
> 
> --
> 2.25.1

Acked-by: Brian Dooley <brian.dooley@intel.com>
  

Patch

diff --git a/examples/fips_validation/fips_validation_gcm.c b/examples/fips_validation/fips_validation_gcm.c
index a80d8b3e4d..bf08d1b995 100644
--- a/examples/fips_validation/fips_validation_gcm.c
+++ b/examples/fips_validation/fips_validation_gcm.c
@@ -79,7 +79,7 @@  parser_read_gcm_pt_len(const char *key, char *src,
 	if (ret < 0)
 		return ret;
 
-	if (vec.pt.len == 0) {
+	if (info.algo == FIPS_TEST_ALGO_AES_GMAC && vec.pt.len == 0) {
 		info.interim_info.gcm_data.is_gmac = 1;
 		test_ops.prepare_sym_op = prepare_auth_op;
 		test_ops.prepare_sym_xform = prepare_gmac_xform;
@@ -296,6 +296,7 @@  parse_test_gcm_json_writeback(struct fips_val *val)
 			tmp_val.val = val->val;
 			tmp_val.len = vec.pt.len;
 
+			info.one_line_text[0] = '\0';
 			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);
@@ -326,6 +327,7 @@  parse_test_gcm_json_writeback(struct fips_val *val)
 				tmp_val.val = val->val;
 				tmp_val.len = vec.pt.len;
 
+				info.one_line_text[0] = '\0';
 				writeback_hex_str("", info.one_line_text, &tmp_val);
 				json_object_set_new(json_info.json_write_case, PT_JSON_STR,
 					json_string(info.one_line_text));
@@ -334,12 +336,8 @@  parse_test_gcm_json_writeback(struct fips_val *val)
 					json_true());
 			}
 		} else {
-			if (!info.interim_info.gcm_data.is_gmac)
-				json_object_set_new(json_info.json_write_case, PT_JSON_STR,
-					json_string(""));
-			else
-				json_object_set_new(json_info.json_write_case, "testPassed",
-					json_false());
+			json_object_set_new(json_info.json_write_case, "testPassed",
+				json_false());
 		}
 	}