1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-01 19:42:48 -05:00

Support hardware SHA-256 and SHA-1 on Arm platforms.

Similarly to my recent addition of NEON-accelerated AES, these new
implementations drop in alongside the SHA-NI ones, under a different
set of ifdefs. All the details of selection and detection are
essentially the same as they were for the AES code.
This commit is contained in:
Simon Tatham
2019-01-23 07:27:12 +00:00
parent cbbd464fd7
commit dc2fdb8acf
5 changed files with 511 additions and 0 deletions

View File

@ -16,6 +16,28 @@ bool platform_aes_hw_available(void)
#endif
}
bool platform_sha256_hw_available(void)
{
#if defined HWCAP_SHA2
return getauxval(AT_HWCAP) & HWCAP_SHA2;
#elif defined HWCAP2_SHA2
return getauxval(AT_HWCAP2) & HWCAP2_SHA2;
#else
return false;
#endif
}
bool platform_sha1_hw_available(void)
{
#if defined HWCAP_SHA1
return getauxval(AT_HWCAP) & HWCAP_SHA1;
#elif defined HWCAP2_SHA1
return getauxval(AT_HWCAP2) & HWCAP2_SHA1;
#else
return false;
#endif
}
#else
bool platform_aes_hw_available(void)
@ -23,4 +45,14 @@ bool platform_aes_hw_available(void)
return false;
}
bool platform_sha256_hw_available(void)
{
return false;
}
bool platform_sha1_hw_available(void)
{
return false;
}
#endif