1
0
mirror of https://github.com/veracrypt/VeraCrypt.git synced 2025-11-11 11:08:02 -06:00

Linux: fix NOASM compilation (#563) (#568)

Signed-off-by: alt3r 3go <alt3r.3go@protonmail.com>
This commit is contained in:
alt3r 3go
2019-12-09 17:43:33 +01:00
committed by Mounir IDRASSI
parent 07bb27e3b9
commit 0364a36f84
9 changed files with 22 additions and 21 deletions

View File

@@ -252,7 +252,7 @@ void EncipherBlocks (int cipher, void *dataPtr, void *ks, size_t blockCount)
#endif #endif
} }
#endif #endif
#if CRYPTOPP_BOOL_X64 #if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM)
else if (cipher == TWOFISH) { else if (cipher == TWOFISH) {
twofish_encrypt_blocks(ks, data, data, (uint32) blockCount); twofish_encrypt_blocks(ks, data, data, (uint32) blockCount);
} }
@@ -369,7 +369,7 @@ void DecipherBlocks (int cipher, void *dataPtr, void *ks, size_t blockCount)
#endif #endif
} }
#endif #endif
#if CRYPTOPP_BOOL_X64 #if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM)
else if (cipher == TWOFISH) { else if (cipher == TWOFISH) {
twofish_decrypt_blocks(ks, data, data, (uint32) blockCount); twofish_decrypt_blocks(ks, data, data, (uint32) blockCount);
} }
@@ -464,7 +464,7 @@ BOOL CipherSupportsIntraDataUnitParallelization (int cipher)
|| (cipher == SERPENT && HasSSE2()) || (cipher == SERPENT && HasSSE2())
|| (cipher == KUZNYECHIK && HasSSE2()) || (cipher == KUZNYECHIK && HasSSE2())
#endif #endif
#if CRYPTOPP_BOOL_X64 #if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM)
|| (cipher == TWOFISH) || (cipher == TWOFISH)
|| (cipher == CAMELLIA) || (cipher == CAMELLIA)
#endif #endif

View File

