HMAC fips mode

This commit is contained in:
toddouska
2014-03-27 15:43:54 -07:00
parent 7dd265cf2e
commit 05b132ce1c
12 changed files with 194 additions and 80 deletions

View File

@@ -43,6 +43,11 @@
#endif
#ifdef HAVE_FIPS
/* set NO_WRAPPERS before headers, use direct internal f()s not wrappers */
#define FIPS_NO_WRAPPERS
#endif
#include <cyassl/ctaocrypt/hmac.h>
#include <cyassl/ctaocrypt/error-crypt.h>
@@ -288,7 +293,7 @@ static void HmacKeyInnerHash(Hmac* hmac)
}
void HmacUpdate(Hmac* hmac, const byte* msg, word32 length)
int HmacUpdate(Hmac* hmac, const byte* msg, word32 length)
{
#ifdef HAVE_CAVIUM
if (hmac->magic == CYASSL_HMAC_CAVIUM_MAGIC)
@@ -339,10 +344,11 @@ void HmacUpdate(Hmac* hmac, const byte* msg, word32 length)
break;
}
return 0;
}
void HmacFinal(Hmac* hmac, byte* hash)
int HmacFinal(Hmac* hmac, byte* hash)
{
#ifdef HAVE_CAVIUM
if (hmac->magic == CYASSL_HMAC_CAVIUM_MAGIC)
@@ -445,6 +451,8 @@ void HmacFinal(Hmac* hmac, byte* hash)
}
hmac->innerHashKeyed = 0;
return 0;
}

View File

@@ -122,7 +122,7 @@ int PBKDF2(byte* output, const byte* passwd, int pLen, const byte* salt,
{
word32 i = 1;
int hLen;
int j;
int j, ret;
Hmac hmac;
byte buffer[MAX_DIGEST_SIZE];
@@ -145,7 +145,9 @@ int PBKDF2(byte* output, const byte* passwd, int pLen, const byte* salt,
else
return BAD_FUNC_ARG;
HmacSetKey(&hmac, hashType, passwd, pLen);
ret = HmacSetKey(&hmac, hashType, passwd, pLen);
if (ret != 0)
return ret;
while (kLen) {
int currentLen;