blob: f08547c80e6391872b80cc01b66da35c6502fcf3 [file] [log] [blame]
Randall Spanglerd1836442010-06-10 09:59:04 -07001/* 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
8#ifndef VBOOT_REFERENCE_HOST_SIGNATURE_H_
9#define VBOOT_REFERENCE_HOST_SIGNATURE_H_
10
Randall Spanglerd1836442010-06-10 09:59:04 -070011#include "cryptolib.h"
12#include "host_key.h"
13#include "utility.h"
14#include "vboot_struct.h"
15
16
17/* Initialize a signature struct. */
18void SignatureInit(VbSignature* sig, uint8_t* sig_data,
19 uint64_t sig_size, uint64_t data_size);
20
21
22/* Allocate a new signature with space for a [sig_size] byte signature. */
23VbSignature* SignatureAlloc(uint64_t sig_size, uint64_t data_size);
24
25
26/* Copy a signature key from [src] to [dest].
27 *
28 * Returns 0 if success, non-zero if error. */
29int SignatureCopy(VbSignature* dest, const VbSignature* src);
30
31
32/* Calculates a SHA-512 checksum.
33 * Caller owns the returned pointer, and must free it with Free().
34 *
Gaurav Shah068fc6f2010-10-29 10:59:50 -070035 * Returns NULL on error. */
Randall Spanglerd1836442010-06-10 09:59:04 -070036VbSignature* CalculateChecksum(const uint8_t* data, uint64_t size);
37
38
39/* Calculates a signature for the data using the specified key.
40 * Caller owns the returned pointer, and must free it with Free().
41 *
Gaurav Shah068fc6f2010-10-29 10:59:50 -070042 * Returns NULL on error. */
Randall Spanglerd1836442010-06-10 09:59:04 -070043VbSignature* CalculateSignature(const uint8_t* data, uint64_t size,
44 const VbPrivateKey* key);
45
Gaurav Shah068fc6f2010-10-29 10:59:50 -070046/* Calculates a signature for the data using the specified key and
47 * an external program.
48 * Caller owns the returned pointer, and must free it with Free().
49 *
50 * Returns NULL on error. */
51VbSignature* CalculateSignature_external(const uint8_t* data, uint64_t size,
52 const char* key_file,
53 uint64_t key_algorithm,
54 const char* external_signer);
55
Randall Spanglerd1836442010-06-10 09:59:04 -070056#endif /* VBOOT_REFERENCE_HOST_SIGNATURE_H_ */