@@ -3,7 +3,7 @@
#include "Crypto/cpu.h" #include "Crypto/cpu.h"
#include "Crypto/misc.h" #include "Crypto/misc.h"
#if CRYPTOPP_BOOL_X64 #if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM)
/* camellia.c ver 1.2.0-x86_64_asm1.1 /* camellia.c ver 1.2.0-x86_64_asm1.1
* *

View File

@@ -17,7 +17,7 @@ void camellia_set_key(const unsigned __int8 userKey[], unsigned __int8 *ks);
void camellia_encrypt(const unsigned __int8 *inBlock, unsigned __int8 *outBlock, unsigned __int8 *ks); void camellia_encrypt(const unsigned __int8 *inBlock, unsigned __int8 *outBlock, unsigned __int8 *ks);
void camellia_decrypt(const unsigned __int8 *inBlock, unsigned __int8 *outBlock, unsigned __int8 *ks); void camellia_decrypt(const unsigned __int8 *inBlock, unsigned __int8 *outBlock, unsigned __int8 *ks);
#if CRYPTOPP_BOOL_X64 #if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM)
void camellia_encrypt_blocks(unsigned __int8 *ks, const byte* in_blk, byte* out_blk, uint32 blockCount); void camellia_encrypt_blocks(unsigned __int8 *ks, const byte* in_blk, byte* out_blk, uint32 blockCount);
void camellia_decrypt_blocks(unsigned __int8 *ks, const byte* in_blk, byte* out_blk, uint32 blockCount); void camellia_decrypt_blocks(unsigned __int8 *ks, const byte* in_blk, byte* out_blk, uint32 blockCount);
#endif #endif

View File

@@ -10,7 +10,7 @@ and released into public domain.
#include "Crypto/cpu.h" #include "Crypto/cpu.h"
#include "Crypto/misc.h" #include "Crypto/misc.h"
#ifdef _UEFI #if defined(_UEFI) || defined(CRYPTOPP_DISABLE_ASM)
#define NO_OPTIMIZED_VERSIONS #define NO_OPTIMIZED_VERSIONS
#endif #endif

View File

@@ -22,7 +22,7 @@ extern "C" {
#define SHA512_DIGEST_SIZE 64 #define SHA512_DIGEST_SIZE 64
#define SHA512_BLOCK_SIZE 128 #define SHA512_BLOCK_SIZE 128
#if CRYPTOPP_BOOL_X64 #if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM)
#define SHA2_ALIGN CRYPTOPP_ALIGN_DATA(32) #define SHA2_ALIGN CRYPTOPP_ALIGN_DATA(32)
#else #else
#define SHA2_ALIGN CRYPTOPP_ALIGN_DATA(16) #define SHA2_ALIGN CRYPTOPP_ALIGN_DATA(16)

View File

@@ -54,7 +54,7 @@
#define UNROLL_TWOFISH #define UNROLL_TWOFISH
#endif #endif
#if CRYPTOPP_BOOL_X64 #if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM)
/* these are 64-bit assembly implementation taken from https://github.com/jkivilin/supercop-blockciphers /* these are 64-bit assembly implementation taken from https://github.com/jkivilin/supercop-blockciphers
Copyright © 2011-2013 Jussi Kivilinna <jussi.kivilinna@iki.fi> Copyright © 2011-2013 Jussi Kivilinna <jussi.kivilinna@iki.fi>
@@ -630,7 +630,7 @@ void twofish_set_key(TwofishInstance *instance, const u4byte in_key[])
uint32 b = rotl32(MDSQ[0][Q[0][Q[0][Q[1][Q[1][i + 1] ^ key[28]] ^ key[20]] ^ key[12]] ^ key[4]] ^ MDSQ[1][Q[0][Q[1][Q[1][Q[0][i + 1] ^ key[29]] ^ key[21]] ^ key[13]] ^ key[5]] uint32 b = rotl32(MDSQ[0][Q[0][Q[0][Q[1][Q[1][i + 1] ^ key[28]] ^ key[20]] ^ key[12]] ^ key[4]] ^ MDSQ[1][Q[0][Q[1][Q[1][Q[0][i + 1] ^ key[29]] ^ key[21]] ^ key[13]] ^ key[5]]
^ MDSQ[2][Q[1][Q[0][Q[0][Q[0][i + 1] ^ key[30]] ^ key[22]] ^ key[14]] ^ key[6]] ^ MDSQ[3][Q[1][Q[1][Q[0][Q[1][i + 1] ^ key[31]] ^ key[23]] ^ key[15]] ^ key[7]], 8); ^ MDSQ[2][Q[1][Q[0][Q[0][Q[0][i + 1] ^ key[30]] ^ key[22]] ^ key[14]] ^ key[6]] ^ MDSQ[3][Q[1][Q[1][Q[0][Q[1][i + 1] ^ key[31]] ^ key[23]] ^ key[15]] ^ key[7]], 8);
a += b; a += b;
#if CRYPTOPP_BOOL_X64 #if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM)
if (i < 8) if (i < 8)
{ {
instance->w[i] = a; instance->w[i] = a;
@@ -998,7 +998,7 @@ void twofish_set_key(TwofishInstance *instance, const u4byte in_key[])
#ifndef TC_MINIMIZE_CODE_SIZE #ifndef TC_MINIMIZE_CODE_SIZE
#if (CRYPTOPP_BOOL_X64 == 0) #if (CRYPTOPP_BOOL_X64 == 0) || defined(CRYPTOPP_DISABLE_ASM)
void twofish_encrypt(TwofishInstance *ks, const u4byte in_blk[4], u4byte out_blk[4]) void twofish_encrypt(TwofishInstance *ks, const u4byte in_blk[4], u4byte out_blk[4])
{ {
uint32* rk = ks->l_key; uint32* rk = ks->l_key;
@@ -1071,7 +1071,7 @@ void twofish_encrypt(TwofishInstance *instance, const u4byte in_blk[4], u4byte o
#ifndef TC_MINIMIZE_CODE_SIZE #ifndef TC_MINIMIZE_CODE_SIZE
#if (CRYPTOPP_BOOL_X64 == 0) #if (CRYPTOPP_BOOL_X64 == 0) || defined(CRYPTOPP_DISABLE_ASM)
void twofish_decrypt(TwofishInstance *ks, const u4byte in_blk[4], u4byte out_blk[4]) void twofish_decrypt(TwofishInstance *ks, const u4byte in_blk[4], u4byte out_blk[4])
{ {
uint32* rk = ks->l_key; uint32* rk = ks->l_key;

View File

@@ -35,7 +35,7 @@ extern "C"
#endif #endif
typedef struct typedef struct
{ {
#if CRYPTOPP_BOOL_X64 #if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM)
u4byte mk_tab[4][256], w[8], k[32]; u4byte mk_tab[4][256], w[8], k[32];
#else #else
u4byte l_key[40]; u4byte l_key[40];
@@ -54,7 +54,7 @@ typedef struct
/* in_key must be 32-bytes long */ /* in_key must be 32-bytes long */
void twofish_set_key(TwofishInstance *instance, const u4byte in_key[]); void twofish_set_key(TwofishInstance *instance, const u4byte in_key[]);
#if CRYPTOPP_BOOL_X64 #if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM)
void twofish_encrypt_blocks(TwofishInstance *instance, const byte* in_blk, byte* out_blk, uint32 blockCount); void twofish_encrypt_blocks(TwofishInstance *instance, const byte* in_blk, byte* out_blk, uint32 blockCount);
void twofish_decrypt_blocks(TwofishInstance *instance, const byte* in_blk, byte* out_blk, uint32 blockCount); void twofish_decrypt_blocks(TwofishInstance *instance, const byte* in_blk, byte* out_blk, uint32 blockCount);
#define twofish_encrypt(instance,in_blk,out_blk) twofish_encrypt_blocks(instance, (const byte*) in_blk, (byte*) out_blk, 1) #define twofish_encrypt(instance,in_blk,out_blk) twofish_encrypt_blocks(instance, (const byte*) in_blk, (byte*) out_blk, 1)

