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 #ifndef VBOOT_REFERENCE_VB1_HELPER_H_ 6 #define VBOOT_REFERENCE_VB1_HELPER_H_ 7 8 struct vb2_kernel_preamble; 9 struct vb2_keyblock; 10 struct vb2_packed_key; 11 12 /* Display a public key with variable indentation */ 13 void show_pubkey(const struct vb2_packed_key *pubkey, const char *sp); 14 15 /* Other random functions needed for backward compatibility */ 16 17 uint8_t *ReadConfigFile(const char *config_file, uint32_t *config_size); 18 19 uint8_t *CreateKernelBlob(uint8_t *vmlinuz_buf, uint32_t vmlinuz_size, 20 enum arch_t arch, uint64_t kernel_body_load_address, 21 uint8_t *config_data, uint32_t config_size, 22 uint8_t *bootloader_data, uint32_t bootloader_size, 23 uint32_t *blob_size_ptr); 24 25 uint8_t *SignKernelBlob(uint8_t *kernel_blob, 26 uint32_t kernel_size, 27 uint32_t padding, 28 int version, 29 uint64_t kernel_body_load_address, 30 struct vb2_keyblock *keyblock, 31 struct vb2_private_key *signpriv_key, 32 uint32_t flags, 33 uint32_t *vblock_size_ptr); 34 35 int WriteSomeParts(const char *outfile, 36 void *part1_data, uint32_t part1_size, 37 void *part2_data, uint32_t part2_size); 38 39 /** 40 * Unpack a kernel partition. 41 * 42 * @param kpart_data Kernel partition data 43 * @param kpart_size Size of kernel partition data in bytes 44 * @param keyblock_ptr Pointer to keyblock stored here on exit 45 * @param preamble_ptr Pointer to premable stored here on exit 46 * @param blob_size_ptr Size of kernel data blob stored here on exit 47 * 48 * @return A pointer to the kernel data blob, or NULL if error. 49 */ 50 uint8_t *unpack_kernel_partition(uint8_t *kpart_data, 51 uint32_t kpart_size, 52 struct vb2_keyblock **keyblock_ptr, 53 struct vb2_kernel_preamble **preamble_ptr, 54 uint32_t *blob_size_ptr); 55 56 int UpdateKernelBlobConfig(uint8_t *kblob_data, uint32_t kblob_size, 57 uint8_t *config_data, uint32_t config_size); 58 59 int VerifyKernelBlob(uint8_t *kernel_blob, 60 uint32_t kernel_size, 61 struct vb2_packed_key *signpub_key, 62 const char *keyblock_outfile, 63 uint32_t min_version); 64 65 uint64_t kernel_cmd_line_offset(const struct vb2_kernel_preamble *preamble); 66 67 #endif /* VBOOT_REFERENCE_VB1_HELPER_H_ */ 68