AES-GCM: MSVC use generated assembly instead of inline

AES-GCM for MSVC was using inline assembly.
Add MSVC version of AES-GCM assembly and use it instead.
Removed inline assembly.
This commit is contained in:
Sean Parkinson 2023-02-16 09:56:36 +10:00
parent c7b4bb1b27
commit 397537e691
13 changed files with 15830 additions and 1483 deletions

@ -40,7 +40,7 @@ The folder hierarchy is the same as the wolfSSL folders with an exception of the
4. Right click on each folders, add or link all the source code in the corresponding folder in wolfSSL.
5. Remove non-C platform dependent files from your build. At the moment, only aes_asm.asm and aes_asm.s must be removed from your wolfssl/wolfcrypt/src folder.
5. Remove non-C platform dependent files from your build. At the moment, only aes_asm.asm, aes_gcm_asm.asm and aes_asm.s must be removed from your wolfssl/wolfcrypt/src folder.
6. In your C/C++ compiler preprocessor settings, add the wolfSSL directories to your include paths.
Here's an example of the paths that must be added.

@ -46,6 +46,7 @@
#define HAVE_SECURE_RENEGOTIATION
#define HAVE_AESGCM
#define WOLFSSL_AESGCM_STREAM
#define WOLFSSL_SHA384
#define WOLFSSL_SHA512
@ -56,12 +57,19 @@
#define ECC_SHAMIR
#define ECC_TIMING_RESISTANT
#define WOLFSSL_SP_X86_64
#define SP_INT_BITS 4096
/* Optional Performance Speedups */
#if 0
/* AESNI on x64 */
#ifdef _WIN64
#define HAVE_INTEL_RDSEED
#define WOLFSSL_AESNI
#define HAVE_INTEL_AVX1
#if 0
#define HAVE_INTEL_AVX2
#endif
#endif
/* Single Precision Support for RSA/DH 1024/2048/3072 and
@ -82,7 +90,6 @@
#define WOLFSSL_SP_X86_64_ASM
#endif
#endif
#else
/* The servers and clients */
#define OPENSSL_EXTRA

@ -51,6 +51,7 @@
#define HAVE_SECURE_RENEGOTIATION
#define HAVE_AESGCM
#define WOLFSSL_AESGCM_STREAM
#define WOLFSSL_SHA384
#define WOLFSSL_SHA512
@ -61,12 +62,19 @@
#define ECC_SHAMIR
#define ECC_TIMING_RESISTANT
#define WOLFSSL_SP_X86_64
#define SP_INT_BITS 4096
/* Optional Performance Speedups */
#if 0
/* AESNI on x64 */
#ifdef _WIN64
#define HAVE_INTEL_RDSEED
#define WOLFSSL_AESNI
#define HAVE_INTEL_AVX1
#if 0
#define HAVE_INTEL_AVX2
#endif
#endif
/* Single Precision Support for RSA/DH 1024/2048/3072 and

@ -331,6 +331,22 @@
<Outputs Condition="'$(Configuration)|$(Platform)'=='DLL Release|x64'">$(IntDir)%(Filename).obj</Outputs>
</CustomBuild>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="..\..\wolfcrypt\src\aes_gcm_asm.asm">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DLL Debug|x64'">false</ExcludedFromBuild>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">ml64.exe /c /Zi /Fo"$(IntDir)%(Filename).obj" %(Identity)</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='DLL Debug|x64'">ml64.exe /c /Zi /Fo"$(IntDir)%(Filename).obj" %(Identity)</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(IntDir)%(Filename).obj</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='DLL Debug|x64'">$(IntDir)%(Filename).obj</Outputs>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DLL Release|x64'">false</ExcludedFromBuild>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">ml64.exe /c /Zi /Fo"$(IntDir)%(Filename).obj" %(Identity)</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='DLL Release|x64'">ml64.exe /c /Zi /Fo"$(IntDir)%(Filename).obj" %(Identity)</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(IntDir)%(Filename).obj</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='DLL Release|x64'">$(IntDir)%(Filename).obj</Outputs>
</CustomBuild>
</ItemGroup>
<ItemGroup>
<ClInclude Include="user_settings.h" />
</ItemGroup>

@ -307,6 +307,22 @@
<Outputs Condition="'$(Configuration)|$(Platform)'=='DLL Release|x64'">$(IntDir)%(Filename).obj</Outputs>
</CustomBuild>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="..\..\wolfcrypt\src\aes_gcm_asm.asm">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DLL Debug|x64'">false</ExcludedFromBuild>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">ml64.exe /DHAVE_FIPS /DHAVE_FIPS_VERSION=5 /DHAVE_FIPS_VERSION_MINOR=1 /c /Zi /Fo"$(IntDir)%(Filename).obj" %(Identity)</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='DLL Debug|x64'">ml64.exe /DHAVE_FIPS /DHAVE_FIPS_VERSION=5 /DHAVE_FIPS_VERSION_MINOR=1 /c /Zi /Fo"$(IntDir)%(Filename).obj" %(Identity)</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(IntDir)%(Filename).obj</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='DLL Debug|x64'">$(IntDir)%(Filename).obj</Outputs>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DLL Release|x64'">false</ExcludedFromBuild>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">ml64.exe /DHAVE_FIPS /DHAVE_FIPS_VERSION=5 /DHAVE_FIPS_VERSION_MINOR=1 /c /Zi /Fo"$(IntDir)%(Filename).obj" %(Identity)</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='DLL Release|x64'">ml64.exe /DHAVE_FIPS /DHAVE_FIPS_VERSION=5 /DHAVE_FIPS_VERSION_MINOR=1 /c /Zi /Fo"$(IntDir)%(Filename).obj" %(Identity)</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(IntDir)%(Filename).obj</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='DLL Release|x64'">$(IntDir)%(Filename).obj</Outputs>
</CustomBuild>
</ItemGroup>
<ItemGroup>
<ClInclude Include="resource.h" />
<ClInclude Include="user_settings.h" />

@ -9,6 +9,7 @@ src and wolfcrypt directories. Uncheck the following:
```
wolfcrypt/src/aes_asm.asm
wolfcrypt/src/aes_gcm_asm.asm
wolfcrypt/src/aes_asm.s
examples/echoclient/
examples/echoserver/

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

15423
wolfcrypt/src/aes_gcm_asm.asm Normal file

File diff suppressed because it is too large Load Diff

@ -14,6 +14,7 @@ EXTRA_DIST += wolfcrypt/src/misc.c
EXTRA_DIST += wolfcrypt/src/evp.c
EXTRA_DIST += wolfcrypt/src/asm.c
EXTRA_DIST += wolfcrypt/src/aes_asm.asm
EXTRA_DIST += wolfcrypt/src/aes_gcm_asm.asm
EXTRA_DIST += wolfcrypt/src/wc_dsp.c
EXTRA_DIST += wolfcrypt/src/sp_dsp32.c
EXTRA_DIST += wolfcrypt/src/sp_x86_64_asm.asm

@ -618,7 +618,12 @@ This library provides single precision (SP) integer math functions.
while (0)
/* Index of highest bit set. */
#define SP_ASM_HI_BIT_SET_IDX(va, vi) \
vi = _BitScanReverse64(va)
do { \
unsigned long idx; \
_BitScanReverse64(&idx, va); \
vi = idx; \
} \
while (0)
#endif
#if !defined(WOLFSSL_SP_DIV_WORD_HALF) && (!defined(_MSC_VER) || \

