Debian Codegraph @

3rdparty/vboot/host/lib21/include/host_signature21.h

raw symbols SCIP
1 /* Copyright 2014 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 * Host-side functions for verified boot key structures
6 */
7
8 #ifndef VBOOT_REFERENCE_HOST_SIGNATURE2_H_
9 #define VBOOT_REFERENCE_HOST_SIGNATURE2_H_
10
11 #include "2struct.h"
12
13 struct vb2_private_key;
14 struct vb21_signature;
15
16 /**
17 * Get the digest info for a hash algorithm
18 *
19 * @param hash_alg Hash algorithm
20 * @param buf_ptr On success, points to the digest info
21 * @param size_ptr On success, contains the info size in bytes
22 * @return VB2_SUCCESS, or non-zero error code on failure.
23 */
24 vb2_error_t vb2_digest_info(enum vb2_hash_algorithm hash_alg,
25 const uint8_t **buf_ptr, uint32_t *size_ptr);
26
27 /**
28 * Sign data buffer
29 *
30 * @param sig_ptr On success, points to a newly allocated signature.
31 * Caller is responsible for calling free() on this.
32 * @param data Pointer to data to sign
33 * @param size Size of data to sign in bytes
34 * @param key Private key to use to sign data
35 * @param desc Optional description for signature. If NULL, the
36 * key description will be used.
37 * @return VB2_SUCCESS, or non-zero error code on failure.
38 */
39 vb2_error_t vb21_sign_data(struct vb21_signature **sig_ptr, const uint8_t *data,
40 uint32_t size, const struct vb2_private_key *key,
41 const char *desc);
42
43 /**
44 * Calculate the signature size for a private key.
45 *
46 * @param size_ptr On success, contains the signature size in bytes.
47 * @param key Key to calculate signature length from.
48 * @param desc Optional description for signature. If NULL, the
49 * key description will be used.
50 * @return VB2_SUCCESS, or non-zero error code on failure.
51 */
52 vb2_error_t vb21_sig_size_for_key(uint32_t *size_ptr,
53 const struct vb2_private_key *key,
54 const char *desc);
55
56 /**
57 * Calculate the total signature size for a list of keys.
58 *
59 * @param size_ptr On success, contains the signature size in bytes.
60 * @param key_list List of keys to calculate signature length from.
61 * @param key_count Number of keys.
62 * @return VB2_SUCCESS, or non-zero error code on failure.
63 */
64 vb2_error_t vb21_sig_size_for_keys(uint32_t *size_ptr,
65 const struct vb2_private_key **key_list,
66 uint32_t key_count);
67
68 /**
69 * Sign object with a key.
70 *
71 * @param buf Buffer containing object to sign, starting with
72 * common header
73 * @param sig_offset Offset in buffer at which to store signature. All
74 * data before this in the buffer will be signed.
75 * @param key Key to sign object with
76 * @param desc If non-null, description to use for signature
77 */
78 vb2_error_t vb21_sign_object(uint8_t *buf, uint32_t sig_offset,
79 const struct vb2_private_key *key,
80 const char *desc);
81
82 /**
83 * Sign object with list of keys.
84 *
85 * @param buf Buffer containing object to sign, starting with
86 * common header
87 * @param sig_offset Offset to start signatures. All data before this
88 * in the buffer will be signed.
89 * @param key_list List of keys to sign object with
90 * @param key_count Number of keys in list
91 */
92 vb2_error_t vb21_sign_object_multiple(uint8_t *buf, uint32_t sig_offset,
93 const struct vb2_private_key **key_list,
94 uint32_t key_count);
95
96 #endif /* VBOOT_REFERENCE_HOST_SIGNATURE2_H_ */