Skip to content

Commit 40e43ea

Browse files
committed
Enable AES-NI per default on x86_64.
This can be disabled by defining `LTC_NO_AES_NI`. Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
1 parent 48d286b commit 40e43ea

File tree

5 files changed

+13
-4
lines changed

5 files changed

+13
-4
lines changed

.github/workflows/main.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ jobs:
4646
- { BUILDNAME: 'VALGRIND', BUILDOPTIONS: '', BUILDSCRIPT: '.ci/valgrind.sh' }
4747
- { BUILDNAME: 'STOCK', BUILDOPTIONS: '', BUILDSCRIPT: '.ci/run.sh' }
4848
- { BUILDNAME: 'STOCK-MPI', BUILDOPTIONS: '-ULTM_DESC -UTFM_DESC -UUSE_LTM -UUSE_TFM', BUILDSCRIPT: '.ci/run.sh' }
49-
- { BUILDNAME: 'STOCK+AESNI', BUILDOPTIONS: '-DLTC_AES_NI', BUILDSCRIPT: '.ci/run.sh' }
5049
- { BUILDNAME: 'EASY', BUILDOPTIONS: '-DLTC_EASY', BUILDSCRIPT: '.ci/run.sh' }
5150
- { BUILDNAME: 'SMALL', BUILDOPTIONS: '-DLTC_SMALL_CODE', BUILDSCRIPT: '.ci/run.sh' }
5251
- { BUILDNAME: 'NO_TABLES', BUILDOPTIONS: '-DLTC_NO_TABLES', BUILDSCRIPT: '.ci/run.sh' }

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ build_script:
3131
cp test.exe test-stock.exe
3232
cp timing.exe timing-stock.exe
3333
nmake -f makefile.msvc clean
34-
nmake -f makefile.msvc all CFLAGS="/Ox /DUSE_LTM /DLTM_DESC /DLTC_AES_NI /I../libtommath"
34+
nmake -f makefile.msvc all CFLAGS="/Ox /DUSE_LTM /DLTM_DESC /DLTC_NO_AES_NI /I../libtommath"
3535
test_script:
3636
- cmd: >-
3737
test-stock.exe

src/ciphers/aes/aes_desc.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,17 @@ static LTC_INLINE int s_aesni_is_supported(void)
8383

8484
return is_supported;
8585
}
86+
#endif
8687

8788
#ifndef ENCRYPT_ONLY
8889
int aesni_is_supported(void)
8990
{
91+
#ifdef LTC_AES_NI
9092
return s_aesni_is_supported();
91-
}
93+
#else
94+
return 0;
9295
#endif
96+
}
9397
#endif
9498

9599
/**

src/headers/tomcrypt_cfg.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ typedef unsigned long ltc_mp_digit;
244244
#undef ENDIAN_32BITWORD
245245
#undef ENDIAN_64BITWORD
246246
#undef LTC_FAST
247+
#define LTC_NO_AES_NI
247248
#define LTC_NO_BSWAP
248249
#define LTC_NO_ROLC
249250
#define LTC_NO_ROTATE
@@ -303,6 +304,10 @@ typedef unsigned long ltc_mp_digit;
303304
#define LTC_HAVE_CTZL_BUILTIN
304305
#endif
305306

307+
#if !defined(LTC_NO_AES_NI) && (defined(__x86_64__) || defined(_M_X64))
308+
#define LTC_AES_NI
309+
#endif
310+
306311
#if defined(__GNUC__)
307312
#define LTC_ALIGN(n) __attribute__((aligned(n)))
308313
#else

src/headers/tomcrypt_cipher.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,10 +711,11 @@ void rijndael_enc_done(symmetric_key *skey);
711711
int rijndael_enc_keysize(int *keysize);
712712
extern const struct ltc_cipher_descriptor rijndael_desc;
713713
extern const struct ltc_cipher_descriptor rijndael_enc_desc;
714+
715+
int aesni_is_supported(void);
714716
#endif
715717

716718
#if defined(LTC_AES_NI)
717-
int aesni_is_supported(void);
718719
int aesni_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
719720
int aesni_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey);
720721
int aesni_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey);

0 commit comments

Comments
 (0)