mirror of
https://github.com/JayDDee/cpuminer-opt.git
synced 2025-09-17 23:44:27 +00:00
v3.7.2
This commit is contained in:
@@ -299,7 +299,7 @@ HMAC_SHA256_Init(HMAC_SHA256_CTX * ctx, const void * _K, size_t Klen)
|
||||
|
||||
/* If Klen > 64, the key is really SHA256(K). */
|
||||
if (Klen > 64) {
|
||||
#if defined __SHA__
|
||||
#ifndef USE_SPH_SHA
|
||||
SHA256_Init(&ctx->ictx);
|
||||
SHA256_Update(&ctx->ictx, K, Klen);
|
||||
SHA256_Final(khash, &ctx->ictx);
|
||||
@@ -313,22 +313,22 @@ HMAC_SHA256_Init(HMAC_SHA256_CTX * ctx, const void * _K, size_t Klen)
|
||||
}
|
||||
|
||||
/* Inner SHA256 operation is SHA256(K xor [block of 0x36] || data). */
|
||||
#if defined __SHA__
|
||||
SHA256_Init(&ctx->ictx);
|
||||
#ifndef USE_SPH_SHA
|
||||
SHA256_Init(&ctx->ictx);
|
||||
#else
|
||||
SHA256_Init_Y(&ctx->ictx);
|
||||
#endif
|
||||
memset(pad, 0x36, 64);
|
||||
for (i = 0; i < Klen; i++)
|
||||
pad[i] ^= K[i];
|
||||
#if defined __SHA__
|
||||
#ifndef USE_SPH_SHA
|
||||
SHA256_Update(&ctx->ictx, pad, 64);
|
||||
#else
|
||||
SHA256_Update_Y(&ctx->ictx, pad, 64);
|
||||
#endif
|
||||
|
||||
/* Outer SHA256 operation is SHA256(K xor [block of 0x5c] || hash). */
|
||||
#if defined __SHA__
|
||||
#ifndef USE_SPH_SHA
|
||||
SHA256_Init(&ctx->octx);
|
||||
#else
|
||||
SHA256_Init_Y(&ctx->octx);
|
||||
@@ -336,7 +336,7 @@ HMAC_SHA256_Init(HMAC_SHA256_CTX * ctx, const void * _K, size_t Klen)
|
||||
memset(pad, 0x5c, 64);
|
||||
for (i = 0; i < Klen; i++)
|
||||
pad[i] ^= K[i];
|
||||
#if defined __SHA__
|
||||
#ifndef USE_SPH_SHA
|
||||
SHA256_Update(&ctx->octx, pad, 64);
|
||||
#else
|
||||
SHA256_Update_Y(&ctx->octx, pad, 64);
|
||||
@@ -352,7 +352,7 @@ HMAC_SHA256_Update(HMAC_SHA256_CTX * ctx, const void *in, size_t len)
|
||||
{
|
||||
|
||||
/* Feed data to the inner SHA256 operation. */
|
||||
#if defined __SHA__
|
||||
#ifndef USE_SPH_SHA
|
||||
SHA256_Update(&ctx->ictx, in, len);
|
||||
#else
|
||||
SHA256_Update_Y(&ctx->ictx, in, len);
|
||||
@@ -365,7 +365,7 @@ HMAC_SHA256_Final(unsigned char digest[32], HMAC_SHA256_CTX * ctx)
|
||||
{
|
||||
unsigned char ihash[32];
|
||||
|
||||
#if defined __SHA__
|
||||
#ifndef USE_SPH_SHA
|
||||
/* Finish the inner SHA256 operation. */
|
||||
SHA256_Final(ihash, &ctx->ictx);
|
||||
|
||||
|
||||
@@ -30,12 +30,8 @@
|
||||
#define _SHA256_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined __SHA__
|
||||
#include <openssl/sha.h>
|
||||
#endif
|
||||
#include <openssl/sha.h>
|
||||
|
||||
typedef struct SHA256Context {
|
||||
uint32_t state[8];
|
||||
@@ -51,7 +47,7 @@ typedef struct HMAC_SHA256Context {
|
||||
*/
|
||||
|
||||
typedef struct HMAC_SHA256Context {
|
||||
#if defined __SHA__
|
||||
#ifndef USE_SPH_SHA
|
||||
SHA256_CTX ictx;
|
||||
SHA256_CTX octx;
|
||||
#else
|
||||
|
||||
@@ -46,7 +46,6 @@
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "sha256_Y.h"
|
||||
#include "sysendian.h"
|
||||
|
||||
@@ -1302,7 +1301,7 @@ yescrypt_kdf(const yescrypt_shared_t * shared, yescrypt_local_t * local,
|
||||
S = (uint8_t *)XY + XY_size;
|
||||
|
||||
if (t || flags) {
|
||||
#if defined __SHA__
|
||||
#ifndef USE_SPH_SHA
|
||||
SHA256_CTX ctx;
|
||||
SHA256_Init(&ctx);
|
||||
SHA256_Update(&ctx, passwd, passwdlen);
|
||||
@@ -1358,33 +1357,30 @@ yescrypt_kdf(const yescrypt_shared_t * shared, yescrypt_local_t * local,
|
||||
* SCRAM's use of SHA-1) would be usable with yescrypt hashes.
|
||||
*/
|
||||
if ((t || flags) && buflen == sizeof(sha256)) {
|
||||
/* Compute ClientKey */
|
||||
{
|
||||
HMAC_SHA256_CTX ctx;
|
||||
HMAC_SHA256_Init(&ctx, buf, buflen);
|
||||
#if 0
|
||||
/* Proper yescrypt */
|
||||
HMAC_SHA256_Update_Y(&ctx, "Client Key", 10);
|
||||
#else
|
||||
/* GlobalBoost-Y buggy yescrypt */
|
||||
/* Compute ClientKey */
|
||||
{
|
||||
HMAC_SHA256_CTX ctx;
|
||||
HMAC_SHA256_Init(&ctx, buf, buflen);
|
||||
if ( client_key_hack ) // GlobalBoost-Y buggy yescrypt
|
||||
HMAC_SHA256_Update(&ctx, salt, saltlen);
|
||||
#endif
|
||||
HMAC_SHA256_Final(sha256, &ctx);
|
||||
}
|
||||
/* Compute StoredKey */
|
||||
{
|
||||
#if defined __SHA__
|
||||
SHA256_CTX ctx;
|
||||
SHA256_Init(&ctx);
|
||||
SHA256_Update(&ctx, sha256, sizeof(sha256));
|
||||
SHA256_Final(buf, &ctx);
|
||||
else // Proper yescrypt
|
||||
HMAC_SHA256_Update(&ctx, "Client Key", 10);
|
||||
HMAC_SHA256_Final(sha256, &ctx);
|
||||
}
|
||||
/* Compute StoredKey */
|
||||
{
|
||||
#ifndef USE_SPH_SHA
|
||||
SHA256_CTX ctx;
|
||||
SHA256_Init(&ctx);
|
||||
SHA256_Update(&ctx, sha256, sizeof(sha256));
|
||||
SHA256_Final(buf, &ctx);
|
||||
#else
|
||||
SHA256_CTX_Y ctx;
|
||||
SHA256_Init_Y(&ctx);
|
||||
SHA256_Update_Y(&ctx, sha256, sizeof(sha256));
|
||||
SHA256_Final_Y(buf, &ctx);
|
||||
SHA256_CTX_Y ctx;
|
||||
SHA256_Init_Y(&ctx);
|
||||
SHA256_Update_Y(&ctx, sha256, sizeof(sha256));
|
||||
SHA256_Final_Y(buf, &ctx);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (free_region(&tmp))
|
||||
|
||||
@@ -366,6 +366,7 @@ static int yescrypt_bsty(const uint8_t * passwd, size_t passwdlen,
|
||||
uint64_t YESCRYPT_N;
|
||||
uint32_t YESCRYPT_R;
|
||||
uint32_t YESCRYPT_P;
|
||||
bool client_key_hack;
|
||||
|
||||
/* main hash 80 bytes input */
|
||||
void yescrypt_hash( const char *input, char *output, uint32_t len )
|
||||
@@ -425,11 +426,12 @@ int64_t yescryptr16_get_max64()
|
||||
|
||||
bool register_yescrypt_algo( algo_gate_t* gate )
|
||||
{
|
||||
gate->optimizations = SSE2_OPT | SHA_OPT;
|
||||
gate->optimizations = SSE2_OPT | AVX_OPT | AVX2_OPT | SHA_OPT;
|
||||
gate->scanhash = (void*)&scanhash_yescrypt;
|
||||
gate->hash = (void*)&yescrypt_hash;
|
||||
gate->set_target = (void*)&scrypt_set_target;
|
||||
gate->get_max64 = (void*)&yescrypt_get_max64;
|
||||
client_key_hack = true;
|
||||
YESCRYPT_N = 2048;
|
||||
YESCRYPT_R = 8;
|
||||
YESCRYPT_P = 1;
|
||||
@@ -438,11 +440,12 @@ bool register_yescrypt_algo( algo_gate_t* gate )
|
||||
|
||||
bool register_yescryptr16_algo( algo_gate_t* gate )
|
||||
{
|
||||
gate->optimizations = SSE2_OPT | SHA_OPT;
|
||||
gate->optimizations = SSE2_OPT | AVX_OPT | AVX2_OPT | SHA_OPT;
|
||||
gate->scanhash = (void*)&scanhash_yescrypt;
|
||||
gate->hash = (void*)&yescrypt_hash;
|
||||
gate->set_target = (void*)&scrypt_set_target;
|
||||
gate->get_max64 = (void*)&yescryptr16_get_max64;
|
||||
client_key_hack = false;
|
||||
YESCRYPT_N = 4096;
|
||||
YESCRYPT_R = 16;
|
||||
YESCRYPT_P = 1;
|
||||
|
||||
@@ -37,6 +37,7 @@ extern "C" {
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h> /* for size_t */
|
||||
#include <stdbool.h>
|
||||
|
||||
//#define __SSE4_1__
|
||||
|
||||
@@ -107,6 +108,9 @@ typedef enum {
|
||||
__YESCRYPT_INIT_SHARED = 0x30000
|
||||
} yescrypt_flags_t;
|
||||
|
||||
extern bool client_key_hack; // true for GlobalBoost-Y
|
||||
|
||||
|
||||
#define YESCRYPT_KNOWN_FLAGS \
|
||||
(YESCRYPT_RW | YESCRYPT_PARALLEL_SMIX | YESCRYPT_PWXFORM | \
|
||||
__YESCRYPT_INIT_SHARED)
|
||||
|
||||
Reference in New Issue
Block a user