Randall Spangler | d183644 | 2010-06-10 09:59:04 -0700 | [diff] [blame] | 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 | |
| 8 | #ifndef VBOOT_REFERENCE_HOST_SIGNATURE_H_ |
| 9 | #define VBOOT_REFERENCE_HOST_SIGNATURE_H_ |
| 10 | |
Randall Spangler | d183644 | 2010-06-10 09:59:04 -0700 | [diff] [blame] | 11 | #include "cryptolib.h" |
| 12 | #include "host_key.h" |
| 13 | #include "utility.h" |
| 14 | #include "vboot_struct.h" |
| 15 | |
| 16 | |
| 17 | /* Initialize a signature struct. */ |
| 18 | void 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. */ |
| 23 | VbSignature* 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. */ |
| 29 | int 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 Shah | 068fc6f | 2010-10-29 10:59:50 -0700 | [diff] [blame] | 35 | * Returns NULL on error. */ |
Randall Spangler | d183644 | 2010-06-10 09:59:04 -0700 | [diff] [blame] | 36 | VbSignature* 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 Shah | 068fc6f | 2010-10-29 10:59:50 -0700 | [diff] [blame] | 42 | * Returns NULL on error. */ |
Randall Spangler | d183644 | 2010-06-10 09:59:04 -0700 | [diff] [blame] | 43 | VbSignature* CalculateSignature(const uint8_t* data, uint64_t size, |
| 44 | const VbPrivateKey* key); |
| 45 | |
Gaurav Shah | 068fc6f | 2010-10-29 10:59:50 -0700 | [diff] [blame] | 46 | /* 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. */ |
| 51 | VbSignature* 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 Spangler | d183644 | 2010-06-10 09:59:04 -0700 | [diff] [blame] | 56 | #endif /* VBOOT_REFERENCE_HOST_SIGNATURE_H_ */ |