futility: Use only vboot 2.0 APIs for keyblocks
[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_keyblock;
11 struct vb2_packed_key;
12
13 /**
14  * Return the name of the vb1 crypto algorithm
15  *
16  * @param algo  Crypto algorithm
17  * @return The name of the algorithm, or "(invalid)" if algo is not valid.
18  */
19 const char *vb1_crypto_name(uint32_t algo);
20
21 /* Display a public key with variable indentation */
22 void show_pubkey(const struct vb2_packed_key *pubkey, const char *sp);
23
24 /* Other random functions needed for backward compatibility */
25
26 uint8_t *ReadConfigFile(const char *config_file, uint64_t *config_size);
27
28 uint8_t *CreateKernelBlob(uint8_t *vmlinuz_buf, uint64_t vmlinuz_size,
29                           enum arch_t arch, uint64_t kernel_body_load_address,
30                           uint8_t *config_data, uint64_t config_size,
31                           uint8_t *bootloader_data, uint64_t bootloader_size,
32                           uint64_t *blob_size_ptr);
33
34 uint8_t *SignKernelBlob(uint8_t *kernel_blob, uint64_t kernel_size,
35                         uint64_t padding,
36                         int version, uint64_t kernel_body_load_address,
37                         struct vb2_keyblock *keyblock,
38                         VbPrivateKey *signpriv_key,
39                         uint32_t flags, uint64_t *vblock_size_ptr);
40
41 int WriteSomeParts(const char *outfile,
42                    void *part1_data, uint64_t part1_size,
43                    void *part2_data, uint64_t part2_size);
44
45 uint8_t *UnpackKPart(uint8_t *kpart_data, uint64_t kpart_size,
46                      uint64_t padding,
47                      struct vb2_keyblock **keyblock_ptr,
48                      VbKernelPreambleHeader **preamble_ptr,
49                      uint64_t *blob_size_ptr);
50
51 int UpdateKernelBlobConfig(uint8_t *kblob_data, uint64_t kblob_size,
52                            uint8_t *config_data, uint64_t config_size);
53
54 int VerifyKernelBlob(uint8_t *kernel_blob,
55                      uint64_t kernel_size,
56                      VbPublicKey *signpub_key,
57                      const char *keyblock_outfile,
58                      uint64_t min_version);
59
60 uint64_t kernel_cmd_line_offset(const struct vb2_kernel_preamble *preamble);
61
62 #endif  /* VBOOT_REFERENCE_FUTILITY_VB1_HELPER_H_ */