diff options
Diffstat (limited to 'firmware/2lib')
-rw-r--r-- | firmware/2lib/2crc8.c | 10 | ||||
-rw-r--r-- | firmware/2lib/include/2api.h | 13 | ||||
-rw-r--r-- | firmware/2lib/include/2common.h | 6 | ||||
-rw-r--r-- | firmware/2lib/include/2crc8.h | 14 | ||||
-rw-r--r-- | firmware/2lib/include/2crypto.h | 7 | ||||
-rw-r--r-- | firmware/2lib/include/2fw_hash_tags.h | 7 | ||||
-rw-r--r-- | firmware/2lib/include/2gbb.h | 6 | ||||
-rw-r--r-- | firmware/2lib/include/2gbb_flags.h | 6 | ||||
-rw-r--r-- | firmware/2lib/include/2hmac.h | 6 | ||||
-rw-r--r-- | firmware/2lib/include/2id.h | 7 | ||||
-rw-r--r-- | firmware/2lib/include/2misc.h | 6 | ||||
-rw-r--r-- | firmware/2lib/include/2nvstorage.h | 6 | ||||
-rw-r--r-- | firmware/2lib/include/2nvstorage_fields.h | 6 | ||||
-rw-r--r-- | firmware/2lib/include/2recovery_reasons.h | 6 | ||||
-rw-r--r-- | firmware/2lib/include/2return_codes.h | 6 | ||||
-rw-r--r-- | firmware/2lib/include/2secdata.h | 10 | ||||
-rw-r--r-- | firmware/2lib/include/2struct.h | 7 | ||||
-rw-r--r-- | firmware/2lib/include/2sysincludes.h | 6 |
18 files changed, 75 insertions, 60 deletions
diff --git a/firmware/2lib/2crc8.c b/firmware/2lib/2crc8.c index 9df0a00f..d5284de6 100644 --- a/firmware/2lib/2crc8.c +++ b/firmware/2lib/2crc8.c @@ -1,21 +1,23 @@ /* 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. + * + * Very simple 8-bit CRC function. */ #include "2sysincludes.h" #include "2crc8.h" +/* Uses CRC-8 ITU version, with x^8 + x^2 + x + 1 polynomial. + Note that result will evaluate to zero for a buffer of all zeroes. */ uint8_t vb2_crc8(const void *vptr, uint32_t size) { const uint8_t *data = vptr; unsigned crc = 0; uint32_t i, j; - /* - * Calculate CRC-8 directly. A table-based algorithm would be faster, - * but for only a few bytes it isn't worth the code size. - */ + /* Calculate CRC-8 directly. A table-based algorithm would be faster, + but for only a few bytes it isn't worth the code size. */ for (j = size; j; j--, data++) { crc ^= (*data << 8); for(i = 8; i; i--) { diff --git a/firmware/2lib/include/2api.h b/firmware/2lib/include/2api.h index 12aa14e8..b091731b 100644 --- a/firmware/2lib/include/2api.h +++ b/firmware/2lib/include/2api.h @@ -1,9 +1,8 @@ /* Copyright (c) 2013 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. - */ - -/* APIs between calling firmware and vboot_reference + * + * APIs between calling firmware and vboot_reference * * General notes: * @@ -17,9 +16,8 @@ * must be done elsewhere, and VB2_NV_DEBUG_RESET_MODE is ignored. */ -#ifndef VBOOT_2_API_H_ -#define VBOOT_2_API_H_ -#include <stdint.h> +#ifndef VBOOT_REFERENCE_2API_H_ +#define VBOOT_REFERENCE_2API_H_ #include "2constants.h" #include "2crypto.h" @@ -28,6 +26,7 @@ #include "2id.h" #include "2recovery_reasons.h" #include "2return_codes.h" +#include "2secdata.h" /* Modes for vb2ex_tpm_set_mode. */ enum vb2_tpm_mode { @@ -740,4 +739,4 @@ vb2_error_t vb2ex_hwcrypto_digest_finalize(uint8_t *digest, */ vb2_error_t vb2ex_tpm_set_mode(enum vb2_tpm_mode mode_val); -#endif /* VBOOT_2_API_H_ */ +#endif /* VBOOT_REFERENCE_2API_H_ */ diff --git a/firmware/2lib/include/2common.h b/firmware/2lib/include/2common.h index ccc0bfc4..d49074f8 100644 --- a/firmware/2lib/include/2common.h +++ b/firmware/2lib/include/2common.h @@ -5,8 +5,8 @@ * Common functions between firmware and kernel verified boot. */ -#ifndef VBOOT_REFERENCE_VBOOT_2COMMON_H_ -#define VBOOT_REFERENCE_VBOOT_2COMMON_H_ +#ifndef VBOOT_REFERENCE_2COMMON_H_ +#define VBOOT_REFERENCE_2COMMON_H_ #include "2api.h" #include "2gbb.h" @@ -261,4 +261,4 @@ int vb2_verify_packed_key_inside(const void *parent, uint32_t parent_size, const struct vb2_packed_key *key); -#endif /* VBOOT_REFERENCE_VBOOT_2COMMON_H_ */ +#endif /* VBOOT_REFERENCE_2COMMON_H_ */ diff --git a/firmware/2lib/include/2crc8.h b/firmware/2lib/include/2crc8.h index f01eabd9..f9e0ccee 100644 --- a/firmware/2lib/include/2crc8.h +++ b/firmware/2lib/include/2crc8.h @@ -5,11 +5,17 @@ * Very simple 8-bit CRC function. */ -#ifndef VBOOT_REFERENCE_2_CRC8_H_ -#define VBOOT_REFERENCE_2_CRC8_H_ +#ifndef VBOOT_REFERENCE_2CRC8_H_ +#define VBOOT_REFERENCE_2CRC8_H_ + +#include "2sysincludes.h" /** - * Calculate CRC-8 of the data, using x^8 + x^2 + x + 1 polynomial. + * Calculate CRC-8 of the data, using the ITU version. + * + * Calculate CRC-8 ITU version of the given buffer, using x^8 + x^2 + x + 1 + * polynomial. Note that the CRC-8 will evaluate to zero for a buffer of all + * zeroes. * * @param data Data to CRC * @param size Size of data in bytes @@ -17,4 +23,4 @@ */ uint8_t vb2_crc8(const void *data, uint32_t size); -#endif /* VBOOT_REFERENCE_2_CRC8_H_ */ +#endif /* VBOOT_REFERENCE_2CRC8_H_ */ diff --git a/firmware/2lib/include/2crypto.h b/firmware/2lib/include/2crypto.h index e786614c..f595fd4f 100644 --- a/firmware/2lib/include/2crypto.h +++ b/firmware/2lib/include/2crypto.h @@ -5,8 +5,9 @@ * Crypto constants for verified boot */ -#ifndef VBOOT_REFERENCE_VBOOT_2CRYPTO_H_ -#define VBOOT_REFERENCE_VBOOT_2CRYPTO_H_ +#ifndef VBOOT_REFERENCE_2CRYPTO_H_ +#define VBOOT_REFERENCE_2CRYPTO_H_ + #include <stdint.h> /* Verified boot crypto algorithms */ @@ -72,4 +73,4 @@ enum vb2_hash_algorithm { VB2_HASH_ALG_COUNT, }; -#endif /* VBOOT_REFERENCE_VBOOT_2CRYPTO_H_ */ +#endif /* VBOOT_REFERENCE_2CRYPTO_H_ */ diff --git a/firmware/2lib/include/2fw_hash_tags.h b/firmware/2lib/include/2fw_hash_tags.h index 0c061f56..1ecec6e0 100644 --- a/firmware/2lib/include/2fw_hash_tags.h +++ b/firmware/2lib/include/2fw_hash_tags.h @@ -5,8 +5,9 @@ * Firmware hash tags for verified boot */ -#ifndef VBOOT_REFERENCE_VBOOT_2FW_HASH_TAGS_H_ -#define VBOOT_REFERENCE_VBOOT_2FW_HASH_TAGS_H_ +#ifndef VBOOT_REFERENCE_2FW_HASH_TAGS_H_ +#define VBOOT_REFERENCE_2FW_HASH_TAGS_H_ + #include <stdint.h> /* @@ -37,4 +38,4 @@ enum vb2_hash_tag { VB2_HASH_TAG_CALLER_BASE = 0x40000000 }; -#endif /* VBOOT_REFERENCE_VBOOT_2FW_HASH_TAGS_H_ */ +#endif /* VBOOT_REFERENCE_2FW_HASH_TAGS_H_ */ diff --git a/firmware/2lib/include/2gbb.h b/firmware/2lib/include/2gbb.h index 4e4bd906..58da6637 100644 --- a/firmware/2lib/include/2gbb.h +++ b/firmware/2lib/include/2gbb.h @@ -5,8 +5,8 @@ * GBB accessor functions. */ -#ifndef VBOOT_REFERENCE_VBOOT_2GBB_H_ -#define VBOOT_REFERENCE_VBOOT_2GBB_H_ +#ifndef VBOOT_REFERENCE_2GBB_H_ +#define VBOOT_REFERENCE_2GBB_H_ #include "2common.h" @@ -43,4 +43,4 @@ vb2_error_t vb2_gbb_read_recovery_key(struct vb2_context *ctx, struct vb2_packed_key **keyp, uint32_t *size, struct vb2_workbuf *wb); -#endif /* VBOOT_REFERENCE_VBOOT_2GBB_H_ */ +#endif /* VBOOT_REFERENCE_2GBB_H_ */ diff --git a/firmware/2lib/include/2gbb_flags.h b/firmware/2lib/include/2gbb_flags.h index 6749aa3f..e90dfb15 100644 --- a/firmware/2lib/include/2gbb_flags.h +++ b/firmware/2lib/include/2gbb_flags.h @@ -7,8 +7,8 @@ * Should be imported externally via vb2_api.h. */ -#ifndef VBOOT_2_GBB_FLAGS_H_ -#define VBOOT_2_GBB_FLAGS_H_ +#ifndef VBOOT_REFERENCE_2GBB_FLAGS_H_ +#define VBOOT_REFERENCE_2GBB_FLAGS_H_ enum vb2_gbb_flag { /* @@ -84,4 +84,4 @@ enum vb2_gbb_flag { VB2_GBB_FLAG_ENABLE_UDC = 1 << 16, }; -#endif /* VBOOT_2_GBB_FLAGS_H_ */ +#endif /* VBOOT_REFERENCE_2GBB_FLAGS_H_ */ diff --git a/firmware/2lib/include/2hmac.h b/firmware/2lib/include/2hmac.h index 1df19397..2f8d8f7c 100644 --- a/firmware/2lib/include/2hmac.h +++ b/firmware/2lib/include/2hmac.h @@ -3,8 +3,8 @@ * found in the LICENSE file. */ -#ifndef VBOOT_REFERENCE_VBOOT_2HMAC_H_ -#define VBOOT_REFERENCE_VBOOT_2HMAC_H_ +#ifndef VBOOT_REFERENCE_2HMAC_H_ +#define VBOOT_REFERENCE_2HMAC_H_ #include <stdint.h> #include "2crypto.h" @@ -26,4 +26,4 @@ int hmac(enum vb2_hash_algorithm alg, const void *msg, uint32_t msg_size, uint8_t *mac, uint32_t mac_size); -#endif +#endif /* VBOOT_REFERENCE_2HMAC_H_ */ diff --git a/firmware/2lib/include/2id.h b/firmware/2lib/include/2id.h index 28ba5538..d1897fda 100644 --- a/firmware/2lib/include/2id.h +++ b/firmware/2lib/include/2id.h @@ -8,8 +8,9 @@ * resistant to collisions and easy to compare. */ -#ifndef VBOOT_REFERENCE_VBOOT_2ID_H_ -#define VBOOT_REFERENCE_VBOOT_2ID_H_ +#ifndef VBOOT_REFERENCE_2ID_H_ +#define VBOOT_REFERENCE_2ID_H_ + #include <stdint.h> #ifdef __cplusplus @@ -33,4 +34,4 @@ struct vb2_id { } #endif /* __cplusplus */ -#endif /* VBOOT_REFERENCE_VBOOT_2ID_H_ */ +#endif /* VBOOT_REFERENCE_2ID_H_ */ diff --git a/firmware/2lib/include/2misc.h b/firmware/2lib/include/2misc.h index 3b61bda4..c7970d68 100644 --- a/firmware/2lib/include/2misc.h +++ b/firmware/2lib/include/2misc.h @@ -5,8 +5,8 @@ * Misc functions which need access to vb2_context but are not public APIs */ -#ifndef VBOOT_REFERENCE_VBOOT_2MISC_H_ -#define VBOOT_REFERENCE_VBOOT_2MISC_H_ +#ifndef VBOOT_REFERENCE_2MISC_H_ +#define VBOOT_REFERENCE_2MISC_H_ #include "2api.h" #include "2struct.h" @@ -185,4 +185,4 @@ vb2_error_t vb2_load_kernel_keyblock(struct vb2_context *ctx); */ vb2_error_t vb2_load_kernel_preamble(struct vb2_context *ctx); -#endif /* VBOOT_REFERENCE_VBOOT_2MISC_H_ */ +#endif /* VBOOT_REFERENCE_2MISC_H_ */ diff --git a/firmware/2lib/include/2nvstorage.h b/firmware/2lib/include/2nvstorage.h index 1a6ab8ad..36dbaa03 100644 --- a/firmware/2lib/include/2nvstorage.h +++ b/firmware/2lib/include/2nvstorage.h @@ -5,8 +5,8 @@ * Non-volatile storage routines */ -#ifndef VBOOT_REFERENCE_VBOOT_2NVSTORAGE_H_ -#define VBOOT_REFERENCE_VBOOT_2NVSTORAGE_H_ +#ifndef VBOOT_REFERENCE_2NVSTORAGE_H_ +#define VBOOT_REFERENCE_2NVSTORAGE_H_ struct vb2_context; @@ -232,4 +232,4 @@ void vb2_nv_set(struct vb2_context *ctx, enum vb2_nv_param param, uint32_t value); -#endif /* VBOOT_REFERENCE_VBOOT_2NVSTORAGE_H_ */ +#endif /* VBOOT_REFERENCE_2NVSTORAGE_H_ */ diff --git a/firmware/2lib/include/2nvstorage_fields.h b/firmware/2lib/include/2nvstorage_fields.h index 11a9f8fb..c9641407 100644 --- a/firmware/2lib/include/2nvstorage_fields.h +++ b/firmware/2lib/include/2nvstorage_fields.h @@ -5,8 +5,8 @@ * Non-volatile storage bitfields */ -#ifndef VBOOT_REFERENCE_VBOOT_2NVSTORAGE_FIELDS_H_ -#define VBOOT_REFERENCE_VBOOT_2NVSTORAGE_FIELDS_H_ +#ifndef VBOOT_REFERENCE_2NVSTORAGE_FIELDS_H_ +#define VBOOT_REFERENCE_2NVSTORAGE_FIELDS_H_ /* * Constants for NV storage. We use this rather than structs and bitfields so @@ -111,4 +111,4 @@ enum vb2_nv_offset { #define VB2_NV_MISC_DEPRECATED_DISABLE_ALT_OS 0x20 #define VB2_NV_MISC_POST_EC_SYNC_DELAY 0x40 -#endif /* VBOOT_REFERENCE_VBOOT_2NVSTORAGE_FIELDS_H_ */ +#endif /* VBOOT_REFERENCE_2NVSTORAGE_FIELDS_H_ */ diff --git a/firmware/2lib/include/2recovery_reasons.h b/firmware/2lib/include/2recovery_reasons.h index f8e6dbe9..870df1f0 100644 --- a/firmware/2lib/include/2recovery_reasons.h +++ b/firmware/2lib/include/2recovery_reasons.h @@ -5,8 +5,8 @@ * Recovery reasons */ -#ifndef VBOOT_REFERENCE_VBOOT_2RECOVERY_REASONS_H_ -#define VBOOT_REFERENCE_VBOOT_2RECOVERY_REASONS_H_ +#ifndef VBOOT_REFERENCE_2RECOVERY_REASONS_H_ +#define VBOOT_REFERENCE_2RECOVERY_REASONS_H_ /* Recovery reason codes */ enum vb2_nv_recovery { @@ -250,4 +250,4 @@ enum vb2_nv_recovery { VB2_RECOVERY_US_UNSPECIFIED = 0xff, }; -#endif /* VBOOT_REFERENCE_VBOOT_2RECOVERY_REASONS_H_ */ +#endif /* VBOOT_REFERENCE_2RECOVERY_REASONS_H_ */ diff --git a/firmware/2lib/include/2return_codes.h b/firmware/2lib/include/2return_codes.h index 68edff38..f12f2c1a 100644 --- a/firmware/2lib/include/2return_codes.h +++ b/firmware/2lib/include/2return_codes.h @@ -3,8 +3,8 @@ * found in the LICENSE file. */ -#ifndef VBOOT_2_RETURN_CODES_H_ -#define VBOOT_2_RETURN_CODES_H_ +#ifndef VBOOT_REFERENCE_2RETURN_CODES_H_ +#define VBOOT_REFERENCE_2RETURN_CODES_H_ /* * Functions which return an error all return this type. This is a 32-bit @@ -905,4 +905,4 @@ enum vb2_return_code { VB2_ERROR_MAX = VB2_ERROR_BASE + 0x1fffffff, }; -#endif /* VBOOT_2_RETURN_CODES_H_ */ +#endif /* VBOOT_REFERENCE_2RETURN_CODES_H_ */ diff --git a/firmware/2lib/include/2secdata.h b/firmware/2lib/include/2secdata.h index bcd308b9..7acdb610 100644 --- a/firmware/2lib/include/2secdata.h +++ b/firmware/2lib/include/2secdata.h @@ -5,8 +5,12 @@ * Secure non-volatile storage routines */ -#ifndef VBOOT_REFERENCE_VBOOT_2SECDATA_H_ -#define VBOOT_REFERENCE_VBOOT_2SECDATA_H_ +#ifndef VBOOT_REFERENCE_2SECDATA_H_ +#define VBOOT_REFERENCE_2SECDATA_H_ + +/* Avoid circular dependency with 2api.h */ +struct vb2_context; +typedef uint32_t vb2_error_t; /*****************************************************************************/ /* Firmware version space */ @@ -161,4 +165,4 @@ vb2_error_t vb2_secdatak_get(struct vb2_context *ctx, vb2_error_t vb2_secdatak_set(struct vb2_context *ctx, enum vb2_secdatak_param param, uint32_t value); -#endif /* VBOOT_REFERENCE_VBOOT_2SECDATA_H_ */ +#endif /* VBOOT_REFERENCE_2SECDATA_H_ */ diff --git a/firmware/2lib/include/2struct.h b/firmware/2lib/include/2struct.h index a045fef3..17294ce6 100644 --- a/firmware/2lib/include/2struct.h +++ b/firmware/2lib/include/2struct.h @@ -13,8 +13,9 @@ * have trouble with accessing unaligned integers. */ -#ifndef VBOOT_REFERENCE_VBOOT_2STRUCT_H_ -#define VBOOT_REFERENCE_VBOOT_2STRUCT_H_ +#ifndef VBOOT_REFERENCE_2STRUCT_H_ +#define VBOOT_REFERENCE_2STRUCT_H_ + #include "2constants.h" #include "2crypto.h" #include "2sysincludes.h" @@ -333,4 +334,4 @@ struct vb2_packed_key { #define EXPECTED_VB2_PACKED_KEY_SIZE 32 -#endif /* VBOOT_REFERENCE_VBOOT_2STRUCT_H_ */ +#endif /* VBOOT_REFERENCE_2STRUCT_H_ */ diff --git a/firmware/2lib/include/2sysincludes.h b/firmware/2lib/include/2sysincludes.h index 792ece43..c23054a1 100644 --- a/firmware/2lib/include/2sysincludes.h +++ b/firmware/2lib/include/2sysincludes.h @@ -10,8 +10,8 @@ * fixed up for platforms which don't have all the system includes. */ -#ifndef VBOOT_REFERENCE_2_SYSINCLUDES_H_ -#define VBOOT_REFERENCE_2_SYSINCLUDES_H_ +#ifndef VBOOT_REFERENCE_2SYSINCLUDES_H_ +#define VBOOT_REFERENCE_2SYSINCLUDES_H_ #include <ctype.h> #include <inttypes.h> /* For PRIu64 */ @@ -25,4 +25,4 @@ #include <memory.h> #endif -#endif /* VBOOT_REFERENCE_2_SYSINCLUDES_H_ */ +#endif /* VBOOT_REFERENCE_2SYSINCLUDES_H_ */ |