Add separate accelerated() function for AES::GMAC.

This commit is contained in:
Adam Ierymenko 2020-07-29 21:52:07 -07:00
parent 7efaab2af1
commit 3b773da8bc
No known key found for this signature in database
GPG key ID: C8877CF2D7A5D7F3
3 changed files with 18 additions and 2 deletions

View file

@ -47,7 +47,7 @@ ZT_INLINE uint8x16_t s_clmul_armneon_crypto(uint8x16_t a8, const uint8x16_t y, c
return vrbitq_u8(veorq_u8(r0, t0));
}
#endif
#endif // ZT_AES_NEON
#ifdef ZT_HAVE_UINT128

View file

@ -149,6 +149,22 @@ public:
friend class GMACSIVDecryptor;
public:
/**
* @return True if this system has hardware GMAC acceleration
*/
static ZT_INLINE bool accelerated()
{
#ifdef ZT_AES_AESNI
return Utils::CPUID.aes;
#else
#ifdef ZT_AES_NEON
return Utils::ARMCAP.pmull;
#else
return false;
#endif
#endif
}
/**
* Create a new instance of GMAC (must be initialized with init() before use)
*

View file

@ -1115,7 +1115,7 @@ extern "C" const char *ZTT_crypto()
{
uint8_t tag[16];
ZT_T_PRINTF("[crypto] Testing AES-GMAC (hardware acceleration: %s)... ", AES::accelerated() ? "enabled" : "disabled");
ZT_T_PRINTF("[crypto] Testing AES-GMAC (hardware acceleration: %s)... ", AES::GMAC::accelerated() ? "enabled" : "disabled");
{
AES aes(AES_GMAC_VECTOR_0_KEY);
AES::GMAC gmac(aes);