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

Side by Side Diff: host/lib/host_misc.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/lib/host_key.c ('k') | host/linktest/main.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 * found in the LICENSE file.
4 *
5 * Host functions for verified boot.
6 */
7
8 /* TODO: change all 'return 0', 'return 1' into meaningful return codes */
9
10 #include <stdio.h>
11 #include <stdlib.h>
12
13 #include "host_common.h"
14
15 #include "cryptolib.h"
16 #include "utility.h"
17 #include "vboot_common.h"
18
19
20 uint8_t* ReadFile(const char* filename, uint64_t* size) {
21 FILE* f;
22 uint8_t* buf;
23
24 f = fopen(filename, "rb");
25 if (!f) {
26 debug("Unable to open file %s\n", filename);
27 return NULL;
28 }
29
30 fseek(f, 0, SEEK_END);
31 *size = ftell(f);
32 rewind(f);
33
34 buf = Malloc(*size);
35 if (!buf) {
36 fclose(f);
37 return NULL;
38 }
39
40 if(1 != fread(buf, *size, 1, f)) {
41 debug("Unable to read from file %s\n", filename);
42 fclose(f);
43 Free(buf);
44 return NULL;
45 }
46
47 fclose(f);
48 return buf;
49 }
OLDNEW
« no previous file with comments | « host/lib/host_key.c ('k') | host/linktest/main.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698