hmac: add comments explaining why each buffer needs erasing
As requested in review: clarify that the padding arrays carry key material (key XOR fixed constant, trivially reversible), not just padding bytes.
This commit is contained in:
committed by
Zbigniew Jędrzejewski-Szmek
parent
0ffefb8a4d
commit
b675582861
+4
-4
@@ -17,13 +17,13 @@ void hmac_sha256(const void *key,
|
||||
uint8_t res[static SHA256_DIGEST_SIZE]) {
|
||||
|
||||
uint8_t inner_padding[HMAC_BLOCK_SIZE] = { };
|
||||
CLEANUP_ERASE(inner_padding);
|
||||
CLEANUP_ERASE(inner_padding); /* carries key ^ 0x36, trivially reversible to the original key */
|
||||
uint8_t outer_padding[HMAC_BLOCK_SIZE] = { };
|
||||
CLEANUP_ERASE(outer_padding);
|
||||
CLEANUP_ERASE(outer_padding); /* carries key ^ 0x5c, trivially reversible to the original key */
|
||||
uint8_t replacement_key[SHA256_DIGEST_SIZE];
|
||||
CLEANUP_ERASE(replacement_key);
|
||||
CLEANUP_ERASE(replacement_key); /* SHA-256 of the key when key_size > block size */
|
||||
struct sha256_ctx hash;
|
||||
CLEANUP_ERASE(hash);
|
||||
CLEANUP_ERASE(hash); /* intermediate state derived from key material */
|
||||
|
||||
assert(key);
|
||||
assert(key_size > 0);
|
||||
|
||||
Reference in New Issue
Block a user