Skip to content
This repository has been archived by the owner on Jan 9, 2021. It is now read-only.

Commit

Permalink
Disable AES function if gcc not support it
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbandi committed May 9, 2016
1 parent c699679 commit f371b32
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ EXTRA_DIST = example-cfg.json nomacro.pl

SUBDIRS = compat

hodlminer_CPPFLAGS = $(PTHREAD_FLAGS) -march=native -Ofast -flto -fuse-linker-plugin -std=gnu11 $(JANSSON_INCLUDES)
hodlminer_CPPFLAGS = $(PTHREAD_FLAGS) -flto -fuse-linker-plugin -std=gnu11 $(JANSSON_INCLUDES)

bin_PROGRAMS = hodlminer

Expand Down
2 changes: 2 additions & 0 deletions aes.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <stdint.h>
#if defined(__AES__)
#include <x86intrin.h>

static inline void ExpandAESKey256_sub1(__m128i *tmp1, __m128i *tmp2)
Expand Down Expand Up @@ -101,3 +102,4 @@ void AES256CBC(__m128i *Ciphertext, const __m128i *Plaintext, const __m128i *Exp
Ciphertext[i] = State;
}
}
#endif
7 changes: 5 additions & 2 deletions hodl.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ int scanhash_hodl(int threadNumber, int totalThreads, uint32_t *pdata, CacheEntr
for(int j = 0; j < AES_ITERATIONS; j++)
{
CacheEntry TmpXOR;
__m128i ExpKey[16];

// use last 4 bytes of first cache as next location
uint32_t nextLocation = Cache.dwords[(GARBAGE_SLICE_SIZE >> 2) - 1] & (COMPARE_SIZE - 1); //% COMPARE_SIZE;
Expand All @@ -57,10 +56,14 @@ int scanhash_hodl(int threadNumber, int totalThreads, uint32_t *pdata, CacheEntr
// Key is last 32b of TmpXOR
// IV is last 16b of TmpXOR

#if defined(__AES__)
if (aes_ni_supported) {
__m128i ExpKey[16];
ExpandAESKey256(ExpKey, TmpXOR.dqwords + (GARBAGE_SLICE_SIZE / sizeof(__m128i)) - 2);
AES256CBC(Cache.dqwords, TmpXOR.dqwords, ExpKey, TmpXOR.dqwords[(GARBAGE_SLICE_SIZE / sizeof(__m128i)) - 1], 256);
} else {
} else
#endif
{
EVP_CIPHER_CTX ctx;
int outlen1;
EVP_EncryptInit(&ctx, EVP_aes_256_cbc(), (const unsigned char *)(TmpXOR.dqwords + (GARBAGE_SLICE_SIZE / sizeof(__m128i)) - 2), (const unsigned char *)(TmpXOR.dqwords + ((GARBAGE_SLICE_SIZE / sizeof(__m128i)) - 1)));
Expand Down

0 comments on commit f371b32

Please sign in to comment.