revert x86 define check, modify makefiles

This commit is contained in:
R4SAS 2020-11-11 02:56:21 +03:00
parent eab9a07e3f
commit 600c7b5b26
8 changed files with 87 additions and 110 deletions

View file

@ -76,7 +76,7 @@ deps: mk_obj_dir
@sed -i -e '/\.o:/ s/^/obj\//' $(DEPS)
obj/%.o: %.cpp
$(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) $(CPU_FLAGS) -c -o $@ $<
$(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) -c -o $@ $<
# '-' is 'ignore if missing' on first run
-include $(DEPS)

View file

@ -35,7 +35,7 @@ endif
# Seems like all recent Mac's have AES-NI, after firmware upgrade 2.2
# Found no good way to detect it from command line. TODO: Might be some osx sysinfo magic
ifeq ($(USE_AESNI),yes)
CXXFLAGS += -maes
CXXFLAGS += -D__AES__
endif
install: all

View file

@ -58,14 +58,7 @@ endif
endif
ifeq ($(USE_AESNI),yes)
ifneq (, $(findstring aarch64, $(SYS)))
CXXFLAGS += -DARM64AES
else
ifeq (, $(findstring arm, $(SYS))) # no arm in dumpmachine
# check if AES-NI is supported by CPU
ifeq ($(shell $(GREP) -c aes /proc/cpuinfo),0)
CPU_FLAGS += -maes
endif
endif
ifeq (, $(findstring arm, $(SYS))$(findstring aarch64, $(SYS)) # no arm and aarch64 in dumpmachine
CXXFLAGS += -D__AES__
endif
endif

View file

@ -53,7 +53,7 @@ ifeq ($(USE_WINXP_FLAGS), yes)
endif
ifeq ($(USE_AESNI),yes)
CPU_FLAGS += -maes
CXXFLAGS += -D__AES__
endif
ifeq ($(USE_ASLR),yes)

View file

@ -22,8 +22,8 @@ ifeq ($(USE_UPNP),yes)
endif
endif
ifeq ($(USE_AESNI),1)
CXXFLAGS += -maes
ifeq ($(USE_AESNI),yes)
CXXFLAGS += -D__AES__
else
CXXFLAGS += -msse
endif

View file

@ -522,7 +522,7 @@ namespace crypto
bn2buf (y, encrypted + len, len);
RAND_bytes (encrypted + 2*len, 256 - 2*len);
}
// ecryption key and iv
// encryption key and iv
EC_POINT_mul (curve, p, nullptr, key, k, ctx);
EC_POINT_get_affine_coordinates_GFp (curve, p, x, y, nullptr);
uint8_t keyBuf[64], iv[64], shared[32];
@ -639,8 +639,6 @@ namespace crypto
uint64_t buf[256];
uint64_t hash[12]; // 96 bytes
#if defined(__x86_64__) || defined(__i386__)
#pragma GCC push_options
#pragma GCC target("avx")
if(i2p::cpu::avx)
{
__asm__
@ -663,7 +661,6 @@ namespace crypto
);
}
else
#pragma GCC pop_options
#endif
{
// ikeypad
@ -698,14 +695,7 @@ namespace crypto
}
// AES
#if defined(__x86_64__) || defined(__i386__)
#ifdef ARM64AES
void init_aesenc(void){
// TODO: Implementation
}
#endif
#ifdef __AES__
#define KeyExpansion256(round0,round1) \
"pshufd $0xff, %%xmm2, %%xmm2 \n" \
"movaps %%xmm1, %%xmm4 \n" \
@ -730,7 +720,7 @@ namespace crypto
"movaps %%xmm3, "#round1"(%[sched]) \n"
#endif
#if defined(__x86_64__) || defined(__i386__)
#ifdef __AES__
void ECBCryptoAESNI::ExpandKey (const AESKey& key)
{
__asm__
@ -771,7 +761,7 @@ namespace crypto
#endif
#if defined(__x86_64__) || defined(__i386__)
#ifdef __AES__
#define EncryptAES256(sched) \
"pxor (%["#sched"]), %%xmm0 \n" \
"aesenc 16(%["#sched"]), %%xmm0 \n" \
@ -792,7 +782,7 @@ namespace crypto
void ECBEncryption::Encrypt (const ChipherBlock * in, ChipherBlock * out)
{
#if defined(__x86_64__) || defined(__i386__)
#ifdef __AES__
if(i2p::cpu::aesni)
{
__asm__
@ -810,7 +800,7 @@ namespace crypto
}
}
#if defined(__x86_64__) || defined(__i386__)
#ifdef __AES__
#define DecryptAES256(sched) \
"pxor 224(%["#sched"]), %%xmm0 \n" \
"aesdec 208(%["#sched"]), %%xmm0 \n" \
@ -831,7 +821,7 @@ namespace crypto
void ECBDecryption::Decrypt (const ChipherBlock * in, ChipherBlock * out)
{
#if defined(__x86_64__) || defined(__i386__)
#ifdef __AES__
if(i2p::cpu::aesni)
{
__asm__
@ -849,7 +839,7 @@ namespace crypto
}
}
#if defined(__x86_64__) || defined(__i386__)
#ifdef __AES__
#define CallAESIMC(offset) \
"movaps "#offset"(%[shed]), %%xmm0 \n" \
"aesimc %%xmm0, %%xmm0 \n" \
@ -858,7 +848,7 @@ namespace crypto
void ECBEncryption::SetKey (const AESKey& key)
{
#if defined(__x86_64__) || defined(__i386__)
#ifdef __AES__
if(i2p::cpu::aesni)
{
ExpandKey (key);
@ -872,7 +862,7 @@ namespace crypto
void ECBDecryption::SetKey (const AESKey& key)
{
#if defined(__x86_64__) || defined(__i386__)
#ifdef __AES__
if(i2p::cpu::aesni)
{
ExpandKey (key); // expand encryption key first
@ -904,7 +894,7 @@ namespace crypto
void CBCEncryption::Encrypt (int numBlocks, const ChipherBlock * in, ChipherBlock * out)
{
#if defined(__x86_64__) || defined(__i386__)
#ifdef __AES__
if(i2p::cpu::aesni)
{
__asm__
@ -949,7 +939,7 @@ namespace crypto
void CBCEncryption::Encrypt (const uint8_t * in, uint8_t * out)
{
#if defined(__x86_64__) || defined(__i386__)
#ifdef __AES__
if(i2p::cpu::aesni)
{
__asm__
@ -973,7 +963,7 @@ namespace crypto
void CBCDecryption::Decrypt (int numBlocks, const ChipherBlock * in, ChipherBlock * out)
{
#if defined(__x86_64__) || defined(__i386__)
#ifdef __AES__
if(i2p::cpu::aesni)
{
__asm__
@ -1019,7 +1009,7 @@ namespace crypto
void CBCDecryption::Decrypt (const uint8_t * in, uint8_t * out)
{
#if defined(__x86_64__) || defined(__i386__)
#ifdef __AES__
if(i2p::cpu::aesni)
{
__asm__
@ -1043,7 +1033,7 @@ namespace crypto
void TunnelEncryption::Encrypt (const uint8_t * in, uint8_t * out)
{
#if defined(__x86_64__) || defined(__i386__)
#ifdef __AES__
if(i2p::cpu::aesni)
{
__asm__
@ -1084,7 +1074,7 @@ namespace crypto
void TunnelDecryption::Decrypt (const uint8_t * in, uint8_t * out)
{
#if defined(__x86_64__) || defined(__i386__)
#ifdef __AES__
if(i2p::cpu::aesni)
{
__asm__

View file

@ -169,9 +169,6 @@ namespace crypto
#ifdef __AES__
#ifdef ARM64AES
void init_aesenc(void) __attribute__((constructor));
#endif
class ECBCryptoAESNI
{
public:

View file

@ -829,8 +829,6 @@ namespace data
{
XORMetric m;
#if defined(__x86_64__) || defined(__i386__)
#pragma GCC push_options
#pragma GCC target("avx")
if(i2p::cpu::avx)
{
__asm__
@ -845,7 +843,6 @@ namespace data
);
}
else
#pragma GCC pop_options
#endif
{
const uint64_t * hash1 = key1.GetLL (), * hash2 = key2.GetLL ();