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 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. */ 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 * 35 * Returns NULL on error. */ 36VbSignature* CalculateChecksum(const uint8_t* data, uint64_t size); 37 38 39/* Calculates a hash of the data using the algorithm from the specified key. 40 * Caller owns the returned pointer, and must free it with Free(). 41 * 42 * Returns NULL on error. */ 43VbSignature* CalculateHash(const uint8_t* data, uint64_t size, 44 const VbPrivateKey* key); 45 46/* Calculates a signature for the data using the specified key. 47 * Caller owns the returned pointer, and must free it with Free(). 48 * 49 * Returns NULL on error. */ 50VbSignature* CalculateSignature(const uint8_t* data, uint64_t size, 51 const VbPrivateKey* key); 52 53/* Calculates a signature for the data using the specified key and 54 * an external program. 55 * Caller owns the returned pointer, and must free it with Free(). 56 * 57 * Returns NULL on error. */ 58VbSignature* CalculateSignature_external(const uint8_t* data, uint64_t size, 59 const char* key_file, 60 uint64_t key_algorithm, 61 const char* external_signer); 62 63#endif /* VBOOT_REFERENCE_HOST_SIGNATURE_H_ */ 64