[3/8] examples/fips_validation: initialize IV for AES-GCM
Checks
Commit Message
From: Michael Shamis <michaelsh@marvell.com>
Configurated AES-GCM IV may include only salt value which length
is 12B. In this case driver should set second part of IV to
initial value = 0x1.
Signed-off-by: Michael Shamis <michaelsh@marvell.com>
---
examples/fips_validation/main.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
@@ -25,6 +25,7 @@
#define CRYPTODEV_BK_DIR_KEY "broken-test-dir"
#define CRYPTODEV_ENC_KEYWORD "enc"
#define CRYPTODEV_DEC_KEYWORD "dec"
+#define IV_SALT_LEN 12
struct fips_test_vector vec;
struct fips_test_interim_info info;
@@ -580,10 +581,16 @@ prepare_aead_op(void)
__rte_crypto_op_reset(env.op, RTE_CRYPTO_OP_TYPE_SYMMETRIC);
rte_pktmbuf_reset(env.mbuf);
- if (info.algo == FIPS_TEST_ALGO_AES_CCM)
+ if (info.algo == FIPS_TEST_ALGO_AES_CCM) {
memcpy(iv + 1, vec.iv.val, vec.iv.len);
- else
+ } else {
memcpy(iv, vec.iv.val, vec.iv.len);
+ /* Set initial IV if specified only salt IV value */
+ if (vec.iv.len == IV_SALT_LEN) {
+ memset(&iv[vec.iv.len], 0, 4);
+ iv[vec.iv.len + 3] = 1;
+ }
+ }
sym->m_src = env.mbuf;
sym->aead.data.offset = 0;