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

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

Issue 661353: Vboot Reference: Refactor Code. (Closed)
Patch Set: Review Fixes. 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
« no previous file with comments | « src/platform/vboot_reference/utils/signature_digest.c ('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>
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 fprintf(stderr, "\t%d for %s\n", i, algo_strings[i]); 67 fprintf(stderr, "\t%d for %s\n", i, algo_strings[i]);
68 return -1; 68 return -1;
69 } 69 }
70 70
71 algorithm = atoi(argv[1]); 71 algorithm = atoi(argv[1]);
72 if (algorithm >= kNumAlgorithms) { 72 if (algorithm >= kNumAlgorithms) {
73 fprintf(stderr, "Invalid Algorithm!\n"); 73 fprintf(stderr, "Invalid Algorithm!\n");
74 return 0; 74 return 0;
75 } 75 }
76 /* Length of the RSA Signature/RSA Key */ 76 /* Length of the RSA Signature/RSA Key */
77 sig_len = siglen_map[algorithm]; 77 sig_len = siglen_map[algorithm];
78 if (!(key = RSAPublicKeyFromFile(argv[2]))) 78 if ((key = RSAPublicKeyFromFile(argv[2])) &&
79 goto failure; 79 (signature = read_signature(argv[3], sig_len)) &&
80 if (!(signature = read_signature(argv[3], sig_len))) 80 (digest = DigestFile(argv[4], algorithm))) {
81 goto failure; 81 if (RSAVerify(key, signature, sig_len, algorithm, digest)) {
82 if (!(digest = DigestFile(argv[4], algorithm))) 82 return_code = 0;
83 goto failure; 83 fprintf(stderr, "Signature Verification "
84 if(RSA_verify(key, signature, sig_len, algorithm, digest)) { 84 COL_GREEN "SUCCEEDED" COL_STOP "\n");
85 return_code = 0; 85 } else {
86 fprintf(stderr, "Signature Verification " 86 fprintf(stderr, "Signature Verification "
87 COL_GREEN "SUCCEEDED" COL_STOP "\n"); 87 COL_RED "FAILED" COL_STOP "\n");
88 } else { 88 }
89 fprintf(stderr, "Signature Verification "
90 COL_RED "FAILED" COL_STOP "\n");
91 } 89 }
90 else
91 return_code = -1;
92 92
93 failure:
94 free(key); 93 free(key);
95 free(signature); 94 free(signature);
96 free(digest); 95 free(digest);
97 96
98 return return_code; 97 return return_code;
99 } 98 }
OLDNEW
« no previous file with comments | « src/platform/vboot_reference/utils/signature_digest.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698