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

Side by Side Diff: src/platform/vboot_reference/tests/verify_data.c

Issue 579009: Fix lost variable declarations due to a botched merge on the previous push. (Closed)
Patch Set: Created 10 years, 10 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 | « src/platform/vboot_reference/tests/verify_data.h ('k') | no next file » | 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 5
6 /* Routines for verifying a file's signature. Useful in testing the core 6 /* Routines for verifying a file's signature. Useful in testing the core
7 * RSA verification implementation. 7 * RSA verification implementation.
8 */ 8 */
9 9
10 #include <fcntl.h> 10 #include <fcntl.h>
11 #include <stdio.h> 11 #include <stdio.h>
12 #include <stdlib.h> 12 #include <stdlib.h>
13 #include <string.h> 13 #include <string.h>
14 #include <sys/stat.h> 14 #include <sys/stat.h>
15 #include <sys/types.h> 15 #include <sys/types.h>
16 #include <unistd.h> 16 #include <unistd.h>
17 17
18 #include "sha_utility.h" 18 #include "sha_utility.h"
19 #include "padding.h" 19 #include "padding.h"
20 #include "rsa.h" 20 #include "rsa.h"
21 #include "rsa_utility.h" 21 #include "rsa_utility.h"
22 #include "verify_data.h" 22 #include "verify_data.h"
23 23
24 RSAPublicKey* read_RSAkey(char* input_file, int len) { 24 RSAPublicKey* read_RSAkey(char* input_file) {
25 int key_fd; 25 int key_fd;
26 RSAPublicKey* key = NULL; 26 int buf_len;
27 struct stat stat_fd;
28 uint8_t* buf = NULL;
27 29
28 if ((key_fd = open(input_file, O_RDONLY)) == -1) { 30 if ((key_fd = open(input_file, O_RDONLY)) == -1) {
29 fprintf(stderr, "Couldn't open pre-processed key file\n"); 31 fprintf(stderr, "Couldn't open pre-processed key file\n");
30 return NULL; 32 return NULL;
31 } 33 }
32 34
33 if (-1 == fstat(key_fd, &stat_fd)) { 35 if (-1 == fstat(key_fd, &stat_fd)) {
34 fprintf(stderr, "Couldn't stat key file\n"); 36 fprintf(stderr, "Couldn't stat key file\n");
35 return NULL; 37 return NULL;
36 } 38 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 } 94 }
93 95
94 algorithm = atoi(argv[1]); 96 algorithm = atoi(argv[1]);
95 if (algorithm >= kNumAlgorithms) { 97 if (algorithm >= kNumAlgorithms) {
96 fprintf(stderr, "Invalid Algorithm!\n"); 98 fprintf(stderr, "Invalid Algorithm!\n");
97 return 0; 99 return 0;
98 } 100 }
99 /* Length of the RSA Signature/RSA Key */ 101 /* Length of the RSA Signature/RSA Key */
100 sig_len = siglen_map[algorithm] * sizeof(uint32_t); 102 sig_len = siglen_map[algorithm] * sizeof(uint32_t);
101 103
102 if (!(key = read_RSAkey(argv[2], sig_len))) 104 if (!(key = read_RSAkey(argv[2])))
103 goto failure; 105 goto failure;
104 if (!(signature = read_signature(argv[3], sig_len))) 106 if (!(signature = read_signature(argv[3], sig_len)))
105 goto failure; 107 goto failure;
106 if (!(digest = DigestFile(argv[4], algorithm))) 108 if (!(digest = DigestFile(argv[4], algorithm)))
107 goto failure; 109 goto failure;
108 if(RSA_verify(key, signature, sig_len, algorithm, digest)) 110 if(RSA_verify(key, signature, sig_len, algorithm, digest))
109 fprintf(stderr, "Signature Verification SUCCEEDED.\n"); 111 fprintf(stderr, "Signature Verification SUCCEEDED.\n");
110 else 112 else
111 fprintf(stderr, "Signature Verification FAILED!\n"); 113 fprintf(stderr, "Signature Verification FAILED!\n");
112 114
113 failure: 115 failure:
114 free(key); 116 free(key);
115 free(signature); 117 free(signature);
116 free(digest); 118 free(digest);
117 119
118 return 0; 120 return 0;
119 } 121 }
OLDNEW
« no previous file with comments | « src/platform/vboot_reference/tests/verify_data.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698