diff options
27 files changed, 47 insertions, 52 deletions
@@ -382,6 +382,7 @@ FWLIB_SRCS = \ firmware/2lib/2kernel.c \ firmware/2lib/2misc.c \ firmware/2lib/2nvstorage.c \ + firmware/2lib/2packed_key.c \ firmware/2lib/2recovery_reasons.c \ firmware/2lib/2rsa.c \ firmware/2lib/2secdata_firmware.c \ @@ -400,8 +401,7 @@ FWLIB_SRCS = \ firmware/lib/vboot_api_kernel.c \ firmware/lib/vboot_kernel.c \ firmware/lib20/api_kernel.c \ - firmware/lib20/kernel.c \ - firmware/lib20/packed_key.c + firmware/lib20/kernel.c # Only add these to firmware and test builds, # as regular host builds don't need them diff --git a/firmware/2lib/2api.c b/firmware/2lib/2api.c index 2beb9edf..aa1d25da 100644 --- a/firmware/2lib/2api.c +++ b/firmware/2lib/2api.c @@ -15,7 +15,6 @@ #include "2sha.h" #include "2sysincludes.h" #include "2tpm_bootmode.h" -#include "vb2_common.h" vb2_error_t vb2api_fw_phase1(struct vb2_context *ctx) { diff --git a/firmware/2lib/2firmware.c b/firmware/2lib/2firmware.c index bc8e9955..bc708dc5 100644 --- a/firmware/2lib/2firmware.c +++ b/firmware/2lib/2firmware.c @@ -6,13 +6,13 @@ */ #include "2api.h" +#include "2common.h" #include "2misc.h" #include "2nvstorage.h" #include "2rsa.h" #include "2secdata.h" #include "2sha.h" #include "2sysincludes.h" -#include "vb2_common.h" vb2_error_t vb2_load_fw_keyblock(struct vb2_context *ctx) { diff --git a/firmware/2lib/2kernel.c b/firmware/2lib/2kernel.c index 8c6d191a..763214dd 100644 --- a/firmware/2lib/2kernel.c +++ b/firmware/2lib/2kernel.c @@ -11,7 +11,6 @@ #include "2nvstorage.h" #include "2rsa.h" #include "2secdata.h" -#include "vb2_common.h" #include "vboot_kernel.h" /** diff --git a/firmware/2lib/2misc.c b/firmware/2lib/2misc.c index 7c4ca262..ec460b32 100644 --- a/firmware/2lib/2misc.c +++ b/firmware/2lib/2misc.c @@ -15,7 +15,6 @@ #include "2sha.h" #include "2struct.h" #include "2sysincludes.h" -#include "vb2_common.h" #include "vboot_api.h" #include "vboot_struct.h" diff --git a/firmware/lib20/packed_key.c b/firmware/2lib/2packed_key.c index 3870288f..4e2c654a 100644 --- a/firmware/lib20/packed_key.c +++ b/firmware/2lib/2packed_key.c @@ -6,9 +6,9 @@ */ #include "2common.h" +#include "2packed_key.h" #include "2rsa.h" #include "2sysincludes.h" -#include "vb2_common.h" test_mockable vb2_error_t vb2_unpack_key_buffer(struct vb2_public_key *key, diff --git a/firmware/2lib/include/2common.h b/firmware/2lib/include/2common.h index e6100938..13ea40f5 100644 --- a/firmware/2lib/include/2common.h +++ b/firmware/2lib/include/2common.h @@ -10,6 +10,7 @@ #include "2api.h" #include "2gbb.h" +#include "2packed_key.h" #include "2return_codes.h" #include "2sha.h" #include "2struct.h" diff --git a/firmware/2lib/include/2packed_key.h b/firmware/2lib/include/2packed_key.h new file mode 100644 index 00000000..09c73553 --- /dev/null +++ b/firmware/2lib/include/2packed_key.h @@ -0,0 +1,39 @@ +/* Copyright 2021 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. + * + * Functions related to unpacking keys and key buffers. + */ + +#ifndef VBOOT_REFERENCE_2PACKED_KEY_H_ +#define VBOOT_REFERENCE_2PACKED_KEY_H_ + +/** + * Unpack a vboot1-format key buffer for use in verification + * + * The elements of the unpacked key will point into the source buffer, so don't + * free the source buffer until you're done with the key. + * + * @param key Destintion for unpacked key + * @param buf Source buffer containing packed key + * @param size Size of buffer in bytes + * @return VB2_SUCCESS, or non-zero error code if error. + */ +vb2_error_t vb2_unpack_key_buffer(struct vb2_public_key *key, + const uint8_t *buf, uint32_t size); + +/** + * Unpack a vboot1-format key for use in verification + * + * The elements of the unpacked key will point into the source packed key, so + * don't free the source until you're done with the public key. + * + * @param key Destintion for unpacked key + * @param packed_key Source packed key + * @param size Size of buffer in bytes + * @return VB2_SUCCESS, or non-zero error code if error. + */ +vb2_error_t vb2_unpack_key(struct vb2_public_key *key, + const struct vb2_packed_key *packed_key); + +#endif /* VBOOT_REFERENCE_2PACKED_KEY_H_ */ diff --git a/firmware/lib/vboot_api_kernel.c b/firmware/lib/vboot_api_kernel.c index 52d3f073..5451033a 100644 --- a/firmware/lib/vboot_api_kernel.c +++ b/firmware/lib/vboot_api_kernel.c @@ -15,7 +15,6 @@ #include "2sysincludes.h" #include "2ui.h" #include "load_kernel_fw.h" -#include "vb2_common.h" #include "vboot_api.h" #include "vboot_kernel.h" #include "vboot_struct.h" diff --git a/firmware/lib/vboot_kernel.c b/firmware/lib/vboot_kernel.c index 6a0b0f37..495b360d 100644 --- a/firmware/lib/vboot_kernel.c +++ b/firmware/lib/vboot_kernel.c @@ -9,6 +9,7 @@ #include "2common.h" #include "2misc.h" #include "2nvstorage.h" +#include "2packed_key.h" #include "2rsa.h" #include "2sha.h" #include "2secdata.h" diff --git a/firmware/lib20/include/vb2_common.h b/firmware/lib20/include/vb2_common.h index 53a077f3..3db04377 100644 --- a/firmware/lib20/include/vb2_common.h +++ b/firmware/lib20/include/vb2_common.h @@ -18,34 +18,6 @@ struct vb2_public_key; /** - * Unpack a vboot1-format key buffer for use in verification - * - * The elements of the unpacked key will point into the source buffer, so don't - * free the source buffer until you're done with the key. - * - * @param key Destintion for unpacked key - * @param buf Source buffer containing packed key - * @param size Size of buffer in bytes - * @return VB2_SUCCESS, or non-zero error code if error. - */ -vb2_error_t vb2_unpack_key_buffer(struct vb2_public_key *key, - const uint8_t *buf, uint32_t size); - -/** - * Unpack a vboot1-format key for use in verification - * - * The elements of the unpacked key will point into the source packed key, so - * don't free the source until you're done with the public key. - * - * @param key Destintion for unpacked key - * @param packed_key Source packed key - * @param size Size of buffer in bytes - * @return VB2_SUCCESS, or non-zero error code if error. - */ -vb2_error_t vb2_unpack_key(struct vb2_public_key *key, - const struct vb2_packed_key *packed_key); - -/** * Verify a keyblock using its hash. * * Header fields are also checked for validity. Does not verify key index or key diff --git a/futility/cmd_create.c b/futility/cmd_create.c index aca1d4c0..16a37332 100644 --- a/futility/cmd_create.c +++ b/futility/cmd_create.c @@ -22,7 +22,6 @@ #include "host_misc21.h" #include "openssl_compat.h" #include "util_misc.h" -#include "vb2_common.h" #include "vboot_host.h" /* Command line options */ diff --git a/futility/cmd_vbutil_firmware.c b/futility/cmd_vbutil_firmware.c index 7659ed25..b7155f7b 100644 --- a/futility/cmd_vbutil_firmware.c +++ b/futility/cmd_vbutil_firmware.c @@ -22,7 +22,6 @@ #include "kernel_blob.h" #include "util_misc.h" #include "vb1_helper.h" -#include "vb2_common.h" /* Command line options */ enum { diff --git a/futility/cmd_vbutil_key.c b/futility/cmd_vbutil_key.c index 0d812540..d26df3ff 100644 --- a/futility/cmd_vbutil_key.c +++ b/futility/cmd_vbutil_key.c @@ -17,7 +17,6 @@ #include "host_key21.h" #include "util_misc.h" #include "vb1_helper.h" -#include "vb2_common.h" /* Command line options */ enum { diff --git a/futility/cmd_vbutil_keyblock.c b/futility/cmd_vbutil_keyblock.c index 977b4aa4..bec23c39 100644 --- a/futility/cmd_vbutil_keyblock.c +++ b/futility/cmd_vbutil_keyblock.c @@ -19,7 +19,6 @@ #include "host_key21.h" #include "util_misc.h" #include "vb1_helper.h" -#include "vb2_common.h" /* Command line options */ enum { diff --git a/host/lib/host_common.c b/host/lib/host_common.c index 63b45f2e..1dc7a542 100644 --- a/host/lib/host_common.c +++ b/host/lib/host_common.c @@ -12,7 +12,6 @@ #include "2sysincludes.h" #include "host_common.h" #include "host_key21.h" -#include "vb2_common.h" struct vb2_fw_preamble *vb2_create_fw_preamble( uint32_t firmware_version, diff --git a/host/lib/host_key2.c b/host/lib/host_key2.c index 913c6dfa..e2e3f318 100644 --- a/host/lib/host_key2.c +++ b/host/lib/host_key2.c @@ -19,7 +19,6 @@ #include "host_key21.h" #include "host_key.h" #include "host_misc.h" -#include "vb2_common.h" enum vb2_crypto_algorithm vb2_get_crypto_algorithm( enum vb2_hash_algorithm hash_alg, diff --git a/host/lib/host_signature.c b/host/lib/host_signature.c index db536c6e..5b71d29a 100644 --- a/host/lib/host_signature.c +++ b/host/lib/host_signature.c @@ -21,7 +21,6 @@ #include "2sysincludes.h" #include "host_common.h" #include "host_signature21.h" -#include "vb2_common.h" /* Invoke [external_signer] command with [pem_file] as an argument, contents of * [inbuf] passed redirected to stdin, and the stdout of the command is put diff --git a/host/lib/host_signature2.c b/host/lib/host_signature2.c index f7caa71f..b6cd6520 100644 --- a/host/lib/host_signature2.c +++ b/host/lib/host_signature2.c @@ -22,7 +22,6 @@ #include "host_common.h" #include "host_key21.h" #include "host_signature21.h" -#include "vb2_common.h" struct vb2_signature *vb2_alloc_signature(uint32_t sig_size, uint32_t data_size) diff --git a/host/lib/util_misc.c b/host/lib/util_misc.c index c99947f0..26f7dac8 100644 --- a/host/lib/util_misc.c +++ b/host/lib/util_misc.c @@ -20,7 +20,6 @@ #include "host_key21.h" #include "openssl_compat.h" #include "util_misc.h" -#include "vb2_common.h" const char *packed_key_sha1_string(const struct vb2_packed_key *key) { diff --git a/tests/vb20_api_kernel_tests.c b/tests/vb20_api_kernel_tests.c index 676cb198..893cd4e4 100644 --- a/tests/vb20_api_kernel_tests.c +++ b/tests/vb20_api_kernel_tests.c @@ -15,7 +15,6 @@ #include "2secdata.h" #include "2sysincludes.h" #include "test_common.h" -#include "vb2_common.h" #include "vboot_struct.h" /* Common context for tests */ diff --git a/tests/vb20_rsa_padding_tests.c b/tests/vb20_rsa_padding_tests.c index 03a38ee1..90ff42ae 100644 --- a/tests/vb20_rsa_padding_tests.c +++ b/tests/vb20_rsa_padding_tests.c @@ -6,13 +6,13 @@ #include <stdint.h> #include <stdio.h> +#include "2common.h" #include "2rsa.h" #include "2sysincludes.h" #include "file_keys.h" #include "host_key.h" #include "rsa_padding_test.h" #include "test_common.h" -#include "vb2_common.h" vb2_error_t hwcrypto_modexp_return_value = VB2_SUCCESS; vb2_error_t vb2ex_hwcrypto_modexp(const struct vb2_public_key *key, diff --git a/tests/vb2_api_tests.c b/tests/vb2_api_tests.c index 1fabb60b..40fdf593 100644 --- a/tests/vb2_api_tests.c +++ b/tests/vb2_api_tests.c @@ -15,7 +15,6 @@ #include "2secdata.h" #include "2sysincludes.h" #include "test_common.h" -#include "vb2_common.h" /* Common context for tests */ diff --git a/tests/vb2_common2_tests.c b/tests/vb2_common2_tests.c index 89a560c4..b1666ab6 100644 --- a/tests/vb2_common2_tests.c +++ b/tests/vb2_common2_tests.c @@ -9,13 +9,13 @@ #include <stdio.h> #include <string.h> +#include "2common.h" #include "2rsa.h" #include "2sysincludes.h" #include "file_keys.h" #include "host_common.h" #include "host_key21.h" #include "test_common.h" -#include "vb2_common.h" static const uint8_t test_data[] = "This is some test data to sign."; static const uint32_t test_size = sizeof(test_data); diff --git a/tests/vb2_firmware_tests.c b/tests/vb2_firmware_tests.c index 0e0c85f8..681e5d67 100644 --- a/tests/vb2_firmware_tests.c +++ b/tests/vb2_firmware_tests.c @@ -15,7 +15,6 @@ #include "2secdata.h" #include "2sysincludes.h" #include "test_common.h" -#include "vb2_common.h" /* Common context for tests */ static uint8_t workbuf[VB2_FIRMWARE_WORKBUF_RECOMMENDED_SIZE] diff --git a/tests/vb2_kernel_tests.c b/tests/vb2_kernel_tests.c index 4b0a2494..ebddafcd 100644 --- a/tests/vb2_kernel_tests.c +++ b/tests/vb2_kernel_tests.c @@ -14,7 +14,6 @@ #include "2secdata.h" #include "2sysincludes.h" #include "test_common.h" -#include "vb2_common.h" #include "vboot_struct.h" /* Common context for tests */ diff --git a/utility/verify_data.c b/utility/verify_data.c index 8440b3a9..6d3ea151 100644 --- a/utility/verify_data.c +++ b/utility/verify_data.c @@ -21,7 +21,6 @@ #include "2sysincludes.h" #include "file_keys.h" #include "host_common.h" -#include "vb2_common.h" /* ANSI Color coding sequences. */ #define COL_GREEN "\e[1;32m" |