Gaurav Shah | 8bf29d8 | 2010-01-28 19:43:24 -0800 | [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 | |
| 6 | #ifndef VBOOT_REFERENCE_SIGNATURE_DIGEST_H_ |
| 7 | #define VBOOT_REFERENCE_SIGNATURE_DIGEST_H_ |
| 8 | |
Gaurav Shah | 47b593d | 2010-08-17 15:48:22 -0700 | [diff] [blame] | 9 | #include <stdint.h> |
Gaurav Shah | 8bf29d8 | 2010-01-28 19:43:24 -0800 | [diff] [blame] | 10 | |
| 11 | /* Returns a buffer with DigestInfo (which depends on [algorithm]) |
| 12 | * prepended to [digest]. |
| 13 | */ |
Gaurav Shah | 47b593d | 2010-08-17 15:48:22 -0700 | [diff] [blame] | 14 | uint8_t* PrependDigestInfo(unsigned int algorithm, uint8_t* digest); |
Gaurav Shah | 8bf29d8 | 2010-01-28 19:43:24 -0800 | [diff] [blame] | 15 | |
Gaurav Shah | f5564fa | 2010-03-02 15:40:01 -0800 | [diff] [blame] | 16 | /* Function that outputs the message digest of the contents of a buffer in a |
| 17 | * format that can be used as input to OpenSSL for an RSA signature. |
| 18 | * Needed until the stable OpenSSL release supports SHA-256/512 digests for |
| 19 | * RSA signatures. |
| 20 | * |
| 21 | * Returns DigestInfo || Digest where DigestInfo is the OID depending on the |
| 22 | * choice of the hash algorithm (see padding.c). Caller owns the returned |
| 23 | * pointer and must Free() it. |
| 24 | */ |
Gaurav Shah | 47b593d | 2010-08-17 15:48:22 -0700 | [diff] [blame] | 25 | uint8_t* SignatureDigest(const uint8_t* buf, uint64_t len, |
| 26 | unsigned int algorithm); |
Gaurav Shah | f5564fa | 2010-03-02 15:40:01 -0800 | [diff] [blame] | 27 | |
| 28 | /* Calculates the signature on a buffer [buf] of length [len] using |
| 29 | * the private RSA key file from [key_file] and signature algorithm |
| 30 | * [algorithm]. |
| 31 | * |
| 32 | * Returns the signature. Caller owns the buffer and must Free() it. |
| 33 | */ |
Gaurav Shah | 456678b | 2010-03-10 18:38:45 -0800 | [diff] [blame] | 34 | uint8_t* SignatureBuf(const uint8_t* buf, uint64_t len, const char* key_file, |
Gaurav Shah | 47b593d | 2010-08-17 15:48:22 -0700 | [diff] [blame] | 35 | unsigned int algorithm); |
Gaurav Shah | 8bf29d8 | 2010-01-28 19:43:24 -0800 | [diff] [blame] | 36 | #endif /* VBOOT_REFERENCE_SIGNATURE_DIGEST_H_ */ |