@ -20598,7 +20598,7 @@ _text SEGMENT READONLY PARA
sp_2048_lshift_32 PROC
push r12
push r13
mov rcx, r8
mov cl, r8b
mov rax, rcx
mov r12, 0
mov r13, QWORD PTR [rdx+216]
@ -40446,7 +40446,7 @@ _text SEGMENT READONLY PARA
sp_3072_lshift_48 PROC
push r12
push r13
mov rcx, r8
mov cl, r8b
mov rax, rcx
mov r12, 0
mov r13, QWORD PTR [rdx+344]
@ -53973,7 +53973,7 @@ _text SEGMENT READONLY PARA
sp_4096_lshift_64 PROC
push r12
push r13
mov rcx, r8
mov cl, r8b
mov rax, rcx
mov r12, 0
mov r13, QWORD PTR [rdx+472]
@ -67878,7 +67878,7 @@ _text SEGMENT READONLY PARA
sp_521_lshift_9 PROC
push r12
push r13
mov rcx, r8
mov cl, r8b
mov rax, rcx
mov r12, 0
mov r13, QWORD PTR [rdx+32]
@ -67925,7 +67925,7 @@ _text SEGMENT READONLY PARA
sp_521_lshift_18 PROC
push r12
push r13
mov rcx, r8
mov cl, r8b
mov rax, rcx
mov r12, 0
mov r13, QWORD PTR [rdx+104]

@ -362,6 +362,20 @@
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(OutDir)%(Filename).obj</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='DLL Release|x64'">$(IntDir)%(Filename).obj</Outputs>
</CustomBuild>
<CustomBuild Include="wolfcrypt\src\aes_gcm_asm.asm">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DLL Debug|x64'">false</ExcludedFromBuild>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">ml64.exe /c /Zi /Fo"$(OutDir)%(Filename).obj" %(Identity)</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='DLL Debug|x64'">ml64.exe /c /Zi /Fo"$(IntDir)%(Filename).obj" %(Identity)</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)%(Filename).obj</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='DLL Debug|x64'">$(IntDir)%(Filename).obj</Outputs>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DLL Release|x64'">false</ExcludedFromBuild>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">ml64.exe /c /Zi /Fo"$(OutDir)%(Filename).obj" %(Identity)</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='DLL Release|x64'">ml64.exe /c /Zi /Fo"$(IntDir)%(Filename).obj" %(Identity)</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(OutDir)%(Filename).obj</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='DLL Release|x64'">$(IntDir)%(Filename).obj</Outputs>
</CustomBuild>
<CustomBuild Include="wolfcrypt\src\sp_x86_64_asm.asm">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DLL Debug|x64'">false</ExcludedFromBuild>