aboutsummaryrefslogtreecommitdiffstats
path: root/lib/crypto/c_src
diff options
context:
space:
mode:
authorAndreas Schultz <[email protected]>2012-07-19 12:12:17 +0200
committerIngela Anderton Andin <[email protected]>2012-08-22 14:00:42 +0200
commit29ecf2ad4b046b6b76b9cefb18fcc1d635a06037 (patch)
treef803b2577a79af72e68526bbc1ecb7a160c7c173 /lib/crypto/c_src
parent7553817a73f8409a789496964a5292627002e785 (diff)
downloadotp-29ecf2ad4b046b6b76b9cefb18fcc1d635a06037.tar.gz
otp-29ecf2ad4b046b6b76b9cefb18fcc1d635a06037.tar.bz2
otp-29ecf2ad4b046b6b76b9cefb18fcc1d635a06037.zip
crypto: fix hmac_sha384 and add hmac test cases from RFC-4231
Diffstat (limited to 'lib/crypto/c_src')
-rw-r--r--lib/crypto/c_src/crypto.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/crypto/c_src/crypto.c b/lib/crypto/c_src/crypto.c
index 2ae34c9741..c64ad2b82d 100644
--- a/lib/crypto/c_src/crypto.c
+++ b/lib/crypto/c_src/crypto.c
@@ -2398,13 +2398,13 @@ static void hmac_sha384(unsigned char *key, int klen,
unsigned char *hmacbuf)
{
SHA512_CTX ctx;
- char ipad[HMAC_INT_LEN];
- char opad[HMAC_INT_LEN];
+ char ipad[HMAC_INT2_LEN];
+ char opad[HMAC_INT2_LEN];
unsigned char nkey[SHA384_DIGEST_LENGTH];
int i;
/* Change key if longer than 64 bytes */
- if (klen > HMAC_INT_LEN) {
+ if (klen > HMAC_INT2_LEN) {
SHA384(key, klen, nkey);
key = nkey;
klen = SHA384_DIGEST_LENGTH;
@@ -2415,19 +2415,19 @@ static void hmac_sha384(unsigned char *key, int klen,
memcpy(ipad, key, klen);
memcpy(opad, key, klen);
- for (i = 0; i < HMAC_INT_LEN; i++) {
+ for (i = 0; i < HMAC_INT2_LEN; i++) {
ipad[i] ^= HMAC_IPAD;
opad[i] ^= HMAC_OPAD;
}
/* inner SHA */
SHA384_Init(&ctx);
- SHA384_Update(&ctx, ipad, HMAC_INT_LEN);
+ SHA384_Update(&ctx, ipad, HMAC_INT2_LEN);
SHA384_Update(&ctx, dbuf, dlen);
SHA384_Final((unsigned char *) hmacbuf, &ctx);
/* outer SHA */
SHA384_Init(&ctx);
- SHA384_Update(&ctx, opad, HMAC_INT_LEN);
+ SHA384_Update(&ctx, opad, HMAC_INT2_LEN);
SHA384_Update(&ctx, hmacbuf, SHA384_DIGEST_LENGTH);
SHA384_Final((unsigned char *) hmacbuf, &ctx);
}