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

Side by Side Diff: tests/vboot_common3_tests.c

Issue 2809037: Make vboot_reference build in MSVC command line environment. (Closed) Base URL: ssh://git@chromiumos-git/vboot_reference.git
Patch Set: Integrated trunk changes. Created 10 years, 5 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
« no previous file with comments | « tests/vboot_common2_tests.c ('k') | tests/vboot_common_tests.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 * Tests for firmware image library. 5 * Tests for firmware image library.
6 */ 6 */
7 7
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 10
(...skipping 13 matching lines...) Expand all
24 Free(newchk); 24 Free(newchk);
25 } 25 }
26 26
27 27
28 static void KeyBlockVerifyTest(const VbPublicKey* public_key, 28 static void KeyBlockVerifyTest(const VbPublicKey* public_key,
29 const VbPrivateKey* private_key, 29 const VbPrivateKey* private_key,
30 const VbPublicKey* data_key) { 30 const VbPublicKey* data_key) {
31 31
32 VbKeyBlockHeader *hdr; 32 VbKeyBlockHeader *hdr;
33 VbKeyBlockHeader *h; 33 VbKeyBlockHeader *h;
34 uint64_t hsize; 34 unsigned hsize;
35 35
36 hdr = KeyBlockCreate(data_key, private_key, 0x1234); 36 hdr = KeyBlockCreate(data_key, private_key, 0x1234);
37 TEST_NEQ((size_t)hdr, 0, "KeyBlockVerify() prerequisites"); 37 TEST_NEQ((size_t)hdr, 0, "KeyBlockVerify() prerequisites");
38 if (!hdr) 38 if (!hdr)
39 return; 39 return;
40 hsize = hdr->key_block_size; 40 hsize = (unsigned) hdr->key_block_size;
41 h = (VbKeyBlockHeader*)Malloc(hsize + 1024); 41 h = (VbKeyBlockHeader*)Malloc(hsize + 1024);
42 42
43 TEST_EQ(KeyBlockVerify(hdr, hsize, NULL), 0, 43 TEST_EQ(KeyBlockVerify(hdr, hsize, NULL), 0,
44 "KeyBlockVerify() ok using checksum"); 44 "KeyBlockVerify() ok using checksum");
45 TEST_EQ(KeyBlockVerify(hdr, hsize, public_key), 0, 45 TEST_EQ(KeyBlockVerify(hdr, hsize, public_key), 0,
46 "KeyBlockVerify() ok using key"); 46 "KeyBlockVerify() ok using key");
47 47
48 TEST_NEQ(KeyBlockVerify(hdr, hsize - 1, NULL), 0, "KeyBlockVerify() size--"); 48 TEST_NEQ(KeyBlockVerify(hdr, hsize - 1, NULL), 0, "KeyBlockVerify() size--");
49 TEST_EQ(KeyBlockVerify(hdr, hsize + 1, NULL), 0, "KeyBlockVerify() size++"); 49 TEST_EQ(KeyBlockVerify(hdr, hsize + 1, NULL), 0, "KeyBlockVerify() size++");
50 50
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 } 142 }
143 143
144 144
145 static void VerifyFirmwarePreambleTest(const VbPublicKey* public_key, 145 static void VerifyFirmwarePreambleTest(const VbPublicKey* public_key,
146 const VbPrivateKey* private_key, 146 const VbPrivateKey* private_key,
147 const VbPublicKey* kernel_subkey) { 147 const VbPublicKey* kernel_subkey) {
148 148
149 VbFirmwarePreambleHeader *hdr; 149 VbFirmwarePreambleHeader *hdr;
150 VbFirmwarePreambleHeader *h; 150 VbFirmwarePreambleHeader *h;
151 RSAPublicKey* rsa; 151 RSAPublicKey* rsa;
152 uint64_t hsize; 152 unsigned hsize;
153 153
154 /* Create a dummy signature */ 154 /* Create a dummy signature */
155 VbSignature *body_sig = SignatureAlloc(56, 78); 155 VbSignature *body_sig = SignatureAlloc(56, 78);
156 156
157 rsa = PublicKeyToRSA(public_key); 157 rsa = PublicKeyToRSA(public_key);
158 hdr = CreateFirmwarePreamble(0x1234, kernel_subkey, body_sig, private_key); 158 hdr = CreateFirmwarePreamble(0x1234, kernel_subkey, body_sig, private_key);
159 TEST_NEQ(hdr && rsa, 0, "VerifyFirmwarePreamble2() prerequisites"); 159 TEST_NEQ(hdr && rsa, 0, "VerifyFirmwarePreamble2() prerequisites");
160 if (!hdr) 160 if (!hdr)
161 return; 161 return;
162 hsize = hdr->preamble_size; 162 hsize = (unsigned) hdr->preamble_size;
163 h = (VbFirmwarePreambleHeader*)Malloc(hsize + 16384); 163 h = (VbFirmwarePreambleHeader*)Malloc(hsize + 16384);
164 164
165 TEST_EQ(VerifyFirmwarePreamble2(hdr, hsize, rsa), 0, 165 TEST_EQ(VerifyFirmwarePreamble2(hdr, hsize, rsa), 0,
166 "VerifyFirmwarePreamble2() ok using key"); 166 "VerifyFirmwarePreamble2() ok using key");
167 TEST_NEQ(VerifyFirmwarePreamble2(hdr, hsize - 1, rsa), 0, 167 TEST_NEQ(VerifyFirmwarePreamble2(hdr, hsize - 1, rsa), 0,
168 "VerifyFirmwarePreamble2() size--"); 168 "VerifyFirmwarePreamble2() size--");
169 TEST_EQ(VerifyFirmwarePreamble2(hdr, hsize + 1, rsa), 0, 169 TEST_EQ(VerifyFirmwarePreamble2(hdr, hsize + 1, rsa), 0,
170 "VerifyFirmwarePreamble2() size++"); 170 "VerifyFirmwarePreamble2() size++");
171 171
172 /* Care about major version but not minor */ 172 /* Care about major version but not minor */
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 288
289 if (signing_public_key) 289 if (signing_public_key)
290 Free(signing_public_key); 290 Free(signing_public_key);
291 if (signing_private_key) 291 if (signing_private_key)
292 Free(signing_private_key); 292 Free(signing_private_key);
293 if (data_public_key) 293 if (data_public_key)
294 Free(data_public_key); 294 Free(data_public_key);
295 295
296 return error_code; 296 return error_code;
297 } 297 }
OLDNEW
« no previous file with comments | « tests/vboot_common2_tests.c ('k') | tests/vboot_common_tests.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698