summaryrefslogtreecommitdiff
path: root/host/lib/include/host_keyblock.h
blob: 21257965d93e24ff9215e713fc07e71e6dee37fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* Copyright (c) 2010 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.
 *
 * Host-side functions for verified boot.
 */

#ifndef VBOOT_REFERENCE_HOST_KEYBLOCK_H_
#define VBOOT_REFERENCE_HOST_KEYBLOCK_H_

#include "host_key.h"
#include "vboot_struct.h"

struct vb2_keyblock;

/**
 * Create a keyblock header
 *
 * @param data_key	Data key to store in keyblock
 * @param signing_key	Key to sign keyblock with.  May be NULL if keyblock
 *			only needs a hash digest.
 * @param flags		Keyblock flags
 *
 * @return The keyblock, or NULL if error.  Caller must free() it.
 */
struct vb2_keyblock *vb2_create_keyblock(
		const struct vb2_packed_key *data_key,
		const struct vb2_private_key *signing_key,
		uint32_t flags);

/**
 * Create a keyblock header using an external signer for all private key
 * operations.
 *
 * @param data_key		Data key to store in keyblock
 * @param signing_key_pem_file	Filename of private key
 * @param algorithm		Signing algorithm index
 * @param flags			Keyblock flags
 * @param external_signer	Path to external signer program
 *
 * @return The keyblock, or NULL if error.  Caller must free() it.
 */
struct vb2_keyblock *vb2_create_keyblock_external(
		const struct vb2_packed_key *data_key,
		const char *signing_key_pem_file,
		uint32_t algorithm,
		uint32_t flags,
		const char *external_signer);

/**
 * Read a keyblock from a .keyblock file.
 *
 * @param filename	File to read keyblock from
 *
 * @return The keyblock, or NULL if error.  Caller must free() it.
 */
struct vb2_keyblock *vb2_read_keyblock(const char *filename);

/**
 * Write a keyblock to a file in .keyblock format.
 *
 * @param filename	Filename to write
 * @param keyblock	Keyblock to write
 *
 * @return VB2_SUCCESS, or non-zero if error.
 */
int vb2_write_keyblock(const char *filename,
		       const struct vb2_keyblock *keyblock);

#endif  /* VBOOT_REFERENCE_HOST_KEYBLOCK_H_ */