Similar to the oneshot helper for sha256, add helpers for sha384 and sha512.
The helper functions don't use the ARMv8 Crypto Extensions, yet. Signed-off-by: Michael Tretter <[email protected]> --- include/crypto/pbl-sha.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/crypto/pbl-sha.h b/include/crypto/pbl-sha.h index dbfb79647462..8a20e0a2b84b 100644 --- a/include/crypto/pbl-sha.h +++ b/include/crypto/pbl-sha.h @@ -28,7 +28,29 @@ int sha512_init(struct digest *desc); int sha512_update(struct digest *desc, const void *data, unsigned long len); int sha512_final(struct digest *desc, u8 *out); +static inline void pbl_sha512(const void *buf, size_t len, + u8 out[SHA512_DIGEST_SIZE]) +{ + struct sha512_state state = { }; + struct digest d = { .ctx = &state, .length = SHA512_DIGEST_SIZE }; + + sha512_init(&d); + sha512_update(&d, buf, len); + sha512_final(&d, out); +} + int sha384_init(struct digest *desc); int sha384_final(struct digest *desc, u8 *out); +static inline void pbl_sha384(const void *buf, size_t len, + u8 out[SHA384_DIGEST_SIZE]) +{ + struct sha512_state state = { }; + struct digest d = { .ctx = &state, .length = SHA384_DIGEST_SIZE }; + + sha384_init(&d); + sha512_update(&d, buf, len); + sha384_final(&d, out); +} + #endif /* __PBL-SHA_H_ */ -- 2.47.3