View File

@@ -151,6 +151,7 @@ endif
ifeq "$(origin NOASM)" "command line" ifeq "$(origin NOASM)" "command line"
CPU_ARCH = unknown CPU_ARCH = unknown
C_CXX_FLAGS += -DCRYPTOPP_DISABLE_X86ASM
endif endif
ifeq "$(CPU_ARCH)" "x86" ifeq "$(CPU_ARCH)" "x86"

View File

@@ -247,7 +247,7 @@ namespace VeraCrypt
if (!Initialized) if (!Initialized)
throw NotInitialized (SRC_POS); throw NotInitialized (SRC_POS);
#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && !defined(CRYPTOPP_DISABLE_ASM)
if ((blockCount >= 4) if ((blockCount >= 4)
&& IsHwSupportAvailable()) && IsHwSupportAvailable())
{ {
@@ -263,7 +263,7 @@ namespace VeraCrypt
if (!Initialized) if (!Initialized)
throw NotInitialized (SRC_POS); throw NotInitialized (SRC_POS);
#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && !defined(CRYPTOPP_DISABLE_ASM)
if ((blockCount >= 4) if ((blockCount >= 4)
&& IsHwSupportAvailable()) && IsHwSupportAvailable())
{ {
@@ -318,7 +318,7 @@ namespace VeraCrypt
if (!Initialized) if (!Initialized)
throw NotInitialized (SRC_POS); throw NotInitialized (SRC_POS);
#if CRYPTOPP_BOOL_X64 #if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM)
twofish_encrypt_blocks ( (TwofishInstance *) ScheduledKey.Ptr(), data, data, blockCount); twofish_encrypt_blocks ( (TwofishInstance *) ScheduledKey.Ptr(), data, data, blockCount);
#else #else
Cipher::EncryptBlocks (data, blockCount); Cipher::EncryptBlocks (data, blockCount);
@@ -330,7 +330,7 @@ namespace VeraCrypt
if (!Initialized) if (!Initialized)
throw NotInitialized (SRC_POS); throw NotInitialized (SRC_POS);
#if CRYPTOPP_BOOL_X64 #if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM)
twofish_decrypt_blocks ( (TwofishInstance *) ScheduledKey.Ptr(), data, data, blockCount); twofish_decrypt_blocks ( (TwofishInstance *) ScheduledKey.Ptr(), data, data, blockCount);
#else #else
Cipher::DecryptBlocks (data, blockCount); Cipher::DecryptBlocks (data, blockCount);
@@ -339,7 +339,7 @@ namespace VeraCrypt
bool CipherTwofish::IsHwSupportAvailable () const bool CipherTwofish::IsHwSupportAvailable () const
{ {
#if CRYPTOPP_BOOL_X64 #if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM)
return true; return true;
#else #else
return false; return false;
@@ -372,7 +372,7 @@ namespace VeraCrypt
if (!Initialized) if (!Initialized)
throw NotInitialized (SRC_POS); throw NotInitialized (SRC_POS);
#if CRYPTOPP_BOOL_X64 #if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM)
camellia_encrypt_blocks ( ScheduledKey.Ptr(), data, data, blockCount); camellia_encrypt_blocks ( ScheduledKey.Ptr(), data, data, blockCount);
#else #else
Cipher::EncryptBlocks (data, blockCount); Cipher::EncryptBlocks (data, blockCount);
@@ -384,7 +384,7 @@ namespace VeraCrypt
if (!Initialized) if (!Initialized)
throw NotInitialized (SRC_POS); throw NotInitialized (SRC_POS);
#if CRYPTOPP_BOOL_X64 #if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM)
camellia_decrypt_blocks ( ScheduledKey.Ptr(), data, data, blockCount); camellia_decrypt_blocks ( ScheduledKey.Ptr(), data, data, blockCount);
#else #else
Cipher::DecryptBlocks (data, blockCount); Cipher::DecryptBlocks (data, blockCount);
@@ -393,7 +393,7 @@ namespace VeraCrypt
bool CipherCamellia::IsHwSupportAvailable () const bool CipherCamellia::IsHwSupportAvailable () const
{ {
#if CRYPTOPP_BOOL_X64 #if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM)
return true; return true;
#else #else
return false; return false;