From f318ee205cc8d92def925c6158272da8a63bf1ed Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Tue, 23 Sep 2014 14:30:30 -0700 Subject: futility: implement vbutil_kernel using buffers, not files The original vbutil_kernel command used file read and write to make changes. Futility prefers to use memory-mapped files. This rewrites cmd_vbutil_kernel.c to use that scheme. BUG=none BRANCH=ToT TEST=make runtests The original cmd_vbutil_kernel.c is renamed, and a test written to ensure that the refactored version produces identical results. Signed-off-by: Bill Richardson Change-Id: Ic6c3e12429a5dcb271f8136a9edac70807d66120 Reviewed-on: https://chromium-review.googlesource.com/219647 Reviewed-by: Randall Spangler --- futility/vb1_helper.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 futility/vb1_helper.h (limited to 'futility/vb1_helper.h') diff --git a/futility/vb1_helper.h b/futility/vb1_helper.h new file mode 100644 index 00000000..fd976e0e --- /dev/null +++ b/futility/vb1_helper.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2014 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#ifndef VBOOT_REFERENCE_FUTILITY_VB1_HELPER_H_ +#define VBOOT_REFERENCE_FUTILITY_VB1_HELPER_H_ + +uint8_t *ReadConfigFile(const char *config_file, uint64_t *config_size); + +uint8_t *CreateKernelBlob(uint8_t *vmlinuz_buf, uint64_t vmlinuz_size, + enum arch_t arch, uint64_t kernel_body_load_address, + uint8_t *config_data, uint64_t config_size, + uint8_t *bootloader_data, uint64_t bootloader_size, + uint64_t *blob_size_ptr); + +uint8_t *SignKernelBlob(uint8_t *kernel_blob, uint64_t kernel_size, + uint64_t padding, + int version, uint64_t kernel_body_load_address, + VbKeyBlockHeader *keyblock, VbPrivateKey *signpriv_key, + uint64_t *vblock_size_ptr); + +int WriteSomeParts(const char *outfile, + void *part1_data, uint64_t part1_size, + void *part2_data, uint64_t part2_size); + +uint8_t *UnpackKPart(uint8_t *kpart_data, uint64_t kpart_size, + uint64_t padding, + VbKeyBlockHeader **keyblock_ptr, + VbKernelPreambleHeader **preamble_ptr, + uint64_t *blob_size_ptr); + +int UpdateKernelBlobConfig(uint8_t *kblob_data, uint64_t kblob_size, + uint8_t *config_data, uint64_t config_size); + +int VerifyKernelBlob(uint8_t *kernel_blob, + uint64_t kernel_size, + VbPublicKey *signpub_key, + const char *keyblock_outfile, + uint64_t min_version); + +uint64_t KernelCmdLineOffset(VbKernelPreambleHeader *preamble); + +#endif /* VBOOT_REFERENCE_FUTILITY_VB1_HELPER_H_ */ -- cgit v1.2.1