aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2020-09-15 11:05:23 +0200
committerDamjan Marion <damarion@cisco.com>2020-09-15 11:05:50 +0200
commit139a6ae0dd460a6b8a5884e65cfd96f0c409f69e (patch)
treeff1eee293d42e25ec25e0f9f63f6b748f00d322f /src/plugins
parent466872f0896139b34ef8ccf12f7fcc0093d7cb19 (diff)
crypto-native: fix issues detected by coiverity
Type: fix Change-Id: Id61aa407eeeb4d44cf47ed39283a0c79ed3abbee Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/crypto_native/aes_gcm.c10
-rw-r--r--src/plugins/crypto_native/crypto_native.h4
2 files changed, 11 insertions, 3 deletions
diff --git a/src/plugins/crypto_native/aes_gcm.c b/src/plugins/crypto_native/aes_gcm.c
index 9aeed9dee2e..e0c1e6c12c3 100644
--- a/src/plugins/crypto_native/aes_gcm.c
+++ b/src/plugins/crypto_native/aes_gcm.c
@@ -63,6 +63,7 @@ typedef enum
static const u32x4 ctr_inv_1 = { 0, 0, 0, 1 << 24 };
+#ifndef __VAES__
static_always_inline void
aes_gcm_enc_first_round (u8x16 * r, aes_gcm_counter_t * ctr, u8x16 k,
int n_blocks)
@@ -106,6 +107,7 @@ aes_gcm_enc_last_round (u8x16 * r, u8x16 * d, u8x16 const *k,
for (int i = 0; i < n_blocks; i++)
d[i] ^= aes_enc_last_round (r[i], k[rounds]);
}
+#endif
static_always_inline u8x16
aes_gcm_ghash_blocks (u8x16 T, aes_gcm_key_data_t * kd,
@@ -161,6 +163,7 @@ aes_gcm_ghash (u8x16 T, aes_gcm_key_data_t * kd, u8x16u * in, u32 n_left)
return T;
}
+#ifndef __VAES__
static_always_inline u8x16
aes_gcm_calc (u8x16 T, aes_gcm_key_data_t * kd, u8x16 * d,
aes_gcm_counter_t * ctr, u8x16u * inv, u8x16u * outv,
@@ -414,6 +417,7 @@ aes_gcm_ghash_last (u8x16 T, aes_gcm_key_data_t * kd, u8x16 * d,
ghash_reduce2 (gd);
return ghash_final (gd);
}
+#endif
#ifdef __VAES__
static const u32x16 ctr_inv_1234 = {
@@ -748,7 +752,6 @@ static_always_inline u8x16
aes_gcm_enc (u8x16 T, aes_gcm_key_data_t * kd, aes_gcm_counter_t * ctr,
u8x16u * inv, u8x16u * outv, u32 n_left, int rounds)
{
- u8x16 d[4];
aes_gcm_flags_t f = AES_GCM_F_ENCRYPT;
if (n_left == 0)
@@ -841,8 +844,8 @@ aes_gcm_enc (u8x16 T, aes_gcm_key_data_t * kd, aes_gcm_counter_t * ctr,
T = aes4_gcm_calc (T, kd, d4, ctr, inv, outv, rounds, 1, n_left, f);
return aes4_gcm_ghash_last (T, kd, d4, 1, n_left);
-#endif
-
+#else
+ u8x16 d[4];
if (n_left < 64)
{
f |= AES_GCM_F_LAST_ROUND;
@@ -928,6 +931,7 @@ aes_gcm_enc (u8x16 T, aes_gcm_key_data_t * kd, aes_gcm_counter_t * ctr,
T = aes_gcm_calc (T, kd, d, ctr, inv, outv, rounds, 1, n_left, f);
return aes_gcm_ghash_last (T, kd, d, 1, n_left);
+#endif
}
static_always_inline u8x16
diff --git a/src/plugins/crypto_native/crypto_native.h b/src/plugins/crypto_native/crypto_native.h
index f1153737dea..5b774b302de 100644
--- a/src/plugins/crypto_native/crypto_native.h
+++ b/src/plugins/crypto_native/crypto_native.h
@@ -23,7 +23,11 @@ typedef void *(crypto_native_key_fn_t) (vnet_crypto_key_t * key);
typedef struct
{
CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
+#if __VAES__
+ u8x16 cbc_iv[16];
+#else
u8x16 cbc_iv[4];
+#endif
} crypto_native_per_thread_data_t;
typedef struct