crypto-native: fix build error on Arm using clang-13
[vpp.git] / src / plugins / crypto_native / aes.h
index b914088..0ba4e87 100644 (file)
@@ -43,17 +43,43 @@ aes_enc_round (u8x16 a, u8x16 k)
 {
 #if defined (__AES__)
   return (u8x16) _mm_aesenc_si128 ((__m128i) a, (__m128i) k);
-#elif defined (__ARM_FEATURE_AES)
+#elif defined (__ARM_FEATURE_CRYPTO)
   return vaesmcq_u8 (vaeseq_u8 (a, u8x16_splat (0))) ^ k;
 #endif
 }
 
+#if defined (__VAES__)
+static_always_inline u8x64
+aes_enc_round_x4 (u8x64 a, u8x64 k)
+{
+  return (u8x64) _mm512_aesenc_epi128 ((__m512i) a, (__m512i) k);
+}
+
+static_always_inline u8x64
+aes_enc_last_round_x4 (u8x64 a, u8x64 k)
+{
+  return (u8x64) _mm512_aesenclast_epi128 ((__m512i) a, (__m512i) k);
+}
+
+static_always_inline u8x64
+aes_dec_round_x4 (u8x64 a, u8x64 k)
+{
+  return (u8x64) _mm512_aesdec_epi128 ((__m512i) a, (__m512i) k);
+}
+
+static_always_inline u8x64
+aes_dec_last_round_x4 (u8x64 a, u8x64 k)
+{
+  return (u8x64) _mm512_aesdeclast_epi128 ((__m512i) a, (__m512i) k);
+}
+#endif
+
 static_always_inline u8x16
 aes_enc_last_round (u8x16 a, u8x16 k)
 {
 #if defined (__AES__)
   return (u8x16) _mm_aesenclast_si128 ((__m128i) a, (__m128i) k);
-#elif defined (__ARM_FEATURE_AES)
+#elif defined (__ARM_FEATURE_CRYPTO)
   return vaeseq_u8 (a, u8x16_splat (0)) ^ k;
 #endif
 }
@@ -93,7 +119,7 @@ aes_load_partial (u8x16u * p, int n_bytes)
   __m128i zero = { };
   return (u8x16) _mm_mask_loadu_epi8 (zero, (1 << n_bytes) - 1, p);
 #else
-  return aes_byte_mask (CLIB_MEM_OVERFLOW_LOAD (*, p), n_bytes);
+  return aes_byte_mask (CLIB_MEM_OVERFLOW_LOAD (p), n_bytes);
 #endif
 }
 
@@ -128,7 +154,7 @@ aes_inv_mix_column (u8x16 a)
 {
 #if defined (__AES__)
   return (u8x16) _mm_aesimc_si128 ((__m128i) a);
-#elif defined (__ARM_FEATURE_AES)
+#elif defined (__ARM_FEATURE_CRYPTO)
   return vaesimcq_u8 (a);
 #endif
 }
@@ -152,7 +178,7 @@ aes128_key_assist (u8x16 * rk, u8x16 r)
 }
 
 static_always_inline void
-aes128_key_expand (u8x16 * rk, u8x16 const *k)
+aes128_key_expand (u8x16 *rk, u8x16u const *k)
 {
   rk[0] = k[0];
   aes128_key_assist (rk + 1, aes_keygen_assist (rk[0], 0x01));
@@ -282,7 +308,7 @@ aes128_key_expand_round_neon (u8x16 * rk, u32 rcon)
 }
 
 static_always_inline void
-aes128_key_expand (u8x16 * rk, const u8x16 * k)
+aes128_key_expand (u8x16 *rk, u8x16u const *k)
 {
   rk[0] = k[0];
   aes128_key_expand_round_neon (rk + 1, 0x01);
@@ -359,7 +385,7 @@ aes256_key_expand_round_neon (u8x16 * rk, u32 rcon)
 }
 
 static_always_inline void
-aes256_key_expand (u8x16 * rk, u8x16 const *k)
+aes256_key_expand (u8x16 *rk, u8x16u const *k)
 {
   rk[0] = k[0];
   rk[1] = k[1];