summaryrefslogtreecommitdiff
path: root/examples/fips_validation
diff options
context:
space:
mode:
authorMichael Shamis <michaelsh@marvell.com>2019-10-01 14:22:55 +0300
committerAkhil Goyal <akhil.goyal@nxp.com>2019-10-23 16:57:06 +0200
commitae65004fa7d2e72c1d640148eba1dbb6c52aacf1 (patch)
tree454438a8984d627c7f1b853007e7ea4a4f4f74b6 /examples/fips_validation
parentd3190431b58abfceec438e84de6f14e7c96b9d45 (diff)
downloaddpdk-ae65004fa7d2e72c1d640148eba1dbb6c52aacf1.zip
dpdk-ae65004fa7d2e72c1d640148eba1dbb6c52aacf1.tar.gz
dpdk-ae65004fa7d2e72c1d640148eba1dbb6c52aacf1.tar.xz
examples/fips_validation: separate ECB and CBC init
Separate initialization of IV, PT and CT according to TDES ECB and CBC crypto modes Signed-off-by: Michael Shamis <michaelsh@marvell.com> Reviewed-by: Marko Kovacevic <marko.kovacevic@intel.com>
Diffstat (limited to 'examples/fips_validation')
-rw-r--r--examples/fips_validation/main.c66
1 files changed, 50 insertions, 16 deletions
diff --git a/examples/fips_validation/main.c b/examples/fips_validation/main.c
index c83763b..f8694ef 100644
--- a/examples/fips_validation/main.c
+++ b/examples/fips_validation/main.c
@@ -1053,6 +1053,7 @@ fips_mct_tdes_test(void)
uint8_t prev_in[TDES_BLOCK_SIZE] = {0};
uint32_t i, j, k;
int ret;
+ int test_mode = info.interim_info.tdes_data.test_mode;
for (i = 0; i < TDES_EXTERN_ITER; i++) {
if (i != 0)
@@ -1079,25 +1080,50 @@ fips_mct_tdes_test(void)
memcpy(prev_out, val.val, TDES_BLOCK_SIZE);
if (info.op == FIPS_TEST_ENC_AUTH_GEN) {
- memcpy(vec.pt.val, vec.iv.val,
- TDES_BLOCK_SIZE);
- memcpy(vec.iv.val, val.val,
- TDES_BLOCK_SIZE);
+ if (test_mode == TDES_MODE_ECB) {
+ memcpy(vec.pt.val, val.val,
+ TDES_BLOCK_SIZE);
+ } else {
+ memcpy(vec.pt.val, vec.iv.val,
+ TDES_BLOCK_SIZE);
+ memcpy(vec.iv.val, val.val,
+ TDES_BLOCK_SIZE);
+ }
+
} else {
- memcpy(vec.iv.val, vec.ct.val,
- TDES_BLOCK_SIZE);
- memcpy(vec.ct.val, val.val,
- TDES_BLOCK_SIZE);
+ if (test_mode == TDES_MODE_ECB) {
+ memcpy(vec.ct.val, val.val,
+ TDES_BLOCK_SIZE);
+ } else {
+ memcpy(vec.iv.val, vec.ct.val,
+ TDES_BLOCK_SIZE);
+ memcpy(vec.ct.val, val.val,
+ TDES_BLOCK_SIZE);
+ }
}
continue;
}
if (info.op == FIPS_TEST_ENC_AUTH_GEN) {
- memcpy(vec.iv.val, val.val, TDES_BLOCK_SIZE);
- memcpy(vec.pt.val, prev_out, TDES_BLOCK_SIZE);
+ if (test_mode == TDES_MODE_ECB) {
+ memcpy(vec.pt.val, val.val,
+ TDES_BLOCK_SIZE);
+ } else {
+ memcpy(vec.iv.val, val.val,
+ TDES_BLOCK_SIZE);
+ memcpy(vec.pt.val, prev_out,
+ TDES_BLOCK_SIZE);
+ }
} else {
- memcpy(vec.iv.val, vec.ct.val, TDES_BLOCK_SIZE);
- memcpy(vec.ct.val, val.val, TDES_BLOCK_SIZE);
+ if (test_mode == TDES_MODE_ECB) {
+ memcpy(vec.ct.val, val.val,
+ TDES_BLOCK_SIZE);
+ } else {
+ memcpy(vec.iv.val, vec.ct.val,
+ TDES_BLOCK_SIZE);
+ memcpy(vec.ct.val, val.val,
+ TDES_BLOCK_SIZE);
+ }
}
if (j == TDES_INTERN_ITER - 1)
@@ -1156,11 +1182,19 @@ fips_mct_tdes_test(void)
val_key.val[k] : (val_key.val[k] ^ 0x1);
if (info.op == FIPS_TEST_ENC_AUTH_GEN) {
- memcpy(vec.iv.val, val.val, TDES_BLOCK_SIZE);
- memcpy(vec.pt.val, prev_out, TDES_BLOCK_SIZE);
+ if (test_mode == TDES_MODE_ECB) {
+ memcpy(vec.pt.val, val.val, TDES_BLOCK_SIZE);
+ } else {
+ memcpy(vec.iv.val, val.val, TDES_BLOCK_SIZE);
+ memcpy(vec.pt.val, prev_out, TDES_BLOCK_SIZE);
+ }
} else {
- memcpy(vec.iv.val, prev_out, TDES_BLOCK_SIZE);
- memcpy(vec.ct.val, val.val, TDES_BLOCK_SIZE);
+ if (test_mode == TDES_MODE_ECB) {
+ memcpy(vec.ct.val, val.val, TDES_BLOCK_SIZE);
+ } else {
+ memcpy(vec.iv.val, prev_out, TDES_BLOCK_SIZE);
+ memcpy(vec.ct.val, val.val, TDES_BLOCK_SIZE);
+ }
}
}