Debian Codegraph @

3rdparty/vboot/firmware/2lib/include/2sha_private.h

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