Skip to content

Commit 26f7120

Browse files
atenartherbertx
authored andcommitted
crypto: sha512_generic - add a sha384 0-length pre-computed hash
This patch adds the sha384 pre-computed 0-length hash so that device drivers can use it when an hardware engine does not support computing a hash from a 0 length input. Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 87eee12 commit 26f7120

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

‎crypto/sha512_generic.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@
2323
#include <asm/byteorder.h>
2424
#include <asm/unaligned.h>
2525

26+
const u8 sha384_zero_message_hash[SHA384_DIGEST_SIZE] = {
27+
0x38, 0xb0, 0x60, 0xa7, 0x51, 0xac, 0x96, 0x38,
28+
0x4c, 0xd9, 0x32, 0x7e, 0xb1, 0xb1, 0xe3, 0x6a,
29+
0x21, 0xfd, 0xb7, 0x11, 0x14, 0xbe, 0x07, 0x43,
30+
0x4c, 0x0c, 0xc7, 0xbf, 0x63, 0xf6, 0xe1, 0xda,
31+
0x27, 0x4e, 0xde, 0xbf, 0xe7, 0x6f, 0x65, 0xfb,
32+
0xd5, 0x1a, 0xd2, 0xf1, 0x48, 0x98, 0xb9, 0x5b
33+
};
34+
EXPORT_SYMBOL_GPL(sha384_zero_message_hash);
35+
2636
const u8 sha512_zero_message_hash[SHA512_DIGEST_SIZE] = {
2737
0xcf, 0x83, 0xe1, 0x35, 0x7e, 0xef, 0xb8, 0xbd,
2838
0xf1, 0x54, 0x28, 0x50, 0xd6, 0x6d, 0x80, 0x07,

‎include/crypto/sha.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ extern const u8 sha224_zero_message_hash[SHA224_DIGEST_SIZE];
7171

7272
extern const u8 sha256_zero_message_hash[SHA256_DIGEST_SIZE];
7373

74+
extern const u8 sha384_zero_message_hash[SHA384_DIGEST_SIZE];
75+
7476
extern const u8 sha512_zero_message_hash[SHA512_DIGEST_SIZE];
7577

7678
struct sha1_state {

0 commit comments

Comments
 (0)