• Linus Walleij's avatar
    crypto: stm32/hash - Support Ux500 hash · b56403a2
    Linus Walleij authored
    The Ux500 has a hash block which is an ancestor to the STM32
    hash block. With some minor code path additions we can
    support also this variant in the STM32 driver. Differences:
    
    - Ux500 only supports SHA1 and SHA256 (+/- MAC) so we split
      up the algorithm registration per-algorithm and register
      each algorithm along with its MAC variant separately.
    
    - Ux500 does not have an interrupt to indicate that hash
      calculation is complete, so we add code paths to handle
      polling for completion if the interrupt is missing in the
      device tree.
    
    - Ux500 is lacking the SR status register, to check if an
      operating is complete, we need to poll the HASH_STR_DCAL
      bit in the HASH_STR register instead.
    
    - Ux500 had the resulting hash at address offset 0x0c and
      8 32bit registers ahead. We account for this with a special
      code path when reading out the hash digest.
    
    - Ux500 need a special bit set in the control register before
      performing the final hash calculation on an empty message.
    
    - Ux500 hashes on empty messages will be performed if the
      above bit is set, but are incorrect. For this reason we
      just make an inline synchronous hash using a fallback
      hash.
    
    Tested on the Ux500 Golden device with the extended tests.
    Acked-by: default avatarLionel Debieve <lionel.debieve@foss.st.com>
    Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
    Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
    b56403a2
stm32-hash.c 42.5 KB