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

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

Issue 650105: Vboot Reference: Add the "real" reference firmware verification function (VerifyFirmware). (Closed)
Patch Set: Review fixes. 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
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 "sha_utility.h" 8 #include "sha_utility.h"
9 9
10 #include <fcntl.h> 10 #include <fcntl.h>
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 while ( (len = read(input_fd, data, SHA1_BLOCK_SIZE)) == 101 while ( (len = read(input_fd, data, SHA1_BLOCK_SIZE)) ==
102 SHA1_BLOCK_SIZE) 102 SHA1_BLOCK_SIZE)
103 DigestUpdate(&ctx, data, len); 103 DigestUpdate(&ctx, data, len);
104 if (len != -1) 104 if (len != -1)
105 DigestUpdate(&ctx, data, len); 105 DigestUpdate(&ctx, data, len);
106 digest = DigestFinal(&ctx); 106 digest = DigestFinal(&ctx);
107 close(input_fd); 107 close(input_fd);
108 return digest; 108 return digest;
109 } 109 }
110 110
111 uint8_t* DigestBuf(uint8_t* buf, int len, int sig_algorithm) { 111 uint8_t* DigestBuf(const uint8_t* buf, int len, int sig_algorithm) {
112 uint8_t* digest = (uint8_t*) Malloc(SHA512_DIGEST_SIZE); /* Use the max. */ 112 uint8_t* digest = (uint8_t*) Malloc(SHA512_DIGEST_SIZE); /* Use the max. */
113 /* Define an array mapping [sig_algorithm] to function pointers to the 113 /* Define an array mapping [sig_algorithm] to function pointers to the
114 * SHA{1|256|512} functions. 114 * SHA{1|256|512} functions.
115 */ 115 */
116 typedef uint8_t* (*Hash_ptr) (const uint8_t*, int, uint8_t*); 116 typedef uint8_t* (*Hash_ptr) (const uint8_t*, int, uint8_t*);
117 Hash_ptr hash[] = { 117 Hash_ptr hash[] = {
118 SHA1, /* RSA 1024 */ 118 SHA1, /* RSA 1024 */
119 SHA256, 119 SHA256,
120 SHA512, 120 SHA512,
121 SHA1, /* RSA 2048 */ 121 SHA1, /* RSA 2048 */
122 SHA256, 122 SHA256,
123 SHA512, 123 SHA512,
124 SHA1, /* RSA 4096 */ 124 SHA1, /* RSA 4096 */
125 SHA256, 125 SHA256,
126 SHA512, 126 SHA512,
127 SHA1, /* RSA 8192 */ 127 SHA1, /* RSA 8192 */
128 SHA256, 128 SHA256,
129 SHA512, 129 SHA512,
130 }; 130 };
131 /* Call the appropriate hash function. */ 131 /* Call the appropriate hash function. */
132 return hash[sig_algorithm](buf, len, digest); 132 return hash[sig_algorithm](buf, len, digest);
133 } 133 }
OLDNEW
« no previous file with comments | « src/platform/vboot_reference/crypto/rsa_utility.c ('k') | src/platform/vboot_reference/include/file_keys.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698