10
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
13
#include <ipxe/crypto.h>
15
/** SHA-256 number of rounds */
16
#define SHA256_ROUNDS 64
18
/** An SHA-256 digest */
19
struct sha256_digest {
24
/** An SHA-256 data block */
30
/** Final block structure */
39
/** SHA-256 digest and data block
41
* The order of fields within this structure is designed to minimise
44
struct sha256_digest_data {
45
/** Digest of data already processed */
46
struct sha256_digest digest;
47
/** Accumulated data */
48
union sha256_block data;
49
} __attribute__ (( packed ));
51
/** SHA-256 digest and data block */
52
union sha256_digest_data_dwords {
53
/** Digest and data block */
54
struct sha256_digest_data dd;
56
uint32_t dword[ sizeof ( struct sha256_digest_data ) /
57
sizeof ( uint32_t ) ];
60
/** An SHA-256 context */
61
struct sha256_context {
62
/** Amount of accumulated data */
66
/** Digest and accumulated data */
67
union sha256_digest_data_dwords ddd;
68
} __attribute__ (( packed ));
70
/** SHA-256 context size */
71
#define SHA256_CTX_SIZE sizeof ( struct sha256_context )
73
/** SHA-256 digest size */
74
#define SHA256_DIGEST_SIZE sizeof ( struct sha256_digest )
76
/** SHA-224 digest size */
77
#define SHA224_DIGEST_SIZE ( SHA256_DIGEST_SIZE * 224 / 256 )
79
extern void sha256_family_init ( struct sha256_context *context,
80
const struct sha256_digest *init,
82
extern void sha256_update ( void *ctx, const void *data, size_t len );
83
extern void sha256_final ( void *ctx, void *out );
85
extern struct digest_algorithm sha256_algorithm;
86
extern struct digest_algorithm sha224_algorithm;
88
#endif /* _IPXE_SHA256_H */