From 4a8f068ba559ceb597fb8b417a08c8fc96088aa4 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Sun, 8 Sep 2024 17:14:31 +0200 Subject: Windows: Add support for x86 and x64 build for driver and binaries using Visual Studio 2019 We also enable Control Flow Guard and Spectre Mitigation --- src/Crypto/Aes.h | 4 ++-- src/Crypto/Aes_hw_cpu.h | 4 ++-- src/Crypto/Aescrypt.c | 4 ++-- src/Crypto/Crypto_vs2019.vcxproj | 30 ++++++++++++++++++------------ src/Crypto/Sha2.c | 4 ++-- 5 files changed, 26 insertions(+), 20 deletions(-) (limited to 'src/Crypto') diff --git a/src/Crypto/Aes.h b/src/Crypto/Aes.h index db1bed27..dcadfc2b 100644 --- a/src/Crypto/Aes.h +++ b/src/Crypto/Aes.h @@ -139,7 +139,7 @@ AES_RETURN aes_encrypt_key256(const unsigned char *key, aes_encrypt_ctx cx[1]); AES_RETURN aes_encrypt_key(const unsigned char *key, int key_len, aes_encrypt_ctx cx[1]); #endif -AES_RETURN aes_encrypt(const unsigned char *in, unsigned char *out, const aes_encrypt_ctx cx[1]); +AES_RETURN VC_CDECL aes_encrypt(const unsigned char *in, unsigned char *out, const aes_encrypt_ctx cx[1]); #endif @@ -161,7 +161,7 @@ AES_RETURN aes_decrypt_key256(const unsigned char *key, aes_decrypt_ctx cx[1]); AES_RETURN aes_decrypt_key(const unsigned char *key, int key_len, aes_decrypt_ctx cx[1]); #endif -AES_RETURN aes_decrypt(const unsigned char *in, unsigned char *out, const aes_decrypt_ctx cx[1]); +AES_RETURN VC_CDECL aes_decrypt(const unsigned char *in, unsigned char *out, const aes_decrypt_ctx cx[1]); #endif diff --git a/src/Crypto/Aes_hw_cpu.h b/src/Crypto/Aes_hw_cpu.h index 58adc78d..face0a0c 100644 --- a/src/Crypto/Aes_hw_cpu.h +++ b/src/Crypto/Aes_hw_cpu.h @@ -25,9 +25,9 @@ uint8 is_aes_hw_cpu_supported (); #endif void aes_hw_cpu_enable_sse (); void aes_hw_cpu_decrypt (const uint8 *ks, uint8 *data); -void aes_hw_cpu_decrypt_32_blocks (const uint8 *ks, uint8 *data); +void VC_CDECL aes_hw_cpu_decrypt_32_blocks (const uint8 *ks, uint8 *data); void aes_hw_cpu_encrypt (const uint8 *ks, uint8 *data); -void aes_hw_cpu_encrypt_32_blocks (const uint8 *ks, uint8 *data); +void VC_CDECL aes_hw_cpu_encrypt_32_blocks (const uint8 *ks, uint8 *data); #if defined(__cplusplus) } diff --git a/src/Crypto/Aescrypt.c b/src/Crypto/Aescrypt.c index 46175981..7348e2cf 100644 --- a/src/Crypto/Aescrypt.c +++ b/src/Crypto/Aescrypt.c @@ -94,7 +94,7 @@ extern "C" #define fwd_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ no_table(x,t_use(s,box),fwd_var,rf1,c)) #endif -AES_RETURN aes_encrypt(const unsigned char *in, unsigned char *out, const aes_encrypt_ctx cx[1]) +AES_RETURN VC_CDECL aes_encrypt(const unsigned char *in, unsigned char *out, const aes_encrypt_ctx cx[1]) { uint_32t locals(b0, b1); const uint_32t *kp; #if defined( dec_fmvars ) @@ -231,7 +231,7 @@ AES_RETURN aes_encrypt(const unsigned char *in, unsigned char *out, const aes_en #define rnd_key(n) (kp - n * N_COLS) #endif -AES_RETURN aes_decrypt(const unsigned char *in, unsigned char *out, const aes_decrypt_ctx cx[1]) +AES_RETURN VC_CDECL aes_decrypt(const unsigned char *in, unsigned char *out, const aes_decrypt_ctx cx[1]) { uint_32t locals(b0, b1); #if defined( dec_imvars ) dec_imvars; /* declare variables for inv_mcol() if needed */ diff --git a/src/Crypto/Crypto_vs2019.vcxproj b/src/Crypto/Crypto_vs2019.vcxproj index ccd512b9..ab3d5f3b 100644 --- a/src/Crypto/Crypto_vs2019.vcxproj +++ b/src/Crypto/Crypto_vs2019.vcxproj @@ -38,6 +38,7 @@ StaticLibrary Unicode v142 + Spectre StaticLibrary @@ -48,11 +49,13 @@ StaticLibrary Unicode v142 + Spectre StaticLibrary Unicode v142 + Spectre StaticLibrary @@ -94,18 +97,18 @@ <_ProjectFileVersion>10.0.40219.1 - Debug\ - Debug\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - Release\ - Release\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(ProjectDir)$(ConfigurationName)\ + $(ProjectDir)$(ConfigurationName)\ + $(ProjectDir)$(Platform)\$(Configuration)\ + $(ProjectDir)$(Platform)\$(Configuration)\ + $(ProjectDir)$(Platform)\$(Configuration)\ + $(ProjectDir)$(Platform)\$(Configuration)\ + $(ProjectDir)$(ConfigurationName)\ + $(ProjectDir)$(ConfigurationName)\ + $(ProjectDir)$(Platform)\$(Configuration)\ + $(ProjectDir)$(Platform)\$(Configuration)\ + $(ProjectDir)$(Platform)\$(Configuration)\ + $(ProjectDir)$(Platform)\$(Configuration)\ @@ -182,6 +185,7 @@ Level4 ProgramDatabase 4100;4127;4201;%(DisableSpecificWarnings) + Guard $(OutDir)Crypto.lib @@ -205,6 +209,7 @@ Level4 ProgramDatabase 4100;4127;4201;%(DisableSpecificWarnings) + Guard $(OutDir)Crypto.lib @@ -226,6 +231,7 @@ Level4 ProgramDatabase 4100;4127;4201;%(DisableSpecificWarnings) + Guard $(OutDir)Crypto.lib diff --git a/src/Crypto/Sha2.c b/src/Crypto/Sha2.c index 42215c89..3cce21d7 100644 --- a/src/Crypto/Sha2.c +++ b/src/Crypto/Sha2.c @@ -27,7 +27,7 @@ extern "C" #endif #if CRYPTOPP_BOOL_X64 || ((CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32) && !defined (TC_MACOSX)) - void sha512_compress_nayuki(uint_64t state[8], const uint_8t block[128]); + void VC_CDECL sha512_compress_nayuki(uint_64t state[8], const uint_8t block[128]); #endif #if defined(__cplusplus) } @@ -309,7 +309,7 @@ extern "C" #endif #if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 - void sha256_compress_nayuki(uint_32t state[8], const uint_8t block[64]); + void VC_CDECL sha256_compress_nayuki(uint_32t state[8], const uint_8t block[64]); #endif #if defined(__cplusplus) -- cgit v1.2.3