blob: d6d4bbae2ee8b416a5a9be252d5643c5c85bc95b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
/* Copyright 2021 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
* Constants & macro for sha algorithms.
*/
#ifndef VBOOT_REFERENCE_2SHA_PRIVATE_H_
#define VBOOT_REFERENCE_2SHA_PRIVATE_H_
/* Sha256 padding is consisted of 0x80 + zeros + length of message (8 byte).
* So minimum length for padding is 9.
*/
#define SHA256_MIN_PAD_LEN 9
/* Beginning of sha256 padding is always 0x80 when messages are in bytes
*/
#define SHA256_PAD_BEGIN 0x80
extern const uint32_t vb2_sha256_h0[8];
extern const uint32_t vb2_sha256_k[64];
extern const uint32_t vb2_hash_seq[8];
extern struct vb2_sha256_context vb2_sha_ctx;
#define UNPACK32(x, str) \
{ \
*((str) + 3) = (uint8_t) ((x) ); \
*((str) + 2) = (uint8_t) ((x) >> 8); \
*((str) + 1) = (uint8_t) ((x) >> 16); \
*((str) + 0) = (uint8_t) ((x) >> 24); \
}
#define PACK32(str, x) \
{ \
*(x) = ((uint32_t) *((str) + 3) ) \
| ((uint32_t) *((str) + 2) << 8) \
| ((uint32_t) *((str) + 1) << 16) \
| ((uint32_t) *((str) + 0) << 24); \
}
void vb2_sha256_transform_hwcrypto(const uint8_t *message,
unsigned int block_nb);
#endif /* VBOOT_REFERENCE_2SHA_PRIVATE_H_ */
|