| 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 | 5 |
| 6 #ifndef VBOOT_REFERENCE_RSA_H_ | 6 #ifndef VBOOT_REFERENCE_RSA_H_ |
| 7 #define VBOOT_REFERENCE_RSA_H_ | 7 #define VBOOT_REFERENCE_RSA_H_ |
| 8 | 8 |
| 9 #ifndef VBOOT_REFERENCE_CRYPTOLIB_H_ | 9 #ifndef VBOOT_REFERENCE_CRYPTOLIB_H_ |
| 10 #error "Do not include this file directly. Use cryptolib.h instead." | 10 #error "Do not include this file directly. Use cryptolib.h instead." |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 uint32_t* n; /* modulus as little endian array */ | 28 uint32_t* n; /* modulus as little endian array */ |
| 29 uint32_t* rr; /* R^2 as little endian array */ | 29 uint32_t* rr; /* R^2 as little endian array */ |
| 30 int algorithm; /* Algorithm to use when verifying binaries with the key */ | 30 int algorithm; /* Algorithm to use when verifying binaries with the key */ |
| 31 } RSAPublicKey; | 31 } RSAPublicKey; |
| 32 | 32 |
| 33 /* Verify a RSA PKCS1.5 signature [sig] of [sig_type] and length [sig_len] | 33 /* Verify a RSA PKCS1.5 signature [sig] of [sig_type] and length [sig_len] |
| 34 * against an expected [hash] using [key]. Returns 0 on failure, 1 on success. | 34 * against an expected [hash] using [key]. Returns 0 on failure, 1 on success. |
| 35 */ | 35 */ |
| 36 int RSAVerify(const RSAPublicKey *key, | 36 int RSAVerify(const RSAPublicKey *key, |
| 37 const uint8_t* sig, | 37 const uint8_t* sig, |
| 38 const int sig_len, | 38 const uint32_t sig_len, |
| 39 const uint8_t sig_type, | 39 const uint8_t sig_type, |
| 40 const uint8_t* hash); | 40 const uint8_t* hash); |
| 41 | 41 |
| 42 /* Perform RSA signature verification on [buf] of length [len] against expected | 42 /* Perform RSA signature verification on [buf] of length [len] against expected |
| 43 * signature [sig] using signature algorithm [algorithm]. The public key used | 43 * signature [sig] using signature algorithm [algorithm]. The public key used |
| 44 * for verification can either be in the form of a pre-process key blob | 44 * for verification can either be in the form of a pre-process key blob |
| 45 * [key_blob] or RSAPublicKey structure [key]. One of [key_blob] or [key] must | 45 * [key_blob] or RSAPublicKey structure [key]. One of [key_blob] or [key] must |
| 46 * be non-NULL, and the other NULL or the function will fail. | 46 * be non-NULL, and the other NULL or the function will fail. |
| 47 * | 47 * |
| 48 * Returns 1 on verification success, 0 on verification failure or invalid | 48 * Returns 1 on verification success, 0 on verification failure or invalid |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 83 |
| 84 /* Create a RSAPublic key structure from binary blob [buf] of length | 84 /* Create a RSAPublic key structure from binary blob [buf] of length |
| 85 * [len]. | 85 * [len]. |
| 86 * | 86 * |
| 87 * Caller owns the returned key and must free it. | 87 * Caller owns the returned key and must free it. |
| 88 */ | 88 */ |
| 89 RSAPublicKey* RSAPublicKeyFromBuf(const uint8_t* buf, int len); | 89 RSAPublicKey* RSAPublicKeyFromBuf(const uint8_t* buf, int len); |
| 90 | 90 |
| 91 | 91 |
| 92 #endif /* VBOOT_REFERENCE_RSA_H_ */ | 92 #endif /* VBOOT_REFERENCE_RSA_H_ */ |
| OLD | NEW |