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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « host/lib/host_key.c ('k') | host/linktest/main.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: host/lib/host_misc.c
diff --git a/host/lib/host_misc.c b/host/lib/host_misc.c
new file mode 100644
index 0000000000000000000000000000000000000000..f24bf40dc0159973848e872c7749a215642b3ee9
--- /dev/null
+++ b/host/lib/host_misc.c
@@ -0,0 +1,49 @@
+/* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * Host functions for verified boot.
+ */
+
+/* TODO: change all 'return 0', 'return 1' into meaningful return codes */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "host_common.h"
+
+#include "cryptolib.h"
+#include "utility.h"
+#include "vboot_common.h"
+
+
+uint8_t* ReadFile(const char* filename, uint64_t* size) {
+ FILE* f;
+ uint8_t* buf;
+
+ f = fopen(filename, "rb");
+ if (!f) {
+ debug("Unable to open file %s\n", filename);
+ return NULL;
+ }
+
+ fseek(f, 0, SEEK_END);
+ *size = ftell(f);
+ rewind(f);
+
+ buf = Malloc(*size);
+ if (!buf) {
+ fclose(f);
+ return NULL;
+ }
+
+ if(1 != fread(buf, *size, 1, f)) {
+ debug("Unable to read from file %s\n", filename);
+ fclose(f);
+ Free(buf);
+ return NULL;
+ }
+
+ fclose(f);
+ return buf;
+}
« 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