Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: src/platform/vboot_reference/crypto/rsa_utility.c

Issue 1430001: VBoot Reference: Fix splicing bugs in Firmware and Kernel verification. (Closed)
Patch Set: . Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 * Utility functions for message digest functions. 5 * Utility functions for message digest functions.
6 */ 6 */
7 7
8 #include "padding.h" 8 #include "padding.h"
9 #include "rsa_utility.h" 9 #include "rsa_utility.h"
10 #include "sha_utility.h" 10 #include "sha_utility.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 return 0; /* Both can't be NULL or non-NULL. */ 93 return 0; /* Both can't be NULL or non-NULL. */
94 94
95 digest = DigestBuf(buf, len, algorithm); 95 digest = DigestBuf(buf, len, algorithm);
96 success = RSAVerify(verification_key, sig, sig_size, algorithm, digest); 96 success = RSAVerify(verification_key, sig, sig_size, algorithm, digest);
97 97
98 Free(digest); 98 Free(digest);
99 if (!key) 99 if (!key)
100 RSAPublicKeyFree(verification_key); /* Only free if we allocated it. */ 100 RSAPublicKeyFree(verification_key); /* Only free if we allocated it. */
101 return success; 101 return success;
102 } 102 }
103
104 /* Version of RSAVerifyBinary_f() where instead of the raw binary blob
105 * of data, its digest is passed as the argument. */
106 int RSAVerifyBinaryWithDigest_f(const uint8_t* key_blob,
107 const RSAPublicKey* key,
108 const uint8_t* digest,
109 const uint8_t* sig,
110 int algorithm) {
111 RSAPublicKey* verification_key = NULL;
112 int key_size;
113 int sig_size;
114 int success;
115
116 if (algorithm >= kNumAlgorithms)
117 return 0; /* Invalid algorithm. */
118 key_size = RSAProcessedKeySize(algorithm);
119 sig_size = siglen_map[algorithm];
120
121 if (key_blob && !key)
122 verification_key = RSAPublicKeyFromBuf(key_blob, key_size);
123 else if (!key_blob && key)
124 verification_key = (RSAPublicKey*) key; /* Supress const warning. */
125 else
126 return 0; /* Both can't be NULL or non-NULL. */
127
128 success = RSAVerify(verification_key, sig, sig_size, algorithm, digest);
129
130 if (!key)
131 RSAPublicKeyFree(verification_key); /* Only free if we allocated it. */
132 return success;
133 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698