OLD | NEW |
1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 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 | 2 * Use of this source code is governed by a BSD-style license that can be |
3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
4 * | 4 * |
5 * Some utility functions for use with RSA signature verification. | 5 * Some utility functions for use with RSA signature verification. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef VBOOT_REFERENCE_RSA_UTILITY_H_ | 8 #ifndef VBOOT_REFERENCE_RSA_UTILITY_H_ |
9 #define VBOOT_REFERENCE_RSA_UTILITY_H_ | 9 #define VBOOT_REFERENCE_RSA_UTILITY_H_ |
10 | 10 |
11 #include "rsa.h" | 11 #include "rsa.h" |
12 | 12 |
13 /* Returns the size of a pre-processed RSA public key in bytes with algorithm | 13 /* Returns the size of a pre-processed RSA public key in bytes with algorithm |
14 * [algorithm]. */ | 14 * [algorithm]. */ |
15 int RSAProcessedKeySize(int algorithm); | 15 int RSAProcessedKeySize(int algorithm); |
16 | 16 |
| 17 /* Deep free the contents of [key]. */ |
| 18 void RSAPublicKeyFree(RSAPublicKey* key); |
| 19 |
17 /* Create a RSAPublic key structure from binary blob [buf] of length | 20 /* Create a RSAPublic key structure from binary blob [buf] of length |
18 * [len]. */ | 21 * [len]. |
19 RSAPublicKey* RSAPublicKeyFromBuf(uint8_t* buf, int len); | 22 * |
| 23 * Caller owns the returned key and must free it. |
| 24 */ |
| 25 RSAPublicKey* RSAPublicKeyFromBuf(const uint8_t* buf, int len); |
| 26 |
| 27 /* Perform RSA signature verification on [buf] of length [len] against expected |
| 28 * signature [sig] using signature algorithm [algorithm]. The public key used |
| 29 * for verification can either be in the form of a pre-process key blob |
| 30 * [key_blob] or RSAPublicKey structure [key]. One of [key_blob] or [key] must |
| 31 * be non-NULL, and the other NULL or the function will fail. |
| 32 * |
| 33 * Returns 1 on verification success, 0 on verification failure or invalid |
| 34 * arguments. |
| 35 * |
| 36 * Note: This function is for use in the firmware and assumes all pointers point |
| 37 * to areas in the memory of the right size. |
| 38 * |
| 39 */ |
| 40 int RSAVerifyBinary_f(const uint8_t* key_blob, |
| 41 const RSAPublicKey* key, |
| 42 const uint8_t* buf, |
| 43 int len, |
| 44 const uint8_t* sig, |
| 45 int algorithm); |
20 | 46 |
21 #endif /* VBOOT_REFERENCE_RSA_UTILITY_H_ */ | 47 #endif /* VBOOT_REFERENCE_RSA_UTILITY_H_ */ |
OLD | NEW |