Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Corentin LABBE and committed by
Herbert Xu
03d7db56 9417cd1c

+10 -2
+3 -2
crypto/hmac.c
··· 16 16 * 17 17 */ 18 18 19 + #include <crypto/hmac.h> 19 20 #include <crypto/internal/hash.h> 20 21 #include <crypto/scatterwalk.h> 21 22 #include <linux/err.h> ··· 75 74 memcpy(opad, ipad, bs); 76 75 77 76 for (i = 0; i < bs; i++) { 78 - ipad[i] ^= 0x36; 79 - opad[i] ^= 0x5c; 77 + ipad[i] ^= HMAC_IPAD_VALUE; 78 + opad[i] ^= HMAC_OPAD_VALUE; 80 79 } 81 80 82 81 return crypto_shash_init(shash) ?:
+7
include/crypto/hmac.h
··· 1 + #ifndef _CRYPTO_HMAC_H 2 + #define _CRYPTO_HMAC_H 3 + 4 + #define HMAC_IPAD_VALUE 0x36 5 + #define HMAC_OPAD_VALUE 0x5c 6 + 7 + #endif /* _CRYPTO_HMAC_H */