iPXE
sha1.h
Go to the documentation of this file.
1 #ifndef _IPXE_SHA1_H
2 #define _IPXE_SHA1_H
3 
4 /** @file
5  *
6  * SHA-1 algorithm
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER );
11 
12 #include <stdint.h>
13 #include <ipxe/crypto.h>
14 
15 /** An SHA-1 digest */
16 struct sha1_digest {
17  /** Hash output */
18  uint32_t h[5];
19 };
20 
21 /** An SHA-1 data block */
22 union sha1_block {
23  /** Raw bytes */
24  uint8_t byte[64];
25  /** Raw dwords */
27  /** Final block structure */
28  struct {
29  /** Padding */
30  uint8_t pad[56];
31  /** Length in bits */
33  } final;
34 };
35 
36 /** SHA-1 digest and data block
37  *
38  * The order of fields within this structure is designed to minimise
39  * code size.
40  */
42  /** Digest of data already processed */
44  /** Accumulated data */
46 } __attribute__ (( packed ));
47 
48 /** SHA-1 digest and data block */
50  /** Digest and data block */
52  /** Raw dwords */
53  uint32_t dword[ sizeof ( struct sha1_digest_data ) /
54  sizeof ( uint32_t ) ];
55 };
56 
57 /** An SHA-1 context */
58 struct sha1_context {
59  /** Amount of accumulated data */
60  size_t len;
61  /** Digest and accumulated data */
63 } __attribute__ (( packed ));
64 
65 /** SHA-1 context size */
66 #define SHA1_CTX_SIZE sizeof ( struct sha1_context )
67 
68 /** SHA-1 block size */
69 #define SHA1_BLOCK_SIZE sizeof ( union sha1_block )
70 
71 /** SHA-1 digest size */
72 #define SHA1_DIGEST_SIZE sizeof ( struct sha1_digest )
73 
74 extern struct digest_algorithm sha1_algorithm;
75 
76 extern void prf_sha1 ( const void *key, size_t key_len, const char *label,
77  const void *data, size_t data_len, void *prf,
78  size_t prf_len );
79 extern void pbkdf2_sha1 ( const void *passphrase, size_t pass_len,
80  const void *salt, size_t salt_len,
81  int iterations, void *key, size_t key_len );
82 
83 #endif /* _IPXE_SHA1_H */
An SHA-1 context.
Definition: sha1.h:58
union sha1_block data
Accumulated data.
Definition: sha1.h:45
unsigned long long uint64_t
Definition: stdint.h:13
Cryptographic API.
uint32_t data_len
Microcode data size (or 0 to indicate 2000 bytes)
Definition: ucode.h:26
uint8_t pad[56]
Padding.
Definition: sha1.h:30
static void const void size_t key_len
Definition: crypto.h:285
struct sha1_digest_data dd
Digest and data block.
Definition: sha1.h:51
struct digest_algorithm sha1_algorithm
SHA-1 algorithm.
Definition: sha1.c:257
void pbkdf2_sha1(const void *passphrase, size_t pass_len, const void *salt, size_t salt_len, int iterations, void *key, size_t key_len)
PBKDF2 key derivation function using SHA1.
Definition: sha1extra.c:148
FILE_LICENCE(GPL2_OR_LATER)
An SHA-1 digest.
Definition: sha1.h:16
union sha1_block data
Accumulated data.
Definition: sha1.h:14
SHA-1 digest and data block.
Definition: sha1.h:41
unsigned char uint8_t
Definition: stdint.h:10
uint32_t h[5]
Hash output.
Definition: sha1.h:18
SHA-1 digest and data block.
Definition: sha1.h:49
unsigned int uint32_t
Definition: stdint.h:12
An SHA-1 data block.
Definition: sha1.h:22
void prf_sha1(const void *key, size_t key_len, const char *label, const void *data, size_t data_len, void *prf, size_t prf_len)
SHA1 pseudorandom function for creating derived keys.
Definition: sha1extra.c:44
size_t len
Amount of accumulated data.
Definition: sha1.h:60
union sha1_digest_data_dwords ddd
Digest and accumulated data.
Definition: sha1.h:62
A message digest algorithm.
Definition: crypto.h:17
struct sha1_digest digest
Digest of data already processed.
Definition: sha1.h:43
unsigned long int dword
Definition: smc9000.h:40
union @382 key
Sense key.
Definition: crypto.h:284
uint64_t len
Length in bits.
Definition: sha1.h:32
union sha1_digest_data_dwords __attribute__