Eliminate dup _InitHmac

pull/1319/head
Takashi Kojo 2017-12-02 05:04:44 +09:00 committed by Jacob Barthelmeh
parent 56efe657fc
commit dce628ae8e
3 changed files with 10 additions and 63 deletions

View File

@ -24751,67 +24751,6 @@ int wolfSSL_HMAC_CTX_copy(WOLFSSL_HMAC_CTX* des, WOLFSSL_HMAC_CTX* src)
return SSL_SUCCESS;
}
/* duplicate from wolfcrypt/src/hmac.c needs refactored */
static int _InitHmac(Hmac* hmac, int type, void* heap)
{
int ret = 0;
switch (type) {
#ifndef NO_MD5
case MD5:
ret = wc_InitMd5(&hmac->hash.md5);
break;
#endif /* !NO_MD5 */
#ifndef NO_SHA
case SHA:
ret = wc_InitSha(&hmac->hash.sha);
break;
#endif /* !NO_SHA */
#ifdef WOLFSSL_SHA224
case SHA224:
ret = wc_InitSha224(&hmac->hash.sha224);
break;
#endif /* WOLFSSL_SHA224 */
#ifndef NO_SHA256
case SHA256:
ret = wc_InitSha256(&hmac->hash.sha256);
break;
#endif /* !NO_SHA256 */
#ifdef WOLFSSL_SHA512
#ifdef WOLFSSL_SHA384
case SHA384:
ret = wc_InitSha384(&hmac->hash.sha384);
break;
#endif /* WOLFSSL_SHA384 */
case SHA512:
ret = wc_InitSha512(&hmac->hash.sha512);
break;
#endif /* WOLFSSL_SHA512 */
#ifdef HAVE_BLAKE2
case BLAKE2B_ID:
ret = wc_InitBlake2b(&hmac->hash.blake2b, BLAKE2B_256);
break;
#endif /* HAVE_BLAKE2 */
default:
ret = BAD_FUNC_ARG;
break;
}
/* default to NULL heap hint or test value */
#ifdef WOLFSSL_HEAP_TEST
hmac->heap = (void)WOLFSSL_HEAP_TEST;
#else
hmac->heap = heap;
#endif /* WOLFSSL_HEAP_TEST */
return ret;
}
int wolfSSL_HMAC_Init(WOLFSSL_HMAC_CTX* ctx, const void* key, int keylen,
const EVP_MD* type)
{

View File

@ -166,9 +166,13 @@ int wc_HmacSizeByType(int type)
return ret;
}
#ifdef OPENSSL_EXTRA
WOLFSSL_LOCAL
#else
static
#endif
/* software implementation */
static int _InitHmac(Hmac* hmac, int type, void* heap)
int _InitHmac(Hmac* hmac, int type, void* heap)
{
int ret = 0;

View File

@ -156,6 +156,10 @@ WOLFSSL_API void wc_HmacFree(Hmac*);
WOLFSSL_API int wolfSSL_GetHmacMaxSize(void);
#ifdef OPENSSL_EXTRA
WOLFSSL_LOCAL int _InitHmac(Hmac* hmac, int type, void* heap);
#endif
#ifdef HAVE_HKDF
WOLFSSL_API int wc_HKDF_Extract(int type, const byte* salt, word32 saltSz,