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

Side by Side Diff: tests/vboot_common2_tests.c

Issue 2762009: Add vbutil_key (Closed) Base URL: ssh://gitrw.chromium.org/vboot_reference.git
Patch Set: Util to pack/unpack .vbpubk files Created 10 years, 6 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 | « host/linktest/main.c ('k') | tests/vboot_common3_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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 VbKernelPreambleHeader *hdr; 84 VbKernelPreambleHeader *hdr;
85 VbKernelPreambleHeader *h; 85 VbKernelPreambleHeader *h;
86 RSAPublicKey* rsa; 86 RSAPublicKey* rsa;
87 uint64_t hsize; 87 uint64_t hsize;
88 88
89 /* Create a dummy signature */ 89 /* Create a dummy signature */
90 VbSignature *body_sig = SignatureAlloc(56, 78); 90 VbSignature *body_sig = SignatureAlloc(56, 78);
91 91
92 rsa = PublicKeyToRSA(public_key); 92 rsa = PublicKeyToRSA(public_key);
93 hdr = CreateKernelPreamble(0x1234, 0x100000, 0x300000, 0x4000, body_sig, 93 hdr = CreateKernelPreamble(0x1234, 0x100000, 0x300000, 0x4000, body_sig,
94 private_key); 94 0, private_key);
95 TEST_NEQ(hdr && rsa, 0, "VerifyKernelPreamble2() prerequisites"); 95 TEST_NEQ(hdr && rsa, 0, "VerifyKernelPreamble2() prerequisites");
96 if (!hdr) 96 if (!hdr)
97 return; 97 return;
98 hsize = hdr->preamble_size; 98 hsize = hdr->preamble_size;
99 h = (VbKernelPreambleHeader*)Malloc(hsize + 16384); 99 h = (VbKernelPreambleHeader*)Malloc(hsize + 16384);
100 100
101 TEST_EQ(VerifyKernelPreamble2(hdr, hsize, rsa), 0, 101 TEST_EQ(VerifyKernelPreamble2(hdr, hsize, rsa), 0,
102 "VerifyKernelPreamble2() ok using key"); 102 "VerifyKernelPreamble2() ok using key");
103 TEST_NEQ(VerifyKernelPreamble2(hdr, hsize-1, rsa), 0, 103 TEST_NEQ(VerifyKernelPreamble2(hdr, hsize - 1, rsa), 0,
104 "VerifyKernelPreamble2() size"); 104 "VerifyKernelPreamble2() size--");
105 TEST_EQ(VerifyKernelPreamble2(hdr, hsize + 1, rsa), 0,
106 "VerifyKernelPreamble2() size++");
105 107
106 /* Care about major version but not minor */ 108 /* Care about major version but not minor */
107 Memcpy(h, hdr, hsize); 109 Memcpy(h, hdr, hsize);
108 h->header_version_major++; 110 h->header_version_major++;
109 ReSignKernelPreamble(h, private_key); 111 ReSignKernelPreamble(h, private_key);
110 TEST_NEQ(VerifyKernelPreamble2(h, hsize, rsa), 0, 112 TEST_NEQ(VerifyKernelPreamble2(h, hsize, rsa), 0,
111 "VerifyKernelPreamble2() major++"); 113 "VerifyKernelPreamble2() major++");
112 114
113 Memcpy(h, hdr, hsize); 115 Memcpy(h, hdr, hsize);
114 h->header_version_major--; 116 h->header_version_major--;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 186
185 /* Read verification keys and create a test image. */ 187 /* Read verification keys and create a test image. */
186 key_algorithm = atoi(argv[1]); 188 key_algorithm = atoi(argv[1]);
187 189
188 private_key = PrivateKeyRead(argv[2], key_algorithm); 190 private_key = PrivateKeyRead(argv[2], key_algorithm);
189 if (!private_key) { 191 if (!private_key) {
190 fprintf(stderr, "Error reading private_key"); 192 fprintf(stderr, "Error reading private_key");
191 return 1; 193 return 1;
192 } 194 }
193 195
194 public_key = PublicKeyRead(argv[3], key_algorithm, 1); 196 public_key = PublicKeyReadKeyb(argv[3], key_algorithm, 1);
195 if (!public_key) { 197 if (!public_key) {
196 fprintf(stderr, "Error reading public_key"); 198 fprintf(stderr, "Error reading public_key");
197 return 1; 199 return 1;
198 } 200 }
199 201
200 VerifyPublicKeyToRSA(public_key); 202 VerifyPublicKeyToRSA(public_key);
201 VerifyDataTest(public_key, private_key); 203 VerifyDataTest(public_key, private_key);
202 VerifyKernelPreambleTest(public_key, private_key); 204 VerifyKernelPreambleTest(public_key, private_key);
203 205
204 if (public_key) 206 if (public_key)
205 Free(public_key); 207 Free(public_key);
206 if (private_key) 208 if (private_key)
207 Free(private_key); 209 Free(private_key);
208 210
209 return error_code; 211 return error_code;
210 } 212 }
OLDNEW
« no previous file with comments | « host/linktest/main.c ('k') | tests/vboot_common3_tests.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698