8f3b500033d2f22c9f817fa2491522e0dc7a19eb
[vboot.git] / futility / vb1_helper.h
1 /*
2  * Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
3  * Use of this source code is governed by a BSD-style license that can be
4  * found in the LICENSE file.
5  */
6 #ifndef VBOOT_REFERENCE_FUTILITY_VB1_HELPER_H_
7 #define VBOOT_REFERENCE_FUTILITY_VB1_HELPER_H_
8
9 struct vb2_kernel_preamble;
10 struct vb2_packed_key;
11
12 /**
13  * Return the name of the vb1 crypto algorithm
14  *
15  * @param algo  Crypto algorithm
16  * @return The name of the algorithm, or "(invalid)" if algo is not valid.
17  */
18 const char *vb1_crypto_name(uint32_t algo);
19
20 /* Display a public key with variable indentation */
21 void show_pubkey(const struct vb2_packed_key *pubkey, const char *sp);
22
23 /* Other random functions needed for backward compatibility */
24
25 uint8_t *ReadConfigFile(const char *config_file, uint64_t *config_size);
26
27 uint8_t *CreateKernelBlob(uint8_t *vmlinuz_buf, uint64_t vmlinuz_size,
28                           enum arch_t arch, uint64_t kernel_body_load_address,
29                           uint8_t *config_data, uint64_t config_size,
30                           uint8_t *bootloader_data, uint64_t bootloader_size,
31                           uint64_t *blob_size_ptr);
32
33 uint8_t *SignKernelBlob(uint8_t *kernel_blob, uint64_t kernel_size,
34                         uint64_t padding,
35                         int version, uint64_t kernel_body_load_address,
36                         VbKeyBlockHeader *keyblock, VbPrivateKey *signpriv_key,
37                         uint32_t flags, uint64_t *vblock_size_ptr);
38
39 int WriteSomeParts(const char *outfile,
40                    void *part1_data, uint64_t part1_size,
41                    void *part2_data, uint64_t part2_size);
42
43 uint8_t *UnpackKPart(uint8_t *kpart_data, uint64_t kpart_size,
44                      uint64_t padding,
45                      VbKeyBlockHeader **keyblock_ptr,
46                      VbKernelPreambleHeader **preamble_ptr,
47                      uint64_t *blob_size_ptr);
48
49 int UpdateKernelBlobConfig(uint8_t *kblob_data, uint64_t kblob_size,
50                            uint8_t *config_data, uint64_t config_size);
51
52 int VerifyKernelBlob(uint8_t *kernel_blob,
53                      uint64_t kernel_size,
54                      VbPublicKey *signpub_key,
55                      const char *keyblock_outfile,
56                      uint64_t min_version);
57
58 uint64_t kernel_cmd_line_offset(const struct vb2_kernel_preamble *preamble);
59
60 #endif  /* VBOOT_REFERENCE_FUTILITY_VB1_HELPER_H_ */