aboutsummaryrefslogtreecommitdiff
path: root/host
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2014-06-20 14:33:00 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-07-09 01:30:48 +0000
commit782990277ac7d6730db4c43c2b5632de93396921 (patch)
treea7c6c3d332e4e89d4ccdbb6ced0b269dda13022d /host
parentf8f807a5ef00e8d5360fc2c9093bd0b5da8c0507 (diff)
downloadvboot_reference-782990277ac7d6730db4c43c2b5632de93396921.tar.gz
Split libvboot_host.a into external and local libraries.
We've been creating and linking against a library called "libvboot_host.a" for two different reasons. The main purpose is to build the vboot_reference tools found in the utility/ directory. But there are some external userspace programs that would also like to use some functions in this library. This change establishes libvboot_host.a as the library for use by external userspace programs only, and creates a new libvboot_util.a library that's only used inside this source tree to build the vboot utilities. BUG=chromium:231567 BRANCH=ToT TEST=manual Build and run the local tests: make runalltests make clean Build Link firmware and all the utilities: emerge-link chromeos-base/vboot_reference \ sys-boot/depthcharge \ sys-boot/coreboot \ chromeos-base/chromeos-ec \ chromeos-base/chromeos-firmware-link \ chromeos-base/chromeos-cryptohome \ chromeos-base/update_engine \ chromeos-base/chromeos-installer \ chromeos-base/chromeos-login \ chromeos-base/verity Build Lumpy utilities, which include the 32-bit cros_installer: emerge-lumpy chromeos-base/vboot_reference \ chromeos-base/chromeos-login \ chromeos-base/verity \ chromeos-base/update_engine \ chromeos-base/chromeos-installer \ chromeos-base/chromeos-cryptohome Change-Id: Ie81ff1f74a6356cb8fab7d98471139d7758c4f19 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/207016 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'host')
-rw-r--r--host/lib/host_misc.c10
-rw-r--r--host/lib/include/host_misc.h3
-rw-r--r--host/lib/include/util_misc.h16
-rw-r--r--host/lib/util_misc.c26
-rw-r--r--host/linktest/extern.c50
-rw-r--r--host/linktest/main.c5
6 files changed, 97 insertions, 13 deletions
diff --git a/host/lib/host_misc.c b/host/lib/host_misc.c
index 77466864..110feee0 100644
--- a/host/lib/host_misc.c
+++ b/host/lib/host_misc.c
@@ -114,13 +114,3 @@ int WriteFile(const char* filename, const void *data, uint64_t size) {
fclose(f);
return 0;
}
-
-void PrintPubKeySha1Sum(VbPublicKey* key) {
- uint8_t* buf = ((uint8_t *)key) + key->key_offset;
- uint64_t buflen = key->key_size;
- uint8_t* digest = DigestBuf(buf, buflen, SHA1_DIGEST_ALGORITHM);
- int i;
- for (i=0; i<SHA1_DIGEST_SIZE; i++)
- printf("%02x", digest[i]);
- free(digest);
-}
diff --git a/host/lib/include/host_misc.h b/host/lib/include/host_misc.h
index 22b31415..9bfa721d 100644
--- a/host/lib/include/host_misc.h
+++ b/host/lib/include/host_misc.h
@@ -43,7 +43,4 @@ int ReadFileBit(const char* filename, int bitmask);
* Returns 0 if success, 1 if error. */
int WriteFile(const char* filename, const void *data, uint64_t size);
-/* Prints the sha1sum of the given VbPublicKey to stdout. */
-void PrintPubKeySha1Sum(VbPublicKey* key);
-
#endif /* VBOOT_REFERENCE_HOST_MISC_H_ */
diff --git a/host/lib/include/util_misc.h b/host/lib/include/util_misc.h
new file mode 100644
index 00000000..788929de
--- /dev/null
+++ b/host/lib/include/util_misc.h
@@ -0,0 +1,16 @@
+/* Copyright (c) 2014 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-side misc functions for verified boot.
+ */
+
+#ifndef VBOOT_REFERENCE_UTIL_MISC_H_
+#define VBOOT_REFERENCE_UTIL_MISC_H_
+
+#include "vboot_struct.h"
+
+/* Prints the sha1sum of the given VbPublicKey to stdout. */
+void PrintPubKeySha1Sum(VbPublicKey* key);
+
+#endif /* VBOOT_REFERENCE_UTIL_MISC_H_ */
diff --git a/host/lib/util_misc.c b/host/lib/util_misc.c
new file mode 100644
index 00000000..09df8eef
--- /dev/null
+++ b/host/lib/util_misc.c
@@ -0,0 +1,26 @@
+/* Copyright (c) 2014 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.
+ *
+ * Miscellaneous functions for userspace vboot utilities.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "cryptolib.h"
+#include "host_common.h"
+#include "util_misc.h"
+#include "vboot_common.h"
+
+void PrintPubKeySha1Sum(VbPublicKey* key) {
+ uint8_t* buf = ((uint8_t *)key) + key->key_offset;
+ uint64_t buflen = key->key_size;
+ uint8_t* digest = DigestBuf(buf, buflen, SHA1_DIGEST_ALGORITHM);
+ int i;
+ for (i=0; i<SHA1_DIGEST_SIZE; i++)
+ printf("%02x", digest[i]);
+ free(digest);
+}
diff --git a/host/linktest/extern.c b/host/linktest/extern.c
new file mode 100644
index 00000000..46b5ddac
--- /dev/null
+++ b/host/linktest/extern.c
@@ -0,0 +1,50 @@
+/* Copyright (c) 2014 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.
+ */
+
+/*
+ * This tests for the presence of those functions actually used by userspace
+ * apps that are not part of firmware or vboot_reference.
+ */
+
+#include "crossystem.h"
+#include "tlcl.h"
+#include "vboot_host.h"
+
+/* TODO(crbug.com/318536) */
+const char* progname = "";
+const char* command = "";
+void (*uuid_generator)(uint8_t* buffer) = NULL;
+
+int main(void)
+{
+ /* crossystem.h */
+ VbGetSystemPropertyInt(0);
+ VbGetSystemPropertyString(0, 0, 0);
+ VbSetSystemPropertyInt(0, 0);
+
+ /* tlcl.h */
+ TlclGetOwnership(0);
+ TlclGetRandom(0, 0, 0);
+ TlclLibClose();
+ TlclLibInit();
+ TlclRead(0, 0, 0);
+
+ /* vboot_host.h */
+ CgptAdd(0);
+ CgptBoot(0);
+ CgptCreate(0);
+ CgptGetBootPartitionNumber(0);
+ CgptGetNumNonEmptyPartitions(0);
+ CgptGetPartitionDetails(0);
+ CgptPrioritize(0);
+ CgptSetAttributes(0);
+ FindKernelConfig(0, 0);
+ GuidEqual(0, 0);
+ GuidIsZero(0);
+ GuidToStr(0, 0, 0);
+ StrToGuid(0, 0);
+
+ return 0;
+}
diff --git a/host/linktest/main.c b/host/linktest/main.c
index 1f3dfecc..56ab21cd 100644
--- a/host/linktest/main.c
+++ b/host/linktest/main.c
@@ -2,6 +2,11 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+
+/*
+ * This tests for the presence of functions used by vboot_reference utilities.
+ */
+
#include <stdio.h>
#include "host_common.h"