1
0
mirror of https://github.com/veracrypt/VeraCrypt.git synced 2025-11-12 11:28:26 -06:00

Windows/Linux/macOS: implement AES hardware support on ARM64 (ARMv8)

This commit is contained in:
Mounir IDRASSI
2025-01-17 00:58:54 +01:00
parent c79f8102e0
commit 54bd819990
22 changed files with 492 additions and 49 deletions

View File

@@ -1164,8 +1164,6 @@ BOOL IsAesHwCpuSupported ()
}
return state && !HwEncryptionDisabled;
#elif defined (_M_ARM64) || defined(__arm__) || defined (__arm64__) || defined (__aarch64__)
return 0;
#else
return (HasAESNI() && !HwEncryptionDisabled)? TRUE : FALSE;
#endif
@@ -1483,29 +1481,3 @@ void VcUnprotectKeys (PCRYPTO_INFO pCryptoInfo, uint64 encID)
#endif
#if defined(_M_ARM64) || defined(__arm__) || defined (__arm64__) || defined (__aarch64__)
/* dummy implementation that should never be called */
void aes_hw_cpu_decrypt(const uint8* ks, uint8* data)
{
ks = ks;
data = data;
}
void aes_hw_cpu_decrypt_32_blocks(const uint8* ks, uint8* data)
{
ks = ks;
data = data;
}
void aes_hw_cpu_encrypt(const uint8* ks, uint8* data)
{
ks = ks;
data = data;
}
void aes_hw_cpu_encrypt_32_blocks(const uint8* ks, uint8* data)
{
ks = ks;
data = data;
}
#endif

View File

@@ -1046,7 +1046,7 @@ BOOL IsOSVersionAtLeast (OSVersionEnum reqMinOS, int reqMinServicePack)
>= (major << 16 | minor << 8 | reqMinServicePack));
}
BOOL IsWin10BuildAtLeast(DWORD minBuild)
BOOL IsWin10BuildAtLeast(int minBuild)
{
// Must first be recognized as Windows 10 or higher
if (nCurrentOS < WIN_10)
@@ -14883,6 +14883,7 @@ void GetAppRandomSeed (unsigned char* pbRandSeed, size_t cbRandSeed)
}
}
#ifndef _M_ARM64
// use RDSEED or RDRAND from CPU as source of entropy if enabled
if ( IsCpuRngEnabled() &&
( (HasRDSEED() && RDSEED_getBytes (digest, sizeof (digest)))
@@ -14891,6 +14892,7 @@ void GetAppRandomSeed (unsigned char* pbRandSeed, size_t cbRandSeed)
{
WHIRLPOOL_add (digest, sizeof(digest), &tctx);
}
#endif
WHIRLPOOL_finalize (&tctx, digest);
count = VC_MIN (cbRandSeed, sizeof (digest));

View File

@@ -503,7 +503,7 @@ void Debug (char *format, ...);
void DebugMsgBox (char *format, ...);
BOOL IsOSAtLeast (OSVersionEnum reqMinOS);
BOOL IsOSVersionAtLeast (OSVersionEnum reqMinOS, int reqMinServicePack);
BOOL IsWin10BuildAtLeast(DWORD minBuild);
BOOL IsWin10BuildAtLeast(int minBuild);
BOOL IsSupportedOS ();
BOOL Is64BitOs ();
BOOL IsARM();

View File

@@ -878,6 +878,7 @@ BOOL SlowPoll (void)
}
}
#ifndef _M_ARM64
// use RDSEED or RDRAND from CPU as source of entropy if present
if ( IsCpuRngEnabled() &&
( (HasRDSEED() && RDSEED_getBytes (buffer, sizeof (buffer)))
@@ -886,6 +887,7 @@ BOOL SlowPoll (void)
{
RandaddBuf (buffer, sizeof (buffer));
}
#endif
burn(buffer, sizeof (buffer));
@@ -1011,6 +1013,7 @@ BOOL FastPoll (void)
return FALSE;
}
#ifndef _M_ARM64
// use RDSEED or RDRAND from CPU as source of entropy if enabled
if ( IsCpuRngEnabled() &&
( (HasRDSEED() && RDSEED_getBytes (buffer, sizeof (buffer)))
@@ -1019,6 +1022,7 @@ BOOL FastPoll (void)
{
RandaddBuf (buffer, sizeof (buffer));
}
#endif
burn (buffer, sizeof(buffer));

View File

@@ -1490,7 +1490,9 @@ BOOL AutoTestAlgorithms (void)
{
/* unexepected exception raised. Disable all CPU extended feature and try again */
EnableHwEncryption (hwEncryptionEnabled);
#ifndef _M_ARM64
DisableCPUExtendedFeatures ();
#endif
__try
{
result = DoAutoTestAlgorithms();