Permalink
Browse files

yescrypt: disable some extra/cleanup memset

set initial benchmark scan max loops

also fix OUT() define conflict on mingw
1 parent d6c5d6b commit 24f996f404b4ebc11c98f91714d67b0163a450da @tpruvot committed Dec 7, 2015
Showing with 18 additions and 16 deletions.
  1. +1 −0 cpu-miner.c
  2. +10 −10 yescrypt/sha256_Y.c
  3. +7 −6 yescrypt/yescrypt-simd.c
View
@@ -1899,6 +1899,7 @@ static void *miner_thread(void *userdata)
break;
case ALGO_DROP:
case ALGO_PLUCK:
+ case ALGO_YESCRYPT:
max64 = 0x1ff;
break;
case ALGO_LYRA2:
View
@@ -32,6 +32,7 @@
#include "sysendian.h"
#include "sha256_Y.h"
+#include "compat.h"
/*
* Encode a length len/4 vector of (uint32_t) into a length len vector of
@@ -91,8 +92,7 @@ be32dec_vect(uint32_t *dst, const unsigned char *src, size_t len)
static void
SHA256_Transform(uint32_t * state, const unsigned char block[64])
{
- uint32_t W[64];
- uint32_t S[8];
+ uint32_t _ALIGN(128) W[64], S[8];
uint32_t t0, t1;
int i;
@@ -173,11 +173,12 @@ SHA256_Transform(uint32_t * state, const unsigned char block[64])
/* 4. Mix local working variables into global state */
for (i = 0; i < 8; i++)
state[i] += S[i];
-
+#if 0
/* Clean the stack. */
memset(W, 0, 256);
memset(S, 0, 32);
t0 = t1 = 0;
+#endif
}
static unsigned char PAD[64] = {
@@ -322,7 +323,7 @@ HMAC_SHA256_Init_Y(HMAC_SHA256_CTX_Y * ctx, const void * _K, size_t Klen)
SHA256_Update_Y(&ctx->octx, pad, 64);
/* Clean the stack. */
- memset(khash, 0, 32);
+ //memset(khash, 0, 32);
}
/* Add bytes to the HMAC-SHA256 operation. */
@@ -350,7 +351,7 @@ HMAC_SHA256_Final_Y(unsigned char digest[32], HMAC_SHA256_CTX_Y * ctx)
SHA256_Final_Y(digest, &ctx->octx);
/* Clean the stack. */
- memset(ihash, 0, 32);
+ //memset(ihash, 0, 32);
}
/**
@@ -363,13 +364,12 @@ PBKDF2_SHA256(const uint8_t * passwd, size_t passwdlen, const uint8_t * salt,
size_t saltlen, uint64_t c, uint8_t * buf, size_t dkLen)
{
HMAC_SHA256_CTX_Y PShctx, hctx;
- size_t i;
+ uint8_t _ALIGN(128) T[32];
+ uint8_t _ALIGN(128) U[32];
uint8_t ivec[4];
- uint8_t U[32];
- uint8_t T[32];
+ size_t i, clen;
uint64_t j;
int k;
- size_t clen;
/* Compute HMAC state after processing P and S. */
HMAC_SHA256_Init_Y(&PShctx, passwd, passwdlen);
@@ -407,5 +407,5 @@ PBKDF2_SHA256(const uint8_t * passwd, size_t passwdlen, const uint8_t * salt,
}
/* Clean PShctx, since we never called _Final on it. */
- memset(&PShctx, 0, sizeof(HMAC_SHA256_CTX_Y));
+ //memset(&PShctx, 0, sizeof(HMAC_SHA256_CTX_Y));
}
@@ -51,9 +51,10 @@
#include "sysendian.h"
#include "yescrypt.h"
-
#include "yescrypt-platform.h"
+#include "compat.h"
+
#if __STDC_VERSION__ >= 199901L
/* have restrict */
#elif defined(__GNUC__)
@@ -309,7 +310,7 @@ blockmix_salsa8(const salsa20_blk_t *restrict Bin,
X2 = _mm_xor_si128(X2, (in)[2]); \
X3 = _mm_xor_si128(X3, (in)[3]);
-#define OUT(out) \
+#define XOUT(out) \
(out)[0] = X0; \
(out)[1] = X1; \
(out)[2] = X2; \
@@ -359,7 +360,7 @@ blockmix(const salsa20_blk_t *restrict Bin, salsa20_blk_t *restrict Bout,
XOR4(Bin[i].q)
PWXFORM
/* B'_i <-- X */
- OUT(Bout[i].q)
+ XOUT(Bout[i].q)
}
/* Last iteration of the loop above */
@@ -497,7 +498,7 @@ blockmix_xor(const salsa20_blk_t *restrict Bin1,
XOR4(Bin2[i].q)
PWXFORM
/* B'_i <-- X */
- OUT(Bout[i].q)
+ XOUT(Bout[i].q)
}
/* Last iteration of the loop above */
@@ -621,7 +622,7 @@ blockmix_xor_save(const salsa20_blk_t *restrict Bin1,
XOR4_Y
PWXFORM
/* B'_i <-- X */
- OUT(Bout[i].q)
+ XOUT(Bout[i].q)
}
/* Last iteration of the loop above */
@@ -1151,12 +1152,12 @@ yescrypt_kdf(const yescrypt_shared_t * shared, yescrypt_local_t * local,
uint64_t N, uint32_t r, uint32_t p, uint32_t t, yescrypt_flags_t flags,
uint8_t * buf, size_t buflen)
{
+ uint8_t _ALIGN(128) sha256[32];
yescrypt_region_t tmp;
uint64_t NROM;
size_t B_size, V_size, XY_size, need;
uint8_t * B, * S;
salsa20_blk_t * V, * XY;
- uint8_t sha256[32];
/*
* YESCRYPT_PARALLEL_SMIX is a no-op at p = 1 for its intended purpose,

0 comments on commit 24f996f

Please sign in to comment.