From: Archana Muniganti Date: Wed, 9 Sep 2020 16:26:35 +0000 (+0530) Subject: examples/fips_validation: fix version compatibility X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=79365018409917a1bf3222cb3352d7c06a878e87;p=dpdk.git examples/fips_validation: fix version compatibility Separate out CAVS request file version 21.4 code to support lower versions. Fixes: 32440cdf2af9 ("examples/fips_validation: fix parsing of TDES vectors") Fixes: 2b84d2bd47df ("examples/fips_validation: fix count overwrite for TDES") Cc: stable@dpdk.org Signed-off-by: Archana Muniganti Acked-by: Fan Zhang Tested-by: Yu Jiang --- diff --git a/examples/fips_validation/fips_validation.c b/examples/fips_validation/fips_validation.c index 13f763c9aa..7454a03b16 100644 --- a/examples/fips_validation/fips_validation.c +++ b/examples/fips_validation/fips_validation.c @@ -92,6 +92,15 @@ error_exit: return -ENOMEM; } +static void +fips_test_parse_version(void) +{ + int len = strlen(info.vec[0]); + char *ptr = info.vec[0]; + + info.version = strtof(ptr + len - 4, NULL); +} + static int fips_test_parse_header(void) { @@ -106,7 +115,10 @@ fips_test_parse_header(void) if (ret < 0) return ret; - for (i = 0; i < info.nb_vec_lines; i++) { + if (info.nb_vec_lines) + fips_test_parse_version(); + + for (i = 1; i < info.nb_vec_lines; i++) { if (!algo_parsed) { if (strstr(info.vec[i], "AESVS")) { algo_parsed = 1; @@ -352,6 +364,8 @@ fips_test_parse_one_case(void) uint32_t interim_cnt = 0; int ret; + info.vec_start_off = 0; + if (info.interim_callbacks) { for (i = 0; i < info.nb_vec_lines; i++) { is_interim = 0; @@ -373,17 +387,24 @@ fips_test_parse_one_case(void) } } - info.vec_start_off = interim_cnt; - if (interim_cnt) { - for (i = 0; i < interim_cnt; i++) - fprintf(info.fp_wr, "%s\n", info.vec[i]); - fprintf(info.fp_wr, "\n"); - - if (info.nb_vec_lines == interim_cnt) + if (info.version == 21.4f) { + for (i = 0; i < interim_cnt; i++) + fprintf(info.fp_wr, "%s\n", info.vec[i]); + fprintf(info.fp_wr, "\n"); + + if (info.nb_vec_lines == interim_cnt) + return 1; + } else { + for (i = 0; i < info.nb_vec_lines; i++) + fprintf(info.fp_wr, "%s\n", info.vec[i]); + fprintf(info.fp_wr, "\n"); return 1; + } } + info.vec_start_off = interim_cnt; + for (i = info.vec_start_off; i < info.nb_vec_lines; i++) { for (j = 0; info.callbacks[j].key != NULL; j++) if (strstr(info.vec[i], info.callbacks[j].key)) { @@ -648,7 +669,7 @@ update_info_vec(uint32_t count) cb = &info.writeback_callbacks[0]; - if (!(strstr(info.vec[0], cb->key))) { + if ((info.version == 21.4f) && (!(strstr(info.vec[0], cb->key)))) { fprintf(info.fp_wr, "%s%u\n", cb->key, count); i = 0; } else { @@ -656,9 +677,8 @@ update_info_vec(uint32_t count) count); i = 1; } - snprintf(info.vec[0], strlen(info.vec[0]) + 4, "%s%u", cb->key, count); - for (i = 1; i < info.nb_vec_lines; i++) { + for (; i < info.nb_vec_lines; i++) { for (j = 1; info.writeback_callbacks[j].key != NULL; j++) { cb = &info.writeback_callbacks[j]; if (strstr(info.vec[i], cb->key)) { diff --git a/examples/fips_validation/fips_validation.h b/examples/fips_validation/fips_validation.h index deba83eada..ca8964aaa1 100644 --- a/examples/fips_validation/fips_validation.h +++ b/examples/fips_validation/fips_validation.h @@ -166,6 +166,7 @@ struct fips_test_interim_info { uint32_t nb_vec_lines; char device_name[MAX_STRING_SIZE]; char file_name[MAX_FILE_NAME_SIZE]; + float version; union { struct aesavs_interim_data aes_data; diff --git a/examples/fips_validation/main.c b/examples/fips_validation/main.c index 9e46307bb2..2a7a3fb5e0 100644 --- a/examples/fips_validation/main.c +++ b/examples/fips_validation/main.c @@ -1088,10 +1088,12 @@ fips_mct_tdes_test(void) int test_mode = info.interim_info.tdes_data.test_mode; for (i = 0; i < TDES_EXTERN_ITER; i++) { - if (i == 0) { + if ((i == 0) && (info.version == 21.4f)) { if (!(strstr(info.vec[0], "COUNT"))) fprintf(info.fp_wr, "%s%u\n", "COUNT = ", 0); - } else + } + + if (i != 0) update_info_vec(i); fips_test_write_one_case();