This commit is contained in:
Jay D Dee
2017-04-17 14:35:18 -04:00
parent 53259692eb
commit 0155cd1bfe
14 changed files with 33 additions and 2293 deletions

View File

@@ -8,19 +8,20 @@
#include "sph_sha2.h"
#if defined (SHA_NI)
#include <openssl/sha.h>
static SHA256_CTX sha256t_ctx __attribute__ ((aligned (64)));
static __thread SHA256_CTX sha256t_mid __attribute__ ((aligned (64)));
#if defined __SHA__
#include <openssl/sha.h>
static SHA256_CTX sha256t_ctx __attribute__ ((aligned (64)));
static __thread SHA256_CTX sha256t_mid __attribute__ ((aligned (64)));
#else
static sph_sha256_context sha256t_ctx __attribute__ ((aligned (64)));
static __thread sph_sha256_context sha256t_mid __attribute__ ((aligned (64)));
static sph_sha256_context sha256t_ctx __attribute__ ((aligned (64)));
static __thread sph_sha256_context sha256t_mid __attribute__ ((aligned (64)));
#endif
void sha256t_midstate( const void* input )
{
memcpy( &sha256t_mid, &sha256t_ctx, sizeof sha256t_mid );
#if defined (SHA_NI)
#if defined __SHA__
SHA256_Update( &sha256t_mid, input, 64 );
#else
sph_sha256( &sha256t_mid, input, 64 );
@@ -33,7 +34,7 @@ void sha256t_hash(void* output, const void* input, uint32_t len)
const int midlen = 64; // bytes
const int tail = 80 - midlen; // 16
#if defined (SHA_NI)
#if defined __SHA__
SHA256_CTX ctx_sha256 __attribute__ ((aligned (64)));
memcpy( &ctx_sha256, &sha256t_mid, sizeof sha256t_mid );
@@ -147,10 +148,9 @@ void sha256t_set_target( struct work* work, double job_diff )
work_set_target( work, job_diff / (256.0 * opt_diff_factor) );
}
bool register_sha256t_algo( algo_gate_t* gate )
{
#if defined (SHA_NI)
#if defined __SHA__
SHA256_Init( &sha256t_ctx );
#else
sph_sha256_init( &sha256t_ctx );