OLD | NEW |
(Empty) | |
| 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_KEY_H_ |
| 9 #define VBOOT_REFERENCE_HOST_KEY_H_ |
| 10 |
| 11 #include <stdint.h> |
| 12 |
| 13 #include "cryptolib.h" |
| 14 #include "utility.h" |
| 15 #include "vboot_struct.h" |
| 16 |
| 17 |
| 18 typedef struct rsa_st RSA; |
| 19 |
| 20 /* Private key data */ |
| 21 typedef struct VbPrivateKey { |
| 22 RSA* rsa_private_key; /* Private key data */ |
| 23 uint64_t algorithm; /* Algorithm to use when signing */ |
| 24 } VbPrivateKey; |
| 25 |
| 26 |
| 27 /* Read a private key from a file. Caller owns the returned pointer, |
| 28 * and must free it with PrivateKeyFree(). */ |
| 29 VbPrivateKey* PrivateKeyRead(const char* filename, uint64_t algorithm); |
| 30 |
| 31 |
| 32 /* Free a private key. */ |
| 33 void PrivateKeyFree(VbPrivateKey* key); |
| 34 |
| 35 |
| 36 /* Initialize a public key to refer to [key_data]. */ |
| 37 void PublicKeyInit(VbPublicKey* key, uint8_t* key_data, uint64_t key_size); |
| 38 |
| 39 |
| 40 /* Allocate a new public key with space for a [key_size] byte key. */ |
| 41 VbPublicKey* PublicKeyAlloc(uint64_t key_size, uint64_t algorithm, |
| 42 uint64_t version); |
| 43 |
| 44 |
| 45 /* Copy a public key from [src] to [dest]. |
| 46 * |
| 47 * Returns 0 if success, non-zero if error. */ |
| 48 int PublicKeyCopy(VbPublicKey* dest, const VbPublicKey* src); |
| 49 |
| 50 |
| 51 /* Read a public key from a file. Caller owns the returned pointer, |
| 52 * and must free it with Free(). |
| 53 * |
| 54 * Returns NULL if error. */ |
| 55 /* TODO: should really store public keys in files as VbPublicKey */ |
| 56 VbPublicKey* PublicKeyRead(const char* filename, uint64_t algorithm, |
| 57 uint64_t version); |
| 58 |
| 59 #endif /* VBOOT_REFERENCE_HOST_KEY_H_ */ |
OLD | NEW |