Skip to content

Commit

Permalink
Move sha256d from sha2.c to sha256.c
Browse files Browse the repository at this point in the history
  • Loading branch information
okoto-xyz committed Nov 4, 2018
1 parent 3cc09c8 commit 842c75c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dist_man_MANS = minerd.1
minerd_SOURCES = elist.h miner.h compat.h \
cpu-miner.c util.c \
yescrypt.c yescrypt.h \
sha2.c sha256.c sha256_shani.c yespower.c yespower.h yespower-opt.c
sha256.c sha256_shani.c yespower.c yespower.h yespower-opt.c
if USE_ASM
if ARCH_x86
minerd_SOURCES += sha2-x86.S scrypt-x86.S
Expand Down
17 changes: 17 additions & 0 deletions sha256.c
Original file line number Diff line number Diff line change
Expand Up @@ -654,3 +654,20 @@ PBKDF2_SHA256(const uint8_t * passwd, size_t passwdlen, const uint8_t * salt,
insecure_memzero(tmp32, 288);
insecure_memzero(&u, sizeof(u));
}

void sha256d(unsigned char *digest, const unsigned char *in, int len)
{
SHA256_CTX ctx;
uint32_t tmp32[72];

SHA256_Init(&ctx);
_SHA256_Update(&ctx, in, len, tmp32);
_SHA256_Final(digest, &ctx, tmp32);
SHA256_Init(&ctx);
_SHA256_Update(&ctx, digest, 32, tmp32);
_SHA256_Final(digest, &ctx, tmp32);

/* Clean the stack. */
insecure_memzero(&ctx, sizeof(SHA256_CTX));
insecure_memzero(tmp32, 288);
}

0 comments on commit 842c75c

Please sign in to comment.