This commit is contained in:
Jay D Dee
2017-11-01 11:03:23 -04:00
parent 8ff52e7ad6
commit ab39e88318
16 changed files with 167 additions and 120 deletions

View File

@@ -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);