This commit is contained in:
Jay D Dee
2017-03-31 11:59:04 -04:00
parent 2dcc4821b6
commit 9afa0d9820
63 changed files with 297 additions and 176 deletions

View File

@@ -93,10 +93,12 @@ int scanhash_blakecoin( int thr_id, struct work *work, uint32_t max_nonce,
return 0;
}
/*
void blakecoin_gen_merkle_root ( char* merkle_root, struct stratum_ctx* sctx )
{
SHA256( sctx->job.coinbase, (int)sctx->job.coinbase_size, merkle_root );
}
*/
// changed to get_max64_0x3fffffLL in cpuminer-multi-decred
int64_t blakecoin_get_max64 ()

View File

@@ -42,7 +42,7 @@ extern "C"{
#endif
#include <stddef.h>
#include "algo/sha3/sph_types.h"
#include "algo/sha/sph_types.h"
/**
* Output size (in bits) for BLAKE-224.

View File

@@ -31,7 +31,7 @@
#include <stdint.h>
#include <string.h>
#include "algo/sha3/sph_types.h"
#include "algo/sha/sph_types.h"
#include "sph_blake2b.h"
// Cyclic right rotation.

View File

@@ -41,7 +41,7 @@ extern "C"{
#endif
#include <stddef.h>
#include "algo/sha3/sph_types.h"
#include "algo/sha/sph_types.h"
/**
* Output size (in bits) for BMW-224.

View File

@@ -42,7 +42,7 @@ extern "C"{
#endif
#include <stddef.h>
#include "algo/sha3/sph_types.h"
#include "algo/sha/sph_types.h"
/**
* Output size (in bits) for CubeHash-224.

View File

@@ -9,8 +9,7 @@
#include <immintrin.h>
#endif
#include "cubehash_sse2.h"
#include "algo/sha3/sha3-defs.h"
//#include "avxdefs.h"
#include "algo/sha/sha3-defs.h"
static void transform( cubehashParam *sp )
{

View File

@@ -3,7 +3,7 @@
#include "compat.h"
#include <stdint.h>
#include "algo/sha3/sha3-defs.h"
#include "algo/sha/sha3-defs.h"
#define OPTIMIZE_SSE2

View File

@@ -22,7 +22,7 @@
#endif
#include "algo/sha3/sha3_common.h"
#include "algo/sha/sha3_common.h"
#include <emmintrin.h>

View File

@@ -16,7 +16,7 @@
#ifndef VPERM_H
#define VPERM_H
#include "algo/sha3/sha3_common.h"
#include "algo/sha/sha3_common.h"
#include <tmmintrin.h>
/*

View File

@@ -71,7 +71,7 @@ extern "C"{
#endif
#define AES_BIG_ENDIAN 0
#include "algo/sha3/aes_helper.c"
#include "algo/sha/aes_helper.c"
#if SPH_ECHO_64

View File

@@ -41,7 +41,7 @@ extern "C"{
#endif
#include <stddef.h>
#include "algo/sha3/sph_types.h"
#include "algo/sha/sph_types.h"
/**
* Output size (in bits) for ECHO-224.

View File

@@ -41,7 +41,7 @@ extern "C"{
#endif
#include <stddef.h>
#include "algo/sha3/sph_types.h"
#include "algo/sha/sph_types.h"
/**
* Output size (in bits) for ECHO-224.

View File

@@ -2,7 +2,7 @@
#define SPH_FUGUE_H__
#include <stddef.h>
#include "algo/sha3/sph_types.h"
#include "algo/sha/sph_types.h"
#ifdef __cplusplus
extern "C"{

View File

@@ -41,7 +41,7 @@ extern "C"{
#endif
#include <stddef.h>
#include "algo/sha3/sph_types.h"
#include "algo/sha/sph_types.h"
/**
* Output size (in bits) for GOST-256.

View File

@@ -11,7 +11,12 @@
#else
#include "aes_ni/hash-groestl.h"
#endif
#include "algo/sha3/sph_sha2.h"
#if defined (SHA_NI)
#include <openssl/sha.h>
#else
#include "algo/sha/sph_sha2.h"
#endif
typedef struct {
#ifdef NO_AES_NI
@@ -19,7 +24,11 @@ typedef struct {
#else
hashState_groestl groestl;
#endif
sph_sha256_context sha;
#if defined (SHA_NI)
SHA256_CTX sha;
#else
sph_sha256_context sha;
#endif
} myrgr_ctx_holder;
myrgr_ctx_holder myrgr_ctx;
@@ -31,28 +40,35 @@ void init_myrgr_ctx()
#else
init_groestl (&myrgr_ctx.groestl, 64 );
#endif
sph_sha256_init(&myrgr_ctx.sha);
#if defined (SHA_NI)
SHA256_Init( &myrgr_ctx.sha );
#else
sph_sha256_init( &myrgr_ctx.sha );
#endif
}
void myriadhash( void *output, const void *input )
{
myrgr_ctx_holder ctx __attribute__ ((aligned (64)));
memcpy( &ctx, &myrgr_ctx, sizeof(myrgr_ctx) );
uint32_t hash[16] __attribute__ ((aligned (64)));
myrgr_ctx_holder ctx __attribute__ ((aligned (64)));
memcpy( &ctx, &myrgr_ctx, sizeof(myrgr_ctx) );
uint32_t hash[16] __attribute__ ((aligned (64)));
#ifdef NO_AES_NI
sph_groestl512(&ctx.groestl, input, 80);
sph_groestl512_close(&ctx.groestl, hash);
sph_groestl512(&ctx.groestl, input, 80);
sph_groestl512_close(&ctx.groestl, hash);
#else
update_and_final_groestl( &ctx.groestl, (char*)input,
(const char*)input, 640 );
update_and_final_groestl( &ctx.groestl, (char*)input,
(const char*)input, 640 );
#endif
sph_sha256(&ctx.sha, hash, 64);
sph_sha256_close(&ctx.sha, hash);
memcpy(output, hash, 32);
#if defined (SHA_NI)
SHA256_Update( &ctx.sha, hash, 64 );
SHA256_Final( (unsigned char*) hash, &ctx.sha );
#else
sph_sha256(&ctx.sha, hash, 64);
sph_sha256_close(&ctx.sha, hash);
#endif
memcpy(output, hash, 32);
}
int scanhash_myriad( int thr_id, struct work *work, uint32_t max_nonce,
@@ -92,7 +108,7 @@ int scanhash_myriad( int thr_id, struct work *work, uint32_t max_nonce,
bool register_myriad_algo( algo_gate_t* gate )
{
gate->optimizations = SSE2_OPT | AES_OPT;
gate->optimizations = SSE2_OPT | AES_OPT | SHA_OPT;
init_myrgr_ctx();
gate->scanhash = (void*)&scanhash_myriad;
gate->hash = (void*)&myriadhash;

View File

@@ -40,7 +40,7 @@ extern "C"{
#endif
#include <stddef.h>
#include "algo/sha3/sph_types.h"
#include "algo/sha/sph_types.h"
/**
* Output size (in bits) for Groestl-224.

View File

@@ -36,7 +36,7 @@
#define SPH_HAMSI_H__
#include <stddef.h>
#include "algo/sha3/sph_types.h"
#include "algo/sha/sph_types.h"
#ifdef __cplusplus
extern "C"{

View File

@@ -66,7 +66,7 @@ extern "C"{
#endif
#include <stddef.h>
#include "algo/sha3/sph_types.h"
#include "algo/sha/sph_types.h"
/**
* Output size (in bits) for HAVAL-128/3.

View File

@@ -20,7 +20,7 @@
#include "algo/fugue/sph_fugue.h"
#include "algo/shabal/sph_shabal.h"
#include "algo/whirlpool/sph_whirlpool.h"
#include "algo/sha2/sph-sha2.h"
#include "algo/sha/sph_sha2.h"
#include "algo/haval/sph-haval.h"
#ifndef NO_AES_NI
@@ -416,7 +416,7 @@ int scanhash_hmq1725( int thr_id, struct work *work, int32_t max_nonce,
bool register_hmq1725_algo( algo_gate_t* gate )
{
init_hmq1725_ctx();
gate->optimizations = SSE2_OPT | AES_OPT | AVX_OPT | AVX2_OPT;
gate->optimizations = SSE2_OPT | AES_OPT | AVX_OPT | AVX2_OPT | SHA_OPT;
gate->set_target = (void*)&scrypt_set_target;
gate->scanhash = (void*)&scanhash_hmq1725;
gate->hash = (void*)&hmq1725hash;

View File

@@ -41,7 +41,7 @@ extern "C"{
#endif
#include <stddef.h>
#include "algo/sha3/sph_types.h"
#include "algo/sha/sph_types.h"
/**
* Output size (in bits) for JH-224.

View File

@@ -41,7 +41,7 @@ extern "C"{
#endif
#include <stddef.h>
#include "algo/sha3/sph_types.h"
#include "algo/sha/sph_types.h"
/**
* Output size (in bits) for Keccak-224.

View File

@@ -41,7 +41,7 @@ extern "C"{
#endif
#include <stddef.h>
#include "algo/sha3/sph_types.h"
#include "algo/sha/sph_types.h"
#define QSTATIC static

View File

@@ -4,11 +4,12 @@
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include "sha3/sph_sha2.h"
#include "ripemd/sph_ripemd.h"
//#define DEBUG_ALGO
#if defined (SHA_NI)
#include <openssl/sha.h>
#else
#include "sha/sph_sha2.h"
#endif
#define LBRY_NTIME_INDEX 25
#define LBRY_NBITS_INDEX 26
@@ -18,9 +19,13 @@
/* Move init out of loop, so init once externally, and then use one single memcpy with that bigger memory block */
typedef struct {
sph_sha256_context sha256;
sph_sha512_context sha512;
sph_ripemd160_context ripemd;
#if defined (SHA_NI)
SHA256_CTX sha256;
#else
sph_sha256_context sha256;
#endif
sph_sha512_context sha512;
sph_ripemd160_context ripemd;
} lbryhash_context_holder;
/* no need to copy, because close reinit the context */
@@ -28,50 +33,78 @@ static lbryhash_context_holder ctx __attribute__ ((aligned (64)));
void init_lbry_contexts(void *dummy)
{
sph_sha256_init(&ctx.sha256);
sph_sha512_init(&ctx.sha512);
sph_ripemd160_init(&ctx.ripemd);
#if defined (SHA_NI)
SHA256_Init( &ctx.sha256 );
#else
sph_sha256_init( &ctx.sha256 );
#endif
sph_sha512_init( &ctx.sha512 );
sph_ripemd160_init( &ctx.ripemd );
}
void lbry_hash(void* output, const void* input)
{
sph_sha256_context ctx_sha256 __attribute__ ((aligned (64)));
sph_sha512_context ctx_sha512 __attribute__ ((aligned (64)));
sph_ripemd160_context ctx_ripemd __attribute__ ((aligned (64)));
uint32_t _ALIGN(64) hashA[16];
uint32_t _ALIGN(64) hashB[16];
uint32_t _ALIGN(64) hashC[16];
#if defined (SHA_NI)
SHA256_CTX ctx_sha256 __attribute__ ((aligned (64)));
#else
sph_sha256_context ctx_sha256 __attribute__ ((aligned (64)));
#endif
sph_sha512_context ctx_sha512 __attribute__ ((aligned (64)));
sph_ripemd160_context ctx_ripemd __attribute__ ((aligned (64)));
uint32_t _ALIGN(64) hashA[16];
uint32_t _ALIGN(64) hashB[16];
uint32_t _ALIGN(64) hashC[16];
sph_sha256_init(&ctx_sha256);
sph_sha256 (&ctx_sha256, input, 112);
sph_sha256_close(&ctx_sha256, hashA);
#if defined (SHA_NI)
SHA256_Init( &ctx_sha256 );
SHA256_Update( &ctx_sha256, input, 112 );
SHA256_Final( (unsigned char*) hashA, &ctx_sha256 );
sph_sha256_init(&ctx_sha256);
sph_sha256 (&ctx_sha256, hashA, 32);
sph_sha256_close(&ctx_sha256, hashA);
SHA256_Init( &ctx_sha256 );
SHA256_Update( &ctx_sha256, hashA, 32 );
SHA256_Final( (unsigned char*) hashA, &ctx_sha256 );
#else
sph_sha256_init( &ctx_sha256 );
sph_sha256 ( &ctx_sha256, input, 112 );
sph_sha256_close( &ctx_sha256, hashA );
sph_sha512_init(&ctx_sha512);
sph_sha512 (&ctx_sha512, hashA, 32);
sph_sha512_close(&ctx_sha512, hashA);
sph_sha256_init( &ctx_sha256 );
sph_sha256 ( &ctx_sha256, hashA, 32 );
sph_sha256_close( &ctx_sha256, hashA );
#endif
sph_ripemd160_init(&ctx_ripemd);
sph_ripemd160 (&ctx_ripemd, hashA, 32);
sph_ripemd160_close(&ctx_ripemd, hashB);
sph_sha512_init( &ctx_sha512 );
sph_sha512 ( &ctx_sha512, hashA, 32 );
sph_sha512_close( &ctx_sha512, hashA );
sph_ripemd160_init(&ctx_ripemd);
sph_ripemd160 (&ctx_ripemd, hashA+8, 32);
sph_ripemd160_close(&ctx_ripemd, hashC);
sph_ripemd160_init( &ctx_ripemd );
sph_ripemd160 ( &ctx_ripemd, hashA, 32 );
sph_ripemd160_close( &ctx_ripemd, hashB );
sph_sha256_init(&ctx_sha256);
sph_sha256 (&ctx_sha256, hashB, 20);
sph_sha256 (&ctx_sha256, hashC, 20);
sph_sha256_close(&ctx_sha256, hashA);
sph_ripemd160_init( &ctx_ripemd );
sph_ripemd160 ( &ctx_ripemd, hashA+8, 32 );
sph_ripemd160_close( &ctx_ripemd, hashC );
sph_sha256_init(&ctx_sha256);
sph_sha256 (&ctx_sha256, hashA, 32);
sph_sha256_close(&ctx_sha256, hashA);
#if defined (SHA_NI)
SHA256_Init( &ctx_sha256 );
SHA256_Update( &ctx_sha256, hashB, 20 );
SHA256_Update( &ctx_sha256, hashC, 20 );
SHA256_Final( (unsigned char*) hashA, &ctx_sha256 );
memcpy(output, hashA, 32);
SHA256_Init( &ctx_sha256 );
SHA256_Update( &ctx_sha256, hashA, 32 );
SHA256_Final( (unsigned char*) hashA, &ctx_sha256 );
#else
sph_sha256_init( &ctx_sha256 );
sph_sha256 ( &ctx_sha256, hashB, 20 );
sph_sha256 ( &ctx_sha256, hashC, 20 );
sph_sha256_close( &ctx_sha256, hashA );
sph_sha256_init( &ctx_sha256 );
sph_sha256 ( &ctx_sha256, hashA, 32 );
sph_sha256_close( &ctx_sha256, hashA );
#endif
memcpy( output, hashA, 32 );
}
int scanhash_lbry( int thr_id, struct work *work, uint32_t max_nonce,
@@ -211,6 +244,7 @@ int64_t lbry_get_max64() { return 0x1ffffLL; }
bool register_lbry_algo( algo_gate_t* gate )
{
gate->optimizations = SSE2_OPT | SHA_OPT;
gate->scanhash = (void*)&scanhash_lbry;
gate->hash = (void*)&lbry_hash;
gate->calc_network_diff = (void*)&lbry_calc_network_diff;

View File

@@ -41,7 +41,7 @@ extern "C"{
#endif
#include <stddef.h>
#include "algo/sha3/sph_types.h"
#include "algo/sha/sph_types.h"
/**
* Output size (in bits) for Luffa-224.

View File

@@ -19,7 +19,7 @@
*/
#include <emmintrin.h>
#include "algo/sha3/sha3-defs.h"
#include "algo/sha/sha3-defs.h"
/* The length of digests*/
#define DIGEST_BIT_LEN_224 224
#define DIGEST_BIT_LEN_256 256

View File

@@ -50,8 +50,9 @@ void lyra2rev2_hash( void *state, const void *input )
{
lyra2v2_ctx_holder ctx __attribute__ ((aligned (64)));
memcpy( &ctx, &lyra2v2_ctx, sizeof(lyra2v2_ctx) );
uint32_t hashA[8], hashB[8] __attribute__ ((aligned (64)));
uint8_t hash[128] __attribute__ ((aligned (64)));
#define hashA hash
#define hashB hash+64
const int midlen = 64; // bytes
const int tail = 80 - midlen; // 16
@@ -124,7 +125,6 @@ void lyra2rev2_set_target( struct work* work, double job_diff )
work_set_target( work, job_diff / (256.0 * opt_diff_factor) );
}
bool lyra2rev2_thread_init()
{
const int64_t ROW_LEN_INT64 = BLOCK_LEN_INT64 * 4; // nCols
@@ -138,7 +138,7 @@ bool lyra2rev2_thread_init()
#if defined (__AVX2__)
memset_zero_m256i( (__m256i*)l2v2_wholeMatrix, i/32 );
#elif defined(__AVX__)
#elif defined (__AVX__)
memset_zero_m128i( (__m128i*)l2v2_wholeMatrix, i/16 );
#else
memset( l2v2_wholeMatrix, 0, i );
@@ -151,9 +151,9 @@ bool register_lyra2rev2_algo( algo_gate_t* gate )
init_lyra2rev2_ctx();
gate->optimizations = SSE2_OPT | AES_OPT | AVX_OPT | AVX2_OPT;
gate->miner_thread_init = (void*)&lyra2rev2_thread_init;
gate->scanhash = (void*)&scanhash_lyra2rev2;
gate->hash = (void*)&lyra2rev2_hash;
gate->set_target = (void*)&lyra2rev2_set_target;
gate->scanhash = (void*)&scanhash_lyra2rev2;
gate->hash = (void*)&lyra2rev2_hash;
gate->set_target = (void*)&lyra2rev2_set_target;
return true;
};

View File

@@ -8,7 +8,7 @@
#include <string.h>
#include <float.h>
#include <math.h>
#include "algo/sha2/sph-sha2.h"
#include "algo/sha/sph_sha2.h"
#include "algo/keccak/sph_keccak.h"
#include "algo/haval/sph-haval.h"
#include "algo/tiger/sph_tiger.h"
@@ -540,7 +540,7 @@ void m7m_reverse_endian( struct work *work )
bool register_m7m_algo( algo_gate_t *gate )
{
gate->optimizations = SSE2_OPT | AES_OPT | AVX_OPT;
gate->optimizations = SSE2_OPT | AES_OPT | AVX_OPT | SHA_OPT;
init_m7m_ctx();
gate->scanhash = (void*)scanhash_m7m_hash;
gate->build_stratum_request = (void*)&std_be_build_stratum_request;

View File

@@ -263,7 +263,7 @@ sph_ripemd_init(void *cc)
#define RFUN ripemd_round
#define HASH ripemd
#define LE32 1
#include "algo/sha3/md_helper.c"
#include "algo/sha/md_helper.c"
#undef RFUN
#undef HASH
#undef LE32
@@ -517,7 +517,7 @@ sph_ripemd128_init(void *cc)
#define RFUN ripemd128_round
#define HASH ripemd128
#define LE32 1
#include "algo/sha3/md_helper.c"
#include "algo/sha/md_helper.c"
#undef RFUN
#undef HASH
#undef LE32
@@ -810,7 +810,7 @@ sph_ripemd160_init(void *cc)
#define RFUN ripemd160_round
#define HASH ripemd160
#define LE32 1
#include "algo/sha3/md_helper.c"
#include "algo/sha/md_helper.c"
#undef RFUN
#undef HASH
#undef LE32

View File

@@ -57,7 +57,7 @@
#define SPH_RIPEMD_H__
#include <stddef.h>
#include "algo/sha3/sph_types.h"
#include "algo/sha/sph_types.h"
/**
* Output size (in bits) for RIPEMD.

View File

@@ -6,45 +6,62 @@
#include <string.h>
#include <stdio.h>
#include "sph-sha2.h"
//#define DEBUG_ALGO
#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)));
#else
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)
SHA256_Update( &sha256t_mid, input, 64 );
#else
sph_sha256( &sha256t_mid, input, 64 );
#endif
}
void sha256t_hash(void* output, const void* input, uint32_t len)
{
sph_sha256_context ctx_sha256 __attribute__ ((aligned (64)));
uint32_t _ALIGN(64) hashA[16];
const int midlen = 64; // bytes
const int tail = 80 - midlen; // 16
#if defined (SHA_NI)
SHA256_CTX ctx_sha256 __attribute__ ((aligned (64)));
memcpy( &ctx_sha256, &sha256t_mid, sizeof sha256t_mid );
SHA256_Update( &ctx_sha256, input + midlen, tail );
SHA256_Final( hashA, &ctx_sha256 );
memcpy( &ctx_sha256, &sha256t_ctx, sizeof sha256t_ctx );
SHA256_Update( &ctx_sha256, hashA, 32 );
SHA256_Final( hashA, &ctx_sha256 );
memcpy( &ctx_sha256, &sha256t_ctx, sizeof sha256t_ctx );
SHA256_Update( &ctx_sha256, hashA, 32 );
SHA256_Final( hashA, &ctx_sha256 );
#else
sph_sha256_context ctx_sha256 __attribute__ ((aligned (64)));
memcpy( &ctx_sha256, &sha256t_mid, sizeof sha256t_mid );
sph_sha256( &ctx_sha256, input + midlen, tail );
// sph_sha256_init(&ctx_sha256);
// sph_sha256 (&ctx_sha256, input, 80);
sph_sha256_close( &ctx_sha256, hashA );
// sph_sha256_init(&ctx_sha256);
memcpy( &ctx_sha256, &sha256t_ctx, sizeof sha256t_ctx );
sph_sha256( &ctx_sha256, hashA, 32 );
sph_sha256_close( &ctx_sha256, hashA );
// sph_sha256_init(&ctx_sha256);
memcpy( &ctx_sha256, &sha256t_ctx, sizeof sha256t_ctx );
sph_sha256( &ctx_sha256, hashA, 32 );
sph_sha256_close( &ctx_sha256, hashA );
#endif
memcpy( output, hashA, 32 );
}
@@ -133,7 +150,12 @@ void sha256t_set_target( struct work* work, double job_diff )
bool register_sha256t_algo( algo_gate_t* gate )
{
#if defined (SHA_NI)
SHA256_Init( &sha256t_ctx );
#else
sph_sha256_init( &sha256t_ctx );
#endif
gate->optimizations = SSE2_OPT | SHA_OPT;
gate->scanhash = (void*)&scanhash_sha256t;
gate->hash = (void*)&sha256t_hash;
gate->set_target = (void*)&sha256t_set_target;

View File

@@ -649,7 +649,7 @@ sph_sha256_init(void *cc)
#define RFUN sha2_round
#define HASH sha224
#define BE32 1
#include "algo/sha3/md_helper.c"
#include "md_helper.c"
/* see sph_sha2.h */
void

View File

@@ -41,7 +41,7 @@
#define SPH_SHA2_H__
#include <stddef.h>
#include "algo/sha3/sph_types.h"
#include "sph_types.h"
#ifdef __cplusplus
extern "C"{

View File

@@ -37,7 +37,7 @@
#define SPH_SHABAL_H__
#include <stddef.h>
#include "algo/sha3/sph_types.h"
#include "algo/sha/sph_types.h"
#ifdef __cplusplus
extern "C"{
#endif

View File

@@ -62,7 +62,7 @@ extern "C"{
*/
#define AES_BIG_ENDIAN 0
#include "algo/sha3/aes_helper.c"
#include "algo/sha/aes_helper.c"
static const sph_u32 IV224[] = {
C32(0x6774F31C), C32(0x990AE210), C32(0xC87D4274), C32(0xC9546371),

View File

@@ -39,7 +39,7 @@
#define SPH_SHAVITE_H__
#include <stddef.h>
#include "algo/sha3/sph_types.h"
#include "algo/sha/sph_types.h"
#ifdef __cplusplus
extern "C"{

View File

@@ -41,7 +41,7 @@ extern "C"{
#endif
#include <stddef.h>
#include "algo/sha3/sph_types.h"
#include "algo/sha/sph_types.h"
/**
* Output size (in bits) for SIMD-224.

View File

@@ -9,7 +9,7 @@
#endif
#include "compat.h"
#include "algo/sha3/sha3-defs.h"
#include "algo/sha/sha3-defs.h"
/*
* NIST API Specific types.
*/

View File

@@ -4,21 +4,33 @@
#include <string.h>
#include <stdint.h>
#include <openssl/sha.h>
#include "sph_skein.h"
#if defined (SHA_NI)
#include <openssl/sha.h>
#else
#include "algo/sha/sph_sha2.h"
#endif
typedef struct {
sph_skein512_context skein;
SHA256_CTX sha256;
sph_skein512_context skein;
#if defined (SHA_NI)
SHA256_CTX sha256;
#else
sph_sha256_context sha256;
#endif
} skein_ctx_holder;
skein_ctx_holder skein_ctx;
void init_skein_ctx()
{
sph_skein512_init(&skein_ctx.skein);
SHA256_Init(&skein_ctx.sha256);
sph_skein512_init( &skein_ctx.skein );
#if defined (SHA_NI)
SHA256_Init( &skein_ctx.sha256 );
#else
sph_sha256_init( &skein_ctx.sha256 );
#endif
}
void skeinhash(void *state, const void *input)
@@ -27,11 +39,16 @@ void skeinhash(void *state, const void *input)
memcpy( &ctx, &skein_ctx, sizeof(skein_ctx) );
uint32_t hash[16] __attribute__ ((aligned (64)));
sph_skein512(&ctx.skein, input, 80);
sph_skein512_close(&ctx.skein, hash);
sph_skein512( &ctx.skein, input, 80 );
sph_skein512_close( &ctx.skein, hash );
SHA256_Update(&ctx.sha256, hash, 64);
SHA256_Final((unsigned char*) hash, &ctx.sha256);
#if defined (SHA_NI)
SHA256_Update( &ctx.sha256, hash, 64 );
SHA256_Final( (unsigned char*) hash, &ctx.sha256 );
#else
sph_sha256( &ctx.sha256, hash, 64 );
sph_sha256_close( &ctx.sha256, hash );
#endif
memcpy(state, hash, 32);
}
@@ -72,6 +89,7 @@ int64_t skein_get_max64() { return 0x7ffffLL; }
bool register_skein_algo( algo_gate_t* gate )
{
init_skein_ctx();
gate->optimizations = SSE2_OPT | SHA_OPT;
gate->scanhash = (void*)&scanhash_skein;
gate->hash = (void*)&skeinhash;
gate->get_max64 = (void*)&skein_get_max64;

View File

@@ -46,7 +46,7 @@ extern "C"{
#endif
#include <stddef.h>
#include "algo/sha3/sph_types.h"
#include "algo/sha/sph_types.h"
#if SPH_64

View File

@@ -661,7 +661,7 @@ sph_tiger_init(void *cc)
#define BLEN 64U
#define PW01 1
#define PLW1 1
#include "algo/sha3/md_helper.c"
#include "algo/sha/md_helper.c"
/* see sph_tiger.h */
void
@@ -684,7 +684,7 @@ sph_tiger_comp(const sph_u64 msg[8], sph_u64 val[3])
#define HASH tiger2
#undef PW01
#define CLOSE_ONLY 1
#include "algo/sha3/md_helper.c"
#include "algo/sha/md_helper.c"
/* see sph_tiger.h */
void

View File

@@ -45,7 +45,7 @@
#define SPH_TIGER_H__
#include <stddef.h>
#include "algo/sha3/sph_types.h"
#include "algo/sha/sph_types.h"
#if SPH_64

View File

@@ -3441,19 +3441,19 @@ ROUND_FUN(whirlpool1, old1)
#define RFUN whirlpool_round
#define HASH whirlpool
#include "algo/sha3/md_helper.c"
#include "algo/sha/md_helper.c"
#undef RFUN
#undef HASH
#define RFUN whirlpool0_round
#define HASH whirlpool0
#include "algo/sha3/md_helper.c"
#include "algo/sha/md_helper.c"
#undef RFUN
#undef HASH
#define RFUN whirlpool1_round
#define HASH whirlpool1
#include "algo/sha3/md_helper.c"
#include "algo/sha/md_helper.c"
#undef RFUN
#undef HASH

View File

@@ -49,7 +49,7 @@
#define SPH_WHIRLPOOL_H__
#include <stddef.h>
#include "algo/sha3/sph_types.h"
#include "algo/sha/sph_types.h"
#if SPH_64

View File

@@ -21,7 +21,7 @@
#include "algo/fugue/sph_fugue.h"
#include "algo/shabal/sph_shabal.h"
#include "algo/whirlpool/sph_whirlpool.h"
#include "algo/sha3/sph_sha2.h"
#include "algo/sha/sph_sha2.h"
#include "algo/haval/sph-haval.h"
#include "algo/luffa/sse2/luffa_for_sse2.h"

View File

@@ -17,7 +17,7 @@
#include "algo/fugue/sph_fugue.h"
#include "algo/shabal/sph_shabal.h"
#include "algo/whirlpool/sph_whirlpool.h"
#include "algo/sha3/sph_sha2.h"
#include "algo/sha/sph_sha2.h"
#include "algo/haval/sph-haval.h"
#include "algo/simd/sse2/nist.h"
#include "algo/cubehash/sse2/cubehash_sse2.h"