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 * Host functions for signature generation. | 5 * Host functions for signature generation. |
6 */ | 6 */ |
7 | 7 |
8 /* TODO: change all 'return 0', 'return 1' into meaningful return codes */ | 8 /* TODO: change all 'return 0', 'return 1' into meaningful return codes */ |
9 | 9 |
10 #define OPENSSL_NO_SHA | 10 #define OPENSSL_NO_SHA |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 sig = SignatureAlloc(siglen_map[key_algorithm], size); | 259 sig = SignatureAlloc(siglen_map[key_algorithm], size); |
260 if (!sig) { | 260 if (!sig) { |
261 Free(signature_digest); | 261 Free(signature_digest); |
262 return NULL; | 262 return NULL; |
263 } | 263 } |
264 | 264 |
265 /* Sign the signature_digest into our output buffer */ | 265 /* Sign the signature_digest into our output buffer */ |
266 rv = InvokeExternalSigner(signature_digest_len, /* Input length */ | 266 rv = InvokeExternalSigner(signature_digest_len, /* Input length */ |
267 signature_digest, /* Input data */ | 267 signature_digest, /* Input data */ |
268 GetSignatureData(sig), /* Output sig */ | 268 GetSignatureData(sig), /* Output sig */ |
269 (sizeof(VbSignature) + /* Max Output sig size. */ | 269 siglen_map[key_algorithm], /* Max Output sig size */ |
270 siglen_map[key_algorithm]) , | |
271 key_file, /* Key file to use */ | 270 key_file, /* Key file to use */ |
272 external_signer); /* External cmd to invoke */ | 271 external_signer); /* External cmd to invoke */ |
273 Free(signature_digest); | 272 Free(signature_digest); |
274 | 273 |
275 if (-1 == rv) { | 274 if (-1 == rv) { |
276 VBDEBUG(("SignatureBuf(): RSA_private_encrypt() failed.\n")); | 275 VBDEBUG(("SignatureBuf(): RSA_private_encrypt() failed.\n")); |
277 Free(sig); | 276 Free(sig); |
278 return NULL; | 277 return NULL; |
279 } | 278 } |
280 | 279 |
281 /* Return the signature */ | 280 /* Return the signature */ |
282 return sig; | 281 return sig; |
283 } | 282 } |
OLD | NEW |