vb1_helper.h 2.3 KB

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