10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
13 #include <ipxe/crypto.h>
15 /** SHA-512 number of rounds */
16 #define SHA512_ROUNDS 80
18 /** An SHA-512 digest */
19 struct sha512_digest {
24 /** An SHA-512 data block */
30 /** Final block structure */
34 /** High 64 bits of length in bits */
36 /** Low 64 bits of length in bits */
41 /** SHA-512 digest and data block
43 * The order of fields within this structure is designed to minimise
46 struct sha512_digest_data {
47 /** Digest of data already processed */
48 struct sha512_digest digest;
49 /** Accumulated data */
50 union sha512_block data;
51 } __attribute__ (( packed ));
53 /** SHA-512 digest and data block */
54 union sha512_digest_data_qwords {
55 /** Digest and data block */
56 struct sha512_digest_data dd;
58 uint64_t qword[ sizeof ( struct sha512_digest_data ) /
59 sizeof ( uint64_t ) ];
62 /** An SHA-512 context */
63 struct sha512_context {
64 /** Amount of accumulated data */
68 /** Digest and accumulated data */
69 union sha512_digest_data_qwords ddq;
70 } __attribute__ (( packed ));
72 /** SHA-512 context size */
73 #define SHA512_CTX_SIZE sizeof ( struct sha512_context )
75 /** SHA-512 digest size */
76 #define SHA512_DIGEST_SIZE sizeof ( struct sha512_digest )
78 /** SHA-384 digest size */
79 #define SHA384_DIGEST_SIZE ( SHA512_DIGEST_SIZE * 384 / 512 )
81 /** SHA-512/256 digest size */
82 #define SHA512_256_DIGEST_SIZE ( SHA512_DIGEST_SIZE * 256 / 512 )
84 /** SHA-512/224 digest size */
85 #define SHA512_224_DIGEST_SIZE ( SHA512_DIGEST_SIZE * 224 / 512 )
87 extern void sha512_family_init ( struct sha512_context *context,
88 const struct sha512_digest *init,
90 extern void sha512_update ( void *ctx, const void *data, size_t len );
91 extern void sha512_final ( void *ctx, void *out );
93 extern struct digest_algorithm sha512_algorithm;
94 extern struct digest_algorithm sha384_algorithm;
95 extern struct digest_algorithm sha512_256_algorithm;
96 extern struct digest_algorithm sha512_224_algorithm;
98 #endif /* IPXE_SHA512_H */