summaryrefslogtreecommitdiff
path: root/firmware/lib21
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2014-12-04 09:54:37 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-12-05 00:02:00 +0000
commit308d2540929cd95e2a565be95ce0b1d45d2fbed2 (patch)
tree8df30f986fd05e934ca3461398cfc63cda398026 /firmware/lib21
parent6f1b82ac14f341d9733d6e95d518b3ee352002ef (diff)
downloadvboot-308d2540929cd95e2a565be95ce0b1d45d2fbed2.tar.gz
vboot2: Get rid of extra '2' at end of new struct names
Now that lib20 and lib21 are distinct, they can have overlapping struct names. This will be cleaner in the long run, since vboot 2.0 (lib20) is just a temporary stepping stone to vboot 2.1 (lib21). It would be a shame to need to carry around the overhead of that extra digit forever. No functional changes, just a lot of renaming. BUG=chromium:423882 BRANCH=none TEST=make runtests && VBOOT2=1 make runtests (works with/withoug VBOOT2 flag) And compile firmware for veyron_pinky Change-Id: I25f348fd31e32d08ca576836dfdd1278828765a1 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/233183 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'firmware/lib21')
-rw-r--r--firmware/lib21/api.c20
-rw-r--r--firmware/lib21/common.c79
-rw-r--r--firmware/lib21/include/vb2_common.h54
-rw-r--r--firmware/lib21/include/vb2_struct.h94
-rw-r--r--firmware/lib21/misc.c32
-rw-r--r--firmware/lib21/packed_key.c14
6 files changed, 145 insertions, 148 deletions
diff --git a/firmware/lib21/api.c b/firmware/lib21/api.c
index 99bc4433..beed98bc 100644
--- a/firmware/lib21/api.c
+++ b/firmware/lib21/api.c
@@ -16,19 +16,19 @@
#include "2rsa.h"
#include "vb2_common.h"
-int vb2api_fw_phase3_2(struct vb2_context *ctx)
+int vb2api_fw_phase3(struct vb2_context *ctx)
{
int rv;
/* Verify firmware keyblock */
- rv = vb2_load_fw_keyblock2(ctx);
+ rv = vb2_load_fw_keyblock(ctx);
if (rv) {
vb2_fail(ctx, VB2_RECOVERY_RO_INVALID_RW, rv);
return rv;
}
/* Verify firmware preamble */
- rv = vb2_load_fw_preamble2(ctx);
+ rv = vb2_load_fw_preamble(ctx);
if (rv) {
vb2_fail(ctx, VB2_RECOVERY_RO_INVALID_RW, rv);
return rv;
@@ -42,8 +42,8 @@ int vb2api_init_hash2(struct vb2_context *ctx,
uint32_t *size)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
- const struct vb2_fw_preamble2 *pre;
- const struct vb2_signature2 *sig = NULL;
+ const struct vb2_fw_preamble *pre;
+ const struct vb2_signature *sig = NULL;
struct vb2_digest_context *dc;
struct vb2_workbuf wb;
uint32_t hash_offset;
@@ -54,13 +54,13 @@ int vb2api_init_hash2(struct vb2_context *ctx,
/* Get preamble pointer */
if (!sd->workbuf_preamble_size)
return VB2_ERROR_API_INIT_HASH_PREAMBLE;
- pre = (const struct vb2_fw_preamble2 *)
+ pre = (const struct vb2_fw_preamble *)
(ctx->workbuf + sd->workbuf_preamble_offset);
/* Find the matching signature */
hash_offset = pre->hash_offset;
for (i = 0; i < pre->hash_count; i++) {
- sig = (const struct vb2_signature2 *)
+ sig = (const struct vb2_signature *)
((uint8_t *)pre + hash_offset);
if (!memcmp(guid, &sig->guid, sizeof(*guid)))
@@ -96,7 +96,7 @@ int vb2api_init_hash2(struct vb2_context *ctx,
return vb2_digest_init(dc, sig->hash_alg);
}
-int vb2api_check_hash2(struct vb2_context *ctx)
+int vb2api_check_hash(struct vb2_context *ctx)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
struct vb2_digest_context *dc = (struct vb2_digest_context *)
@@ -106,7 +106,7 @@ int vb2api_check_hash2(struct vb2_context *ctx)
uint8_t *digest;
uint32_t digest_size = vb2_digest_size(dc->hash_alg);
- const struct vb2_signature2 *sig;
+ const struct vb2_signature *sig;
int rv;
@@ -115,7 +115,7 @@ int vb2api_check_hash2(struct vb2_context *ctx)
/* Get signature pointer */
if (!sd->hash_tag)
return VB2_ERROR_API_CHECK_HASH_TAG;
- sig = (const struct vb2_signature2 *)(ctx->workbuf + sd->hash_tag);
+ sig = (const struct vb2_signature *)(ctx->workbuf + sd->hash_tag);
/* Must have initialized hash digest work area */
if (!sd->workbuf_hash_size)
diff --git a/firmware/lib21/common.c b/firmware/lib21/common.c
index cf1ec417..5adbf7ae 100644
--- a/firmware/lib21/common.c
+++ b/firmware/lib21/common.c
@@ -173,15 +173,14 @@ const struct vb2_guid *vb2_hash_guid(enum vb2_hash_algorithm hash_alg)
}
}
-int vb2_verify_signature2(const struct vb2_signature2 *sig,
- uint32_t size)
+int vb2_verify_signature(const struct vb2_signature *sig, uint32_t size)
{
uint32_t min_offset = 0;
uint32_t expect_sig_size;
int rv;
/* Check magic number */
- if (sig->c.magic != VB2_MAGIC_SIGNATURE2)
+ if (sig->c.magic != VB2_MAGIC_SIGNATURE)
return VB2_ERROR_SIG_MAGIC;
/* Make sure common header is good */
@@ -194,7 +193,7 @@ int vb2_verify_signature2(const struct vb2_signature2 *sig,
* that's compatible across readers matching the major version, and we
* haven't added any new fields.
*/
- if (sig->c.struct_version_major != VB2_SIGNATURE2_VERSION_MAJOR)
+ if (sig->c.struct_version_major != VB2_SIGNATURE_VERSION_MAJOR)
return VB2_ERROR_SIG_VERSION;
/* Make sure header is big enough for signature */
@@ -220,15 +219,15 @@ int vb2_verify_signature2(const struct vb2_signature2 *sig,
/**
* Return the signature data for a signature
*/
-static uint8_t *vb2_signature2_data(struct vb2_signature2 *sig)
+static uint8_t *vb2_signature_data(struct vb2_signature *sig)
{
return (uint8_t *)sig + sig->sig_offset;
}
-int vb2_verify_digest2(const struct vb2_public_key *key,
- struct vb2_signature2 *sig,
- const uint8_t *digest,
- const struct vb2_workbuf *wb)
+int vb2_verify_digest(const struct vb2_public_key *key,
+ struct vb2_signature *sig,
+ const uint8_t *digest,
+ const struct vb2_workbuf *wb)
{
uint32_t key_sig_size = vb2_sig_size(key->sig_alg, key->hash_alg);
@@ -245,7 +244,7 @@ int vb2_verify_digest2(const struct vb2_public_key *key,
if (key->sig_alg == VB2_SIG_NONE) {
/* Bare hash */
- if (vb2_safe_memcmp(vb2_signature2_data(sig),
+ if (vb2_safe_memcmp(vb2_signature_data(sig),
digest, key_sig_size))
return VB2_ERROR_VDATA_VERIFY_DIGEST;
@@ -253,16 +252,16 @@ int vb2_verify_digest2(const struct vb2_public_key *key,
} else {
/* RSA-signed digest */
return vb2_rsa_verify_digest(key,
- vb2_signature2_data(sig),
+ vb2_signature_data(sig),
digest, wb);
}
}
-int vb2_verify_data2(const void *data,
- uint32_t size,
- struct vb2_signature2 *sig,
- const struct vb2_public_key *key,
- const struct vb2_workbuf *wb)
+int vb2_verify_data(const void *data,
+ uint32_t size,
+ struct vb2_signature *sig,
+ const struct vb2_public_key *key,
+ const struct vb2_workbuf *wb)
{
struct vb2_workbuf wblocal = *wb;
struct vb2_digest_context *dc;
@@ -303,19 +302,19 @@ int vb2_verify_data2(const void *data,
vb2_workbuf_free(&wblocal, sizeof(*dc));
- return vb2_verify_digest2(key, sig, digest, &wblocal);
+ return vb2_verify_digest(key, sig, digest, &wblocal);
}
-int vb2_verify_keyblock2(struct vb2_keyblock2 *block,
- uint32_t size,
- const struct vb2_public_key *key,
- const struct vb2_workbuf *wb)
+int vb2_verify_keyblock(struct vb2_keyblock *block,
+ uint32_t size,
+ const struct vb2_public_key *key,
+ const struct vb2_workbuf *wb)
{
uint32_t min_offset = 0, sig_offset;
int rv, i;
/* Check magic number */
- if (block->c.magic != VB2_MAGIC_KEYBLOCK2)
+ if (block->c.magic != VB2_MAGIC_KEYBLOCK)
return VB2_ERROR_KEYBLOCK_MAGIC;
/* Make sure common header is good */
@@ -328,7 +327,7 @@ int vb2_verify_keyblock2(struct vb2_keyblock2 *block,
* that's compatible across readers matching the major version, and we
* haven't added any new fields.
*/
- if (block->c.struct_version_major != VB2_KEYBLOCK2_VERSION_MAJOR)
+ if (block->c.struct_version_major != VB2_KEYBLOCK_VERSION_MAJOR)
return VB2_ERROR_KEYBLOCK_HEADER_VERSION;
/* Make sure header is big enough */
@@ -343,7 +342,7 @@ int vb2_verify_keyblock2(struct vb2_keyblock2 *block,
/* Loop over signatures */
sig_offset = block->sig_offset;
for (i = 0; i < block->sig_count; i++, sig_offset = min_offset) {
- struct vb2_signature2 *sig;
+ struct vb2_signature *sig;
/* Make sure signature is inside keyblock */
rv = vb2_verify_common_subobject(block, &min_offset,
@@ -351,11 +350,11 @@ int vb2_verify_keyblock2(struct vb2_keyblock2 *block,
if (rv)
return rv;
- sig = (struct vb2_signature2 *)((uint8_t *)block + sig_offset);
+ sig = (struct vb2_signature *)((uint8_t *)block + sig_offset);
/* Verify the signature integrity */
- rv = vb2_verify_signature2(sig,
- block->c.total_size - sig_offset);
+ rv = vb2_verify_signature(sig,
+ block->c.total_size - sig_offset);
if (rv)
return rv;
@@ -367,24 +366,24 @@ int vb2_verify_keyblock2(struct vb2_keyblock2 *block,
if (sig->data_size != block->sig_offset)
return VB2_ERROR_KEYBLOCK_SIGNED_SIZE;
- return vb2_verify_data2(block, block->sig_offset, sig, key, wb);
+ return vb2_verify_data(block, block->sig_offset, sig, key, wb);
}
/* If we're still here, no signature matched the key GUID */
return VB2_ERROR_KEYBLOCK_SIG_GUID;
}
-int vb2_verify_fw_preamble2(struct vb2_fw_preamble2 *preamble,
- uint32_t size,
- const struct vb2_public_key *key,
- const struct vb2_workbuf *wb)
+int vb2_verify_fw_preamble(struct vb2_fw_preamble *preamble,
+ uint32_t size,
+ const struct vb2_public_key *key,
+ const struct vb2_workbuf *wb)
{
- struct vb2_signature2 *sig;
+ struct vb2_signature *sig;
uint32_t min_offset = 0, hash_offset;
int rv, i;
/* Check magic number */
- if (preamble->c.magic != VB2_MAGIC_FW_PREAMBLE2)
+ if (preamble->c.magic != VB2_MAGIC_FW_PREAMBLE)
return VB2_ERROR_PREAMBLE_MAGIC;
/* Make sure common header is good */
@@ -397,7 +396,7 @@ int vb2_verify_fw_preamble2(struct vb2_fw_preamble2 *preamble,
* that's compatible across readers matching the major version, and we
* haven't added any new fields.
*/
- if (preamble->c.struct_version_major != VB2_FW_PREAMBLE2_VERSION_MAJOR)
+ if (preamble->c.struct_version_major != VB2_FW_PREAMBLE_VERSION_MAJOR)
return VB2_ERROR_PREAMBLE_HEADER_VERSION;
/* Make sure header is big enough */
@@ -413,11 +412,11 @@ int vb2_verify_fw_preamble2(struct vb2_fw_preamble2 *preamble,
if (rv)
return rv;
- sig = (struct vb2_signature2 *)
+ sig = (struct vb2_signature *)
((uint8_t *)preamble + hash_offset);
/* Verify the signature integrity */
- rv = vb2_verify_signature2(
+ rv = vb2_verify_signature(
sig, preamble->c.total_size - hash_offset);
if (rv)
return rv;
@@ -434,10 +433,10 @@ int vb2_verify_fw_preamble2(struct vb2_fw_preamble2 *preamble,
return rv;
/* Verify preamble signature */
- sig = (struct vb2_signature2 *)((uint8_t *)preamble +
- preamble->sig_offset);
+ sig = (struct vb2_signature *)((uint8_t *)preamble +
+ preamble->sig_offset);
- rv = vb2_verify_data2(preamble, preamble->sig_offset, sig, key, wb);
+ rv = vb2_verify_data(preamble, preamble->sig_offset, sig, key, wb);
if (rv)
return rv;
diff --git a/firmware/lib21/include/vb2_common.h b/firmware/lib21/include/vb2_common.h
index db296046..19b43109 100644
--- a/firmware/lib21/include/vb2_common.h
+++ b/firmware/lib21/include/vb2_common.h
@@ -8,10 +8,8 @@
#ifndef VBOOT_REFERENCE_VB2_COMMON_H_
#define VBOOT_REFERENCE_VB2_COMMON_H_
-#include "2api.h"
#include "2common.h"
#include "2return_codes.h"
-#include "2sha.h"
#include "2struct.h"
#include "vb2_struct.h"
@@ -87,23 +85,23 @@ int vb2_verify_common_subobject(const void *parent,
* @param size Size of buffer in bytes
* @return VB2_SUCCESS, or non-zero error code if error.
*/
-int vb2_unpack_key2(struct vb2_public_key *key,
- const uint8_t *buf,
- uint32_t size);
+int vb2_unpack_key(struct vb2_public_key *key,
+ const uint8_t *buf,
+ uint32_t size);
/**
* Unpack the RSA data fields for a public key
*
- * This is called by vb2_unpack_key2() to extract the arrays from a packed key.
+ * This is called by vb2_unpack_key() to extract the arrays from a packed key.
* These elements of *key will point inside the key_data buffer.
*
* @param key Destination key for RSA data fields
* @param key_data Packed key data (from inside a packed key buffer)
* @param key_size Size of packed key data in bytes
*/
-int vb2_unpack_key2_data(struct vb2_public_key *key,
- const uint8_t *key_data,
- uint32_t key_size);
+int vb2_unpack_key_data(struct vb2_public_key *key,
+ const uint8_t *key_data,
+ uint32_t key_size);
/**
* Verify the integrity of a signature struct
@@ -111,8 +109,8 @@ int vb2_unpack_key2_data(struct vb2_public_key *key,
* @param size Size of buffer containing signature struct
* @return VB2_SUCCESS, or non-zero if error.
*/
-int vb2_verify_signature2(const struct vb2_signature2 *sig,
- uint32_t size);
+int vb2_verify_signature(const struct vb2_signature *sig,
+ uint32_t size);
/**
* Verify a signature against an expected hash digest.
@@ -123,10 +121,10 @@ int vb2_verify_signature2(const struct vb2_signature2 *sig,
* @param wb Work buffer
* @return VB2_SUCCESS, or non-zero if error.
*/
-int vb2_verify_digest2(const struct vb2_public_key *key,
- struct vb2_signature2 *sig,
- const uint8_t *digest,
- const struct vb2_workbuf *wb);
+int vb2_verify_digest(const struct vb2_public_key *key,
+ struct vb2_signature *sig,
+ const uint8_t *digest,
+ const struct vb2_workbuf *wb);
/**
* Verify data matches signature.
@@ -139,11 +137,11 @@ int vb2_verify_digest2(const struct vb2_public_key *key,
* @param wb Work buffer
* @return VB2_SUCCESS, or non-zero error code if error.
*/
-int vb2_verify_data2(const void *data,
- uint32_t size,
- struct vb2_signature2 *sig,
- const struct vb2_public_key *key,
- const struct vb2_workbuf *wb);
+int vb2_verify_data(const void *data,
+ uint32_t size,
+ struct vb2_signature *sig,
+ const struct vb2_public_key *key,
+ const struct vb2_workbuf *wb);
/**
* Check the sanity of a key block using a public key.
@@ -157,10 +155,10 @@ int vb2_verify_data2(const void *data,
* @param wb Work buffer
* @return VB2_SUCCESS, or non-zero error code if error.
*/
-int vb2_verify_keyblock2(struct vb2_keyblock2 *block,
- uint32_t size,
- const struct vb2_public_key *key,
- const struct vb2_workbuf *wb);
+int vb2_verify_keyblock(struct vb2_keyblock *block,
+ uint32_t size,
+ const struct vb2_public_key *key,
+ const struct vb2_workbuf *wb);
/**
* Check the sanity of a firmware preamble using a public key.
@@ -173,9 +171,9 @@ int vb2_verify_keyblock2(struct vb2_keyblock2 *block,
* @param wb Work buffer
* @return VB2_SUCCESS, or non-zero error code if error.
*/
-int vb2_verify_fw_preamble2(struct vb2_fw_preamble2 *preamble,
- uint32_t size,
- const struct vb2_public_key *key,
- const struct vb2_workbuf *wb);
+int vb2_verify_fw_preamble(struct vb2_fw_preamble *preamble,
+ uint32_t size,
+ const struct vb2_public_key *key,
+ const struct vb2_workbuf *wb);
#endif /* VBOOT_REFERENCE_VB2_COMMON_H_ */
diff --git a/firmware/lib21/include/vb2_struct.h b/firmware/lib21/include/vb2_struct.h
index 4bf4da74..d9921d94 100644
--- a/firmware/lib21/include/vb2_struct.h
+++ b/firmware/lib21/include/vb2_struct.h
@@ -23,23 +23,23 @@
* structs as invalid.
*/
enum vb2_struct_common_magic {
- /* "Vb2B" = vb2_keyblock2.c.magic */
- VB2_MAGIC_KEYBLOCK2 = 0x42326256,
+ /* "Vb2B" = vb2_keyblock.c.magic */
+ VB2_MAGIC_KEYBLOCK = 0x42326256,
/* "Vb2F" = vb2_fw_preamble.c.magic */
- VB2_MAGIC_FW_PREAMBLE2 = 0x46326256,
+ VB2_MAGIC_FW_PREAMBLE = 0x46326256,
- /* "Vb2I" = vb2_packed_private_key2.c.magic */
- VB2_MAGIC_PACKED_PRIVATE_KEY2 = 0x49326256,
+ /* "Vb2I" = vb2_packed_private_key.c.magic */
+ VB2_MAGIC_PACKED_PRIVATE_KEY = 0x49326256,
/* "Vb2K" = vb2_kernel_preamble.c.magic */
- VB2_MAGIC_KERNEL_PREAMBLE2 = 0x4b326256,
+ VB2_MAGIC_KERNEL_PREAMBLE = 0x4b326256,
- /* "Vb2P" = vb2_packed_key2.c.magic */
- VB2_MAGIC_PACKED_KEY2 = 0x50326256,
+ /* "Vb2P" = vb2_packed_key.c.magic */
+ VB2_MAGIC_PACKED_KEY = 0x50326256,
/* "Vb2S" = vb2_signature.c.magic */
- VB2_MAGIC_SIGNATURE2 = 0x53326256,
+ VB2_MAGIC_SIGNATURE = 0x53326256,
};
@@ -102,19 +102,19 @@ struct vb2_struct_common {
#define EXPECTED_VB2_STRUCT_COMMON_SIZE 20
-/* Current version of vb2_packed_key2 struct */
-#define VB2_PACKED_KEY2_VERSION_MAJOR 3
-#define VB2_PACKED_KEY2_VERSION_MINOR 0
+/* Current version of vb2_packed_key struct */
+#define VB2_PACKED_KEY_VERSION_MAJOR 3
+#define VB2_PACKED_KEY_VERSION_MINOR 0
/*
- * Packed public key data, version 2
+ * Packed public key data
*
* The key data must be arranged like this:
- * 1) vb2_packed_key2 header struct h
+ * 1) vb2_packed_key header struct h
* 2) Key description (pointed to by h.c.fixed_size)
* 3) Key data key (pointed to by h.key_offset)
*/
-struct vb2_packed_key2 {
+struct vb2_packed_key {
/* Common header fields */
struct vb2_struct_common c;
@@ -141,22 +141,22 @@ struct vb2_packed_key2 {
struct vb2_guid guid;
} __attribute__((packed));
-#define EXPECTED_VB2_PACKED_KEY2_SIZE \
+#define EXPECTED_VB2_PACKED_KEY_SIZE \
(EXPECTED_VB2_STRUCT_COMMON_SIZE + EXPECTED_GUID_SIZE + 16)
-/* Current version of vb2_packed_private_key2 struct */
-#define VB2_PACKED_PRIVATE_KEY2_VERSION_MAJOR 3
-#define VB2_PACKED_PRIVATE_KEY2_VERSION_MINOR 0
+/* Current version of vb2_packed_private_key struct */
+#define VB2_PACKED_PRIVATE_KEY_VERSION_MAJOR 3
+#define VB2_PACKED_PRIVATE_KEY_VERSION_MINOR 0
/*
- * Packed private key data, version 2
+ * Packed private key data
*
* The key data must be arranged like this:
- * 1) vb2_packed_private_key2 header struct h
+ * 1) vb2_packed_private_key header struct h
* 2) Key description (pointed to by h.c.fixed_size)
* 3) Key data key (pointed to by h.key_offset)
*/
-struct vb2_packed_private_key2 {
+struct vb2_packed_private_key {
/* Common header fields */
struct vb2_struct_common c;
@@ -180,22 +180,22 @@ struct vb2_packed_private_key2 {
struct vb2_guid guid;
} __attribute__((packed));
-#define EXPECTED_VB2_PACKED_PRIVATE_KEY2_SIZE \
+#define EXPECTED_VB2_PACKED_PRIVATE_KEY_SIZE \
(EXPECTED_VB2_STRUCT_COMMON_SIZE + EXPECTED_GUID_SIZE + 12)
-/* Current version of vb2_signature2 struct */
-#define VB2_SIGNATURE2_VERSION_MAJOR 3
-#define VB2_SIGNATURE2_VERSION_MINOR 0
+/* Current version of vb2_signature struct */
+#define VB2_SIGNATURE_VERSION_MAJOR 3
+#define VB2_SIGNATURE_VERSION_MINOR 0
/*
- * Signature data, version 2
+ * Signature data
*
* The signature data must be arranged like this:
- * 1) vb2_signature2 header struct h
+ * 1) vb2_signature header struct h
* 2) Signature description (pointed to by h.c.fixed_size)
* 3) Signature data (pointed to by h.sig_offset)
*/
-struct vb2_signature2 {
+struct vb2_signature {
/* Common header fields */
struct vb2_struct_common c;
@@ -228,20 +228,20 @@ struct vb2_signature2 {
struct vb2_guid guid;
} __attribute__((packed));
-#define EXPECTED_VB2_SIGNATURE2_SIZE \
+#define EXPECTED_VB2_SIGNATURE_SIZE \
(EXPECTED_VB2_STRUCT_COMMON_SIZE + EXPECTED_GUID_SIZE + 16)
-/* Current version of vb2_keyblock2 struct */
-#define VB2_KEYBLOCK2_VERSION_MAJOR 3
-#define VB2_KEYBLOCK2_VERSION_MINOR 0
+/* Current version of vb2_keyblock struct */
+#define VB2_KEYBLOCK_VERSION_MAJOR 3
+#define VB2_KEYBLOCK_VERSION_MINOR 0
/*
* Key block. This contains a signed, versioned key for use in the next stage
* of verified boot.
*
* The key block data must be arranged like this:
- * 1) vb2_keyblock2 header struct h
+ * 1) vb2_keyblock header struct h
* 2) Keyblock description (pointed to by h.c.fixed_size)
* 3) Data key (pointed to by h.data_key_offset)
* 4) Signatures (first signature pointed to by h.sig_offset)
@@ -249,7 +249,7 @@ struct vb2_signature2 {
* The signatures from 4) must cover all the data from 1), 2), 3). That is,
* signatures must sign all data up to sig_offset.
*/
-struct vb2_keyblock2 {
+struct vb2_keyblock {
/* Common header fields */
struct vb2_struct_common c;
@@ -257,7 +257,7 @@ struct vb2_keyblock2 {
uint32_t flags;
/*
- * Offset of key (struct vb2_packed_key2) to use in next stage of
+ * Offset of key (struct vb2_packed_key) to use in next stage of
* verification, from start of the keyblock.
*/
uint32_t key_offset;
@@ -266,7 +266,7 @@ struct vb2_keyblock2 {
uint32_t sig_count;
/*
- * Offset of the first signature (struct vb2_signature2) from the start
+ * Offset of the first signature (struct vb2_signature) from the start
* of the keyblock.
*
* Signatures sign the contents of this struct and the data pointed to
@@ -284,25 +284,25 @@ struct vb2_keyblock2 {
uint32_t sig_offset;
} __attribute__((packed));
-#define EXPECTED_VB2_KEYBLOCK2_SIZE (EXPECTED_VB2_STRUCT_COMMON_SIZE + 16)
+#define EXPECTED_VB2_KEYBLOCK_SIZE (EXPECTED_VB2_STRUCT_COMMON_SIZE + 16)
-/* Current version of vb2_fw_preamble2 struct */
-#define VB2_FW_PREAMBLE2_VERSION_MAJOR 3
-#define VB2_FW_PREAMBLE2_VERSION_MINOR 0
+/* Current version of vb2_fw_preamble struct */
+#define VB2_FW_PREAMBLE_VERSION_MAJOR 3
+#define VB2_FW_PREAMBLE_VERSION_MINOR 0
/*
* Firmware preamble
*
* The preamble data must be arranged like this:
- * 1) vb2_fw_preamble2 header struct h
+ * 1) vb2_fw_preamble header struct h
* 2) Preamble description (pointed to by h.c.fixed_size)
* 3) Hashes (pointed to by h.hash_offset)
* 4) Signature (pointed to by h.sig_offset)
*
* The signature 4) must cover all the data from 1), 2), 3).
*/
-struct vb2_fw_preamble2 {
+struct vb2_fw_preamble {
/* Common header fields */
struct vb2_struct_common c;
@@ -310,13 +310,13 @@ struct vb2_fw_preamble2 {
uint32_t flags;
/* Firmware version */
- uint32_t firmware_version;
+ uint32_t fw_version;
- /* Offset of signature (struct vb2_signature2) for this preamble */
+ /* Offset of signature (struct vb2_signature) for this preamble */
uint32_t sig_offset;
/*
- * The preamble contains a list of hashes (struct vb2_signature2) for
+ * The preamble contains a list of hashes (struct vb2_signature) for
* the various firmware components. These have sig_alg=VB2_SIG_NONE,
* and the GUID for each hash identifies the component being hashed.
* The calling firmware is responsible for knowing where to find those
@@ -331,6 +331,6 @@ struct vb2_fw_preamble2 {
uint32_t hash_offset;
} __attribute__((packed));
-#define EXPECTED_VB2_FW_PREAMBLE2_SIZE (EXPECTED_VB2_STRUCT_COMMON_SIZE + 20)
+#define EXPECTED_VB2_FW_PREAMBLE_SIZE (EXPECTED_VB2_STRUCT_COMMON_SIZE + 20)
#endif /* VBOOT_REFERENCE_VB2_STRUCT_H_ */
diff --git a/firmware/lib21/misc.c b/firmware/lib21/misc.c
index 16648a74..384d44ed 100644
--- a/firmware/lib21/misc.c
+++ b/firmware/lib21/misc.c
@@ -62,16 +62,16 @@ int vb2_read_resource_object(struct vb2_context *ctx,
return VB2_SUCCESS;
}
-int vb2_load_fw_keyblock2(struct vb2_context *ctx)
+int vb2_load_fw_keyblock(struct vb2_context *ctx)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
struct vb2_workbuf wb;
uint8_t *key_data;
uint32_t key_size;
- struct vb2_packed_key2 *packed_key;
+ struct vb2_packed_key *packed_key;
struct vb2_public_key root_key;
- struct vb2_keyblock2 *kb;
+ struct vb2_keyblock *kb;
uint32_t sec_version;
int rv;
@@ -90,7 +90,7 @@ int vb2_load_fw_keyblock2(struct vb2_context *ctx)
return rv;
/* Unpack the root key */
- rv = vb2_unpack_key2(&root_key, key_data, key_size);
+ rv = vb2_unpack_key(&root_key, key_data, key_size);
if (rv)
return rv;
@@ -104,7 +104,7 @@ int vb2_load_fw_keyblock2(struct vb2_context *ctx)
return rv;
/* Verify the keyblock */
- rv = vb2_verify_keyblock2(kb, kb->c.total_size, &root_key, &wb);
+ rv = vb2_verify_keyblock(kb, kb->c.total_size, &root_key, &wb);
if (rv)
return rv;
@@ -116,7 +116,7 @@ int vb2_load_fw_keyblock2(struct vb2_context *ctx)
if (rv)
return rv;
- packed_key = (struct vb2_packed_key2 *)((uint8_t *)kb + kb->key_offset);
+ packed_key = (struct vb2_packed_key *)((uint8_t *)kb + kb->key_offset);
/* Key version is the upper 16 bits of the composite firmware version */
if (packed_key->key_version > 0xffff)
@@ -137,7 +137,7 @@ int vb2_load_fw_keyblock2(struct vb2_context *ctx)
* paranoid.
*/
memmove(key_data, packed_key, packed_key->c.total_size);
- packed_key = (struct vb2_packed_key2 *)key_data;
+ packed_key = (struct vb2_packed_key *)key_data;
/* Save the packed key offset and size */
sd->workbuf_data_key_offset = vb2_offset_of(ctx->workbuf, key_data);
@@ -150,7 +150,7 @@ int vb2_load_fw_keyblock2(struct vb2_context *ctx)
return VB2_SUCCESS;
}
-int vb2_load_fw_preamble2(struct vb2_context *ctx)
+int vb2_load_fw_preamble(struct vb2_context *ctx)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
struct vb2_workbuf wb;
@@ -160,7 +160,7 @@ int vb2_load_fw_preamble2(struct vb2_context *ctx)
struct vb2_public_key data_key;
/* Preamble goes in the next unused chunk of work buffer */
- struct vb2_fw_preamble2 *pre;
+ struct vb2_fw_preamble *pre;
uint32_t sec_version;
int rv;
@@ -171,7 +171,7 @@ int vb2_load_fw_preamble2(struct vb2_context *ctx)
if (!sd->workbuf_data_key_size)
return VB2_ERROR_FW_PREAMBLE2_DATA_KEY;
- rv = vb2_unpack_key2(&data_key, key_data, key_size);
+ rv = vb2_unpack_key(&data_key, key_data, key_size);
if (rv)
return rv;
@@ -185,13 +185,13 @@ int vb2_load_fw_preamble2(struct vb2_context *ctx)
/* Work buffer now contains the data subkey data and the preamble */
/* Verify the preamble */
- rv = vb2_verify_fw_preamble2(pre, pre->c.total_size, &data_key, &wb);
+ rv = vb2_verify_fw_preamble(pre, pre->c.total_size, &data_key, &wb);
if (rv)
return rv;
/* Move the preamble down now that the data key is no longer used */
memmove(key_data, pre, pre->c.total_size);
- pre = (struct vb2_fw_preamble2 *)key_data;
+ pre = (struct vb2_fw_preamble *)key_data;
/* Data key is now gone */
sd->workbuf_data_key_offset = sd->workbuf_data_key_size = 0;
@@ -205,13 +205,13 @@ int vb2_load_fw_preamble2(struct vb2_context *ctx)
* Firmware version is the lower 16 bits of the composite firmware
* version.
*/
- if (pre->firmware_version > 0xffff)
- return VB2_ERROR_FW_PREAMBLE2_VERSION_RANGE;
+ if (pre->fw_version > 0xffff)
+ return VB2_ERROR_FW_PREAMBLE_VERSION_RANGE;
/* Combine with the key version from vb2_load_fw_keyblock() */
- sd->fw_version |= pre->firmware_version;
+ sd->fw_version |= pre->fw_version;
if (sd->fw_version < sec_version)
- return VB2_ERROR_FW_PREAMBLE2_VERSION_ROLLBACK;
+ return VB2_ERROR_FW_PREAMBLE_VERSION_ROLLBACK;
/*
* If this is a newer version than in secure storage, and we
diff --git a/firmware/lib21/packed_key.c b/firmware/lib21/packed_key.c
index 3974b5f8..f7f2de9e 100644
--- a/firmware/lib21/packed_key.c
+++ b/firmware/lib21/packed_key.c
@@ -10,7 +10,7 @@
#include "2rsa.h"
#include "vb2_common.h"
-int vb2_unpack_key2_data(struct vb2_public_key *key,
+int vb2_unpack_key_data(struct vb2_public_key *key,
const uint8_t *key_data,
uint32_t key_size)
{
@@ -42,18 +42,18 @@ int vb2_unpack_key2_data(struct vb2_public_key *key,
return VB2_SUCCESS;
}
-int vb2_unpack_key2(struct vb2_public_key *key,
+int vb2_unpack_key(struct vb2_public_key *key,
const uint8_t *buf,
uint32_t size)
{
- const struct vb2_packed_key2 *pkey =
- (const struct vb2_packed_key2 *)buf;
+ const struct vb2_packed_key *pkey =
+ (const struct vb2_packed_key *)buf;
uint32_t sig_size;
uint32_t min_offset = 0;
int rv;
/* Check magic number */
- if (pkey->c.magic != VB2_MAGIC_PACKED_KEY2)
+ if (pkey->c.magic != VB2_MAGIC_PACKED_KEY)
return VB2_ERROR_UNPACK_KEY_MAGIC;
rv = vb2_verify_common_header(buf, size);
@@ -71,7 +71,7 @@ int vb2_unpack_key2(struct vb2_public_key *key,
* that's compatible across readers matching the major version, and we
* haven't added any new fields.
*/
- if (pkey->c.struct_version_major != VB2_PACKED_KEY2_VERSION_MAJOR)
+ if (pkey->c.struct_version_major != VB2_PACKED_KEY_VERSION_MAJOR)
return VB2_ERROR_UNPACK_KEY_STRUCT_VERSION;
/* Copy key algorithms */
@@ -84,7 +84,7 @@ int vb2_unpack_key2(struct vb2_public_key *key,
sig_size = vb2_rsa_sig_size(key->sig_alg);
if (!sig_size)
return VB2_ERROR_UNPACK_KEY_SIG_ALGORITHM;
- rv = vb2_unpack_key2_data(
+ rv = vb2_unpack_key_data(
key,
(const uint8_t *)pkey + pkey->key_offset,
pkey->key_size);