Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
  • Eric Biggers's avatar
    crypto: hmac - remove unnecessary alignment logic · 25c74a39
    Eric Biggers authored
    
    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: default avatarEric Biggers <ebiggers@google.com>
    Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
    25c74a39