host_keyblock.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
  2. * Use of this source code is governed by a BSD-style license that can be
  3. * found in the LICENSE file.
  4. *
  5. * Host-side functions for verified boot.
  6. */
  7. #ifndef VBOOT_REFERENCE_HOST_KEYBLOCK_H_
  8. #define VBOOT_REFERENCE_HOST_KEYBLOCK_H_
  9. #include "host_key.h"
  10. #include "vboot_struct.h"
  11. struct vb2_keyblock;
  12. /**
  13. * Create a keyblock header
  14. *
  15. * @param data_key Data key to store in keyblock
  16. * @param signing_key Key to sign keyblock with. May be NULL if keyblock
  17. * only needs a hash digest.
  18. * @param flags Keyblock flags
  19. *
  20. * @return The keyblock, or NULL if error. Caller must free() it.
  21. */
  22. struct vb2_keyblock *vb2_create_keyblock(
  23. const struct vb2_packed_key *data_key,
  24. const struct vb2_private_key *signing_key,
  25. uint32_t flags);
  26. /**
  27. * Create a keyblock header using an external signer for all private key
  28. * operations.
  29. *
  30. * @param data_key Data key to store in keyblock
  31. * @param signing_key_pem_file Filename of private key
  32. * @param algorithm Signing algorithm index
  33. * @param flags Keyblock flags
  34. * @param external_signer Path to external signer program
  35. *
  36. * @return The keyblock, or NULL if error. Caller must free() it.
  37. */
  38. struct vb2_keyblock *vb2_create_keyblock_external(
  39. const struct vb2_packed_key *data_key,
  40. const char *signing_key_pem_file,
  41. uint32_t algorithm,
  42. uint32_t flags,
  43. const char *external_signer);
  44. /**
  45. * Read a keyblock from a .keyblock file.
  46. *
  47. * @param filename File to read keyblock from
  48. *
  49. * @return The keyblock, or NULL if error. Caller must free() it.
  50. */
  51. struct vb2_keyblock *vb2_read_keyblock(const char *filename);
  52. /**
  53. * Write a keyblock to a file in .keyblock format.
  54. *
  55. * @param filename Filename to write
  56. * @param keyblock Keyblock to write
  57. *
  58. * @return VB2_SUCCESS, or non-zero if error.
  59. */
  60. int vb2_write_keyblock(const char *filename,
  61. const struct vb2_keyblock *keyblock);
  62. #endif /* VBOOT_REFERENCE_HOST_KEYBLOCK_H_ */