]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
crypto: hmac - remove unnecessary alignment logic
authorEric Biggers <ebiggers@google.com>
Thu, 19 Oct 2023 05:53:34 +0000 (22:53 -0700)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 27 Oct 2023 10:04:24 +0000 (18:04 +0800)
commit25c74a39e0f637a44982c3820a583755aedc9811
tree8524f07e4079099e8f3a39d80dbb223ffe1f96ea
parentf9dc9f2e4072de356614d95940c9d7f448a4e334
crypto: hmac - remove unnecessary alignment logic

The hmac template is setting its alignmask to that of its underlying
unkeyed hash algorithm, and it is aligning the ipad and opad fields in
its tfm context to that alignment.  However, hmac does not actually need
any sort of alignment itself, which makes this pointless except to keep
the pads aligned to what the underlying algorithm prefers.  But very few
shash algorithms actually set an alignmask, and it is being removed from
those remaining ones; also, after setkey, the pads are only passed to
crypto_shash_import and crypto_shash_export which ignore the alignmask.

Therefore, make the hmac template stop setting an alignmask and simply
use natural alignment for ipad and opad.  Note, this change also moves
the pads from the beginning of the tfm context to the end, which makes
much more sense; the variable-length fields should be at the end.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/hmac.c