iPXE
sha512.h
Go to the documentation of this file.
1#ifndef _IPXE_SHA512_H
2#define _IPXE_SHA512_H
3
4/** @file
5 *
6 * SHA-512 algorithm
7 *
8 */
9
10FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11FILE_SECBOOT ( PERMITTED );
12
13#include <stdint.h>
14#include <endian.h>
15#include <ipxe/crypto.h>
16#include <ipxe/mdhash.h>
17
18/** SHA-512 number of rounds */
19#define SHA512_ROUNDS 80
20
21/** An SHA-512 digest */
23 /** Hash output */
25};
26
27/** An SHA-512 data block */
29 /** Raw bytes */
30 uint8_t byte[128];
31 /** Raw qwords */
33 /** Final block structure */
34 struct {
35 /** Padding */
37 /** Length in bits */
38 struct {
39 /** High 64 bits (unused by iPXE) */
41 /** Low 64 bits (unused by iPXE) */
43 } __attribute__ (( packed )) len;
44 } final;
45};
46
47/** SHA-512 digest and data block
48 *
49 * The order of fields within this structure is designed to minimise
50 * code size.
51 */
53 /** Digest of data already processed */
55 /** Accumulated data */
57} __attribute__ (( packed ));
58
59/** SHA-512 context size */
60#define SHA512_CTX_SIZE MDHASH_CTX_SIZE ( struct sha512_digest_data )
61
62/** SHA-512 block size */
63#define SHA512_BLOCK_SIZE sizeof ( union sha512_block )
64
65/** SHA-512 digest size */
66#define SHA512_DIGEST_SIZE sizeof ( struct sha512_digest )
67
68/** SHA-384 digest size */
69#define SHA384_DIGEST_SIZE ( SHA512_DIGEST_SIZE * 384 / 512 )
70
71/** SHA-512/256 digest size */
72#define SHA512_256_DIGEST_SIZE ( SHA512_DIGEST_SIZE * 256 / 512 )
73
74/** SHA-512/224 digest size */
75#define SHA512_224_DIGEST_SIZE ( SHA512_DIGEST_SIZE * 224 / 512 )
76
77extern void sha512_compress ( struct sha512_digest_data *dd,
78 const struct sha512_digest *digest );
79
80/** Define a SHA-512 family digest algorithm */
81#define SHA512_ALGORITHM( _name, _digest, _init, _digestsize ) \
82 MDHASH_ALGORITHM( _name, _digest, sha512_compress, \
83 __BIG_ENDIAN, struct sha512_digest_data, \
84 _init, _digestsize )
85
90
91#endif /* IPXE_SHA512_H */
unsigned long long uint64_t
Definition stdint.h:13
unsigned char uint8_t
Definition stdint.h:10
ring len
Length.
Definition dwmac.h:226
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:921
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:951
#define __attribute__(x)
Definition compiler.h:10
Cryptographic API.
Merkle-Damgård hash algorithms.
struct digest_algorithm sha512_224_algorithm
struct digest_algorithm sha512_algorithm
struct digest_algorithm sha512_256_algorithm
struct digest_algorithm sha384_algorithm
void sha512_compress(struct sha512_digest_data *dd, const struct sha512_digest *digest)
Calculate SHA-512 digest of accumulated data.
Definition sha512.c:101
A message digest algorithm.
Definition crypto.h:19
SHA-512 digest and data block.
Definition sha512.h:52
struct sha512_digest digest
Digest of data already processed.
Definition sha512.h:54
union sha512_block data
Accumulated data.
Definition sha512.h:56
An SHA-512 digest.
Definition sha512.h:22
uint64_t h[8]
Hash output.
Definition sha512.h:24
An SHA-512 data block.
Definition sha512.h:28
uint64_t hi
High 64 bits (unused by iPXE).
Definition sha512.h:40
uint64_t qword[16]
Raw qwords.
Definition sha512.h:32
uint8_t pad[112]
Padding.
Definition sha512.h:36
uint64_t lo
Low 64 bits (unused by iPXE).
Definition sha512.h:42