Commit 03d7db56 authored by Corentin LABBE's avatar Corentin LABBE Committed by Herbert Xu

crypto: hmac - add hmac IPAD/OPAD constant

Many HMAC users directly use directly 0x36/0x5c values.
It's better with crypto to use a name instead of directly some crypto
constant.

This patch simply add HMAC_IPAD_VALUE/HMAC_OPAD_VALUE defines in a new
include file "crypto/hmac.h" and use them in crypto/hmac.c
Signed-off-by: default avatarCorentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 9417cd1c
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
* *
*/ */
#include <crypto/hmac.h>
#include <crypto/internal/hash.h> #include <crypto/internal/hash.h>
#include <crypto/scatterwalk.h> #include <crypto/scatterwalk.h>
#include <linux/err.h> #include <linux/err.h>
...@@ -74,8 +75,8 @@ static int hmac_setkey(struct crypto_shash *parent, ...@@ -74,8 +75,8 @@ static int hmac_setkey(struct crypto_shash *parent,
memcpy(opad, ipad, bs); memcpy(opad, ipad, bs);
for (i = 0; i < bs; i++) { for (i = 0; i < bs; i++) {
ipad[i] ^= 0x36; ipad[i] ^= HMAC_IPAD_VALUE;
opad[i] ^= 0x5c; opad[i] ^= HMAC_OPAD_VALUE;
} }
return crypto_shash_init(shash) ?: return crypto_shash_init(shash) ?:
......
#ifndef _CRYPTO_HMAC_H
#define _CRYPTO_HMAC_H
#define HMAC_IPAD_VALUE 0x36
#define HMAC_OPAD_VALUE 0x5c
#endif /* _CRYPTO_HMAC_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment