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

Side by Side Diff: src/platform/vboot_reference/common/utility_stub.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
« no previous file with comments | « no previous file | src/platform/vboot_reference/crypto/rsa_utility.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 * Stub implementations of utility functions which call their linux-specific 5 * Stub implementations of utility functions which call their linux-specific
6 * equivalents. 6 * equivalents.
7 */ 7 */
8 8
9 #include "utility.h" 9 #include "utility.h"
10 10
(...skipping 12 matching lines...) Expand all
23 void Free(void* ptr) { 23 void Free(void* ptr) {
24 free(ptr); 24 free(ptr);
25 } 25 }
26 26
27 void* Memcpy(void* dest, const void* src, size_t n) { 27 void* Memcpy(void* dest, const void* src, size_t n) {
28 return memcpy(dest, src, n); 28 return memcpy(dest, src, n);
29 } 29 }
30 30
31 void* Memset(void* dest, const uint8_t c, size_t n) { 31 void* Memset(void* dest, const uint8_t c, size_t n) {
32 while (n--) { 32 while (n--) {
33 *((uint8_t*)dest) = c; 33 *((uint8_t*)dest++) = c;
34 } 34 }
35 return dest; 35 return dest;
36 } 36 }
37 37
38 int SafeMemcmp(const void* s1, const void* s2, size_t n) { 38 int SafeMemcmp(const void* s1, const void* s2, size_t n) {
39 int match = 1; 39 int match = 0;
40 const unsigned char* us1 = s1; 40 const unsigned char* us1 = s1;
41 const unsigned char* us2 = s2; 41 const unsigned char* us2 = s2;
42 while (n--) { 42 while (n--) {
43 if (*us1++ != *us2++) 43 if (*us1++ != *us2++)
44 match = 0;
45 else
46 match = 1; 44 match = 1;
47 } 45 }
48 46
49 return match; 47 return match;
50 } 48 }
51 49
52 void* StatefulMemcpy(MemcpyState* state, void* dst, int len) { 50 void* StatefulMemcpy(MemcpyState* state, void* dst, int len) {
53 void* saved_ptr; 51 void* saved_ptr;
54 if (len > state->remaining_len) { 52 if (len > state->remaining_len) {
55 state->remaining_len = -1; 53 state->remaining_len = -1;
56 return NULL; 54 return NULL;
57 } 55 }
58 saved_ptr = state->remaining_buf; 56 saved_ptr = state->remaining_buf;
59 Memcpy(dst, saved_ptr, len); 57 Memcpy(dst, saved_ptr, len);
60 state->remaining_buf += len; 58 state->remaining_buf += len;
61 state->remaining_len -= len; 59 state->remaining_len -= len;
62 return dst; 60 return dst;
63 } 61 }
OLDNEW
« no previous file with comments | « no previous file | src/platform/vboot_reference/crypto/rsa_utility.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698