16 Jul, 2020

1 commit

  • Add a function sha256() which computes a SHA-256 digest in one step,
    combining sha256_init() + sha256_update() + sha256_final().

    This is similar to how we also have blake2s().

    Reviewed-by: Ard Biesheuvel
    Tested-by: Hans de Goede
    Signed-off-by: Eric Biggers
    Signed-off-by: Herbert Xu

    Eric Biggers
     

08 May, 2020

1 commit

  • The SHA-256 / SHA-224 library functions can't fail, so remove the
    useless return value.

    Also long as the declarations are being changed anyway, also fix some
    parameter names in the declarations to match the definitions.

    Signed-off-by: Eric Biggers
    Reviewed-by: Jason A. Donenfeld
    Signed-off-by: Herbert Xu

    Eric Biggers
     

05 Sep, 2019

2 commits

  • lib/crypto/sha256.c and include/crypto/sha256_base.h define
    99% identical functions to init a sha256_state struct for sha224 or
    sha256 use.

    This commit moves the functions from lib/crypto/sha256.c to
    include/crypto/sha.h (making them static inline) and makes the
    sha224/256_base_init static inline functions from
    include/crypto/sha256_base.h wrappers around the now also
    static inline include/crypto/sha.h functions.

    Signed-off-by: Hans de Goede
    Signed-off-by: Herbert Xu

    Hans de Goede
     
  • The generic sha256 implementation from lib/crypto/sha256.c uses data
    structs defined in crypto/sha.h, so lets move the function prototypes
    there too.

    Signed-off-by: Hans de Goede
    Signed-off-by: Herbert Xu

    Hans de Goede
     

30 Aug, 2019

1 commit


22 Aug, 2019

4 commits

  • Add sha224 support to the lib/crypto/sha256 library code. This will allow
    us to replace both the sha256 and sha224 parts of crypto/sha256_generic.c
    when we remove the code duplication in further patches in this series.

    Suggested-by: Eric Biggers
    Signed-off-by: Hans de Goede
    Signed-off-by: Herbert Xu

    Hans de Goede
     
  • Before this commit lib/crypto/sha256.c has only been used in the s390 and
    x86 purgatory code, make it suitable for generic use:

    * Export interesting symbols
    * Add -D__DISABLE_EXPORTS to CFLAGS_sha256.o for purgatory builds to
    avoid the exports for the purgatory builds
    * Add to lib/crypto/Makefile and crypto/Kconfig

    Signed-off-by: Hans de Goede
    Signed-off-by: Herbert Xu

    Hans de Goede
     
  • Use get/put_unaligned_be32 in lib/crypto/sha256.c to load / store data
    so that it can be used with unaligned buffers too, making it more generic.

    And use memzero_explicit for better clearing of sensitive data.

    Note unlike other patches in this series this commit actually makes
    functional changes to the sha256 code as used by the purgatory code.

    This fully aligns the lib/crypto/sha256.c sha256 implementation with the
    one from crypto/sha256_generic.c allowing us to remove the latter in
    further patches in this series.

    Signed-off-by: Hans de Goede
    Signed-off-by: Herbert Xu

    Hans de Goede
     
  • Generic crypto implementations belong under lib/crypto not directly in
    lib, likewise the header should be in include/crypto, not include/linux.

    Note that the code in lib/crypto/sha256.c is not yet available for
    generic use after this commit, it is still only used by the s390 and x86
    purgatory code. Making it suitable for generic use is done in further
    patches in this series.

    Signed-off-by: Hans de Goede
    Signed-off-by: Herbert Xu

    Hans de Goede