iPXE
sha256.h
Go to the documentation of this file.
1#ifndef _IPXE_SHA256_H
2#define _IPXE_SHA256_H
3
4/** @file
5 *
6 * SHA-256 algorithm
7 *
8 */
9
10FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11FILE_SECBOOT ( PERMITTED );
12
13#include <stdint.h>
14#include <ipxe/crypto.h>
15
16/** SHA-256 number of rounds */
17#define SHA256_ROUNDS 64
18
19/** An SHA-256 digest */
21 /** Hash output */
23};
24
25/** An SHA-256 data block */
27 /** Raw bytes */
28 uint8_t byte[64];
29 /** Raw dwords */
31 /** Final block structure */
32 struct {
33 /** Padding */
35 /** Length in bits */
37 } final;
38};
39
40/** SHA-256 digest and data block
41 *
42 * The order of fields within this structure is designed to minimise
43 * code size.
44 */
46 /** Digest of data already processed */
48 /** Accumulated data */
50} __attribute__ (( packed ));
51
52/** SHA-256 digest and data block */
54 /** Digest and data block */
56 /** Raw dwords */
57 uint32_t dword[ sizeof ( struct sha256_digest_data ) /
58 sizeof ( uint32_t ) ];
59};
60
61/** An SHA-256 context */
63 /** Amount of accumulated data */
64 size_t len;
65 /** Digest size */
66 size_t digestsize;
67 /** Digest and accumulated data */
69} __attribute__ (( packed ));
70
71/** SHA-256 context size */
72#define SHA256_CTX_SIZE sizeof ( struct sha256_context )
73
74/** SHA-256 block size */
75#define SHA256_BLOCK_SIZE sizeof ( union sha256_block )
76
77/** SHA-256 digest size */
78#define SHA256_DIGEST_SIZE sizeof ( struct sha256_digest )
79
80/** SHA-224 digest size */
81#define SHA224_DIGEST_SIZE ( SHA256_DIGEST_SIZE * 224 / 256 )
82
83extern void sha256_family_init ( struct sha256_context *context,
84 const struct sha256_digest *init,
85 size_t digestsize );
86extern void sha256_update ( void *ctx, const void *data, size_t len );
87extern void sha256_final ( void *ctx, void *out );
88
91
92#endif /* _IPXE_SHA256_H */
struct golan_eq_context ctx
Definition CIB_PRM.h:0
__be32 out[4]
Definition CIB_PRM.h:8
unsigned int uint32_t
Definition stdint.h:12
unsigned long long uint64_t
Definition stdint.h:13
unsigned char uint8_t
Definition stdint.h:10
ring len
Length.
Definition dwmac.h:226
uint8_t data[48]
Additional event data.
Definition ena.h:11
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
#define __attribute__(x)
Definition compiler.h:10
Cryptographic API.
uint32_t digestsize
Digest size (i.e.
Definition pccrr.h:1
struct digest_algorithm sha224_algorithm
SHA-224 algorithm.
Definition sha224.c:64
struct digest_algorithm sha256_algorithm
SHA-256 algorithm.
Definition sha256.c:265
void sha256_update(void *ctx, const void *data, size_t len)
Accumulate data with SHA-256 algorithm.
Definition sha256.c:217
void sha256_final(void *ctx, void *out)
Generate SHA-256 digest.
Definition sha256.c:240
void sha256_family_init(struct sha256_context *context, const struct sha256_digest *init, size_t digestsize)
Initialise SHA-256 family algorithm.
Definition sha256.c:93
A message digest algorithm.
Definition crypto.h:19
An SHA-256 context.
Definition sha256.h:62
size_t digestsize
Digest size.
Definition sha256.h:66
size_t len
Amount of accumulated data.
Definition sha256.h:64
union sha256_digest_data_dwords ddd
Digest and accumulated data.
Definition sha256.h:68
SHA-256 digest and data block.
Definition sha256.h:45
struct sha256_digest digest
Digest of data already processed.
Definition sha256.h:47
union sha256_block data
Accumulated data.
Definition sha256.h:49
An SHA-256 digest.
Definition sha256.h:20
uint32_t h[8]
Hash output.
Definition sha256.h:22
An SHA-256 data block.
Definition sha256.h:26
uint64_t len
Length in bits.
Definition sha256.h:36
uint8_t pad[56]
Padding.
Definition sha256.h:34
uint32_t dword[16]
Raw dwords.
Definition sha256.h:30
SHA-256 digest and data block.
Definition sha256.h:53
uint32_t dword[sizeof(struct sha256_digest_data)/sizeof(uint32_t)]
Raw dwords.
Definition sha256.h:58
struct sha256_digest_data dd
Digest and data block.
Definition sha256.h:55