summaryrefslogtreecommitdiff
path: root/firmware/lib
diff options
context:
space:
mode:
authorJoel Kitching <kitching@google.com>2019-06-25 16:51:16 +0800
committerCommit Bot <commit-bot@chromium.org>2019-07-10 01:57:10 +0000
commite501b731d8d218943011bd18527be148ff15bdd4 (patch)
treec1b20de98998058c7268bca6fa3649eb8cff089c /firmware/lib
parent9cff6fe1b866abf9c1ad63dd5a9aae415c813296 (diff)
downloadvboot-e501b731d8d218943011bd18527be148ff15bdd4.tar.gz
vboot: remove VbPublicKey struct
Update all references to vboot2-style struct vb2_packed_key. BUG=b:124141368 TEST=make clean && make runtests BRANCH=none Change-Id: I55a5f6bf315bdb4b83a998759d3732077283998e Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1675871 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
Diffstat (limited to 'firmware/lib')
-rw-r--r--firmware/lib/include/vboot_common.h15
-rw-r--r--firmware/lib/vboot_common.c18
-rw-r--r--firmware/lib/vboot_display.c6
3 files changed, 22 insertions, 17 deletions
diff --git a/firmware/lib/include/vboot_common.h b/firmware/lib/include/vboot_common.h
index 9bf9f0e5..95916488 100644
--- a/firmware/lib/include/vboot_common.h
+++ b/firmware/lib/include/vboot_common.h
@@ -9,6 +9,7 @@
#define VBOOT_REFERENCE_VBOOT_COMMON_H_
#include "2api.h"
+#include "2struct.h"
#include "vboot_struct.h"
/* Test an important condition at compile time, not run time */
@@ -47,8 +48,8 @@ extern const char *kVbootErrors[VBOOT_ERROR_MAX];
* Helper functions to get data pointed to by a public key or signature.
*/
-uint8_t *GetPublicKeyData(VbPublicKey *key);
-const uint8_t *GetPublicKeyDataC(const VbPublicKey *key);
+uint8_t *GetPublicKeyData(struct vb2_packed_key *key);
+const uint8_t *GetPublicKeyDataC(const struct vb2_packed_key *key);
uint8_t *GetSignatureData(VbSignature *sig);
const uint8_t *GetSignatureDataC(const VbSignature *sig);
@@ -58,7 +59,7 @@ const uint8_t *GetSignatureDataC(const VbSignature *sig);
*/
int VerifyPublicKeyInside(const void *parent, uint64_t parent_size,
- const VbPublicKey *key);
+ const struct vb2_packed_key *key);
int VerifySignatureInside(const void *parent, uint64_t parent_size,
const VbSignature *sig);
@@ -66,14 +67,16 @@ int VerifySignatureInside(const void *parent, uint64_t parent_size,
/**
* Initialize a public key to refer to [key_data].
*/
-void PublicKeyInit(VbPublicKey *key, uint8_t *key_data, uint64_t key_size);
+void PublicKeyInit(struct vb2_packed_key *key,
+ uint8_t *key_data, uint64_t key_size);
/**
* Copy a public key from [src] to [dest].
*
* Returns 0 if success, non-zero if error.
*/
-int PublicKeyCopy(VbPublicKey *dest, const VbPublicKey *src);
+int PublicKeyCopy(struct vb2_packed_key *dest,
+ const struct vb2_packed_key *src);
/**
* Retrieve the 16-bit vmlinuz header address and size from the kernel preamble
@@ -122,7 +125,7 @@ uint64_t VbSharedDataReserve(VbSharedDataHeader *header, uint64_t size);
* Returns 0 if success, non-zero if error.
*/
int VbSharedDataSetKernelKey(VbSharedDataHeader *header,
- const VbPublicKey *src);
+ const struct vb2_packed_key *src);
/**
* Check whether recovery is allowed or not.
diff --git a/firmware/lib/vboot_common.c b/firmware/lib/vboot_common.c
index 3238fd5c..e9516476 100644
--- a/firmware/lib/vboot_common.c
+++ b/firmware/lib/vboot_common.c
@@ -30,12 +30,12 @@ const char *kVbootErrors[VBOOT_ERROR_MAX] = {
/* Helper functions to get data pointed to by a public key or signature. */
-uint8_t *GetPublicKeyData(VbPublicKey *key)
+uint8_t *GetPublicKeyData(struct vb2_packed_key *key)
{
return (uint8_t *)key + key->key_offset;
}
-const uint8_t *GetPublicKeyDataC(const VbPublicKey *key)
+const uint8_t *GetPublicKeyDataC(const struct vb2_packed_key *key)
{
return (const uint8_t *)key + key->key_offset;
}
@@ -56,10 +56,10 @@ const uint8_t *GetSignatureDataC(const VbSignature *sig)
*/
int VerifyPublicKeyInside(const void *parent, uint64_t parent_size,
- const VbPublicKey *key)
+ const struct vb2_packed_key *key)
{
return vb2_verify_member_inside(parent, parent_size,
- key, sizeof(VbPublicKey),
+ key, sizeof(struct vb2_packed_key),
key->key_offset, key->key_size);
}
@@ -71,7 +71,8 @@ int VerifySignatureInside(const void *parent, uint64_t parent_size,
sig->sig_offset, sig->sig_size);
}
-void PublicKeyInit(VbPublicKey *key, uint8_t *key_data, uint64_t key_size)
+void PublicKeyInit(struct vb2_packed_key *key,
+ uint8_t *key_data, uint64_t key_size)
{
key->key_offset = vb2_offset_of(key, key_data);
key->key_size = key_size;
@@ -79,7 +80,7 @@ void PublicKeyInit(VbPublicKey *key, uint8_t *key_data, uint64_t key_size)
key->key_version = 0;
}
-int PublicKeyCopy(VbPublicKey *dest, const VbPublicKey *src)
+int PublicKeyCopy(struct vb2_packed_key *dest, const struct vb2_packed_key *src)
{
if (dest->key_size < src->key_size)
return 1;
@@ -146,9 +147,10 @@ uint64_t VbSharedDataReserve(VbSharedDataHeader *header, uint64_t size)
return offs;
}
-int VbSharedDataSetKernelKey(VbSharedDataHeader *header, const VbPublicKey *src)
+int VbSharedDataSetKernelKey(VbSharedDataHeader *header,
+ const struct vb2_packed_key *src)
{
- VbPublicKey *kdest;
+ struct vb2_packed_key *kdest;
if (!header)
return VBOOT_SHARED_DATA_INVALID;
diff --git a/firmware/lib/vboot_display.c b/firmware/lib/vboot_display.c
index 6ef692f7..7835dbbd 100644
--- a/firmware/lib/vboot_display.c
+++ b/firmware/lib/vboot_display.c
@@ -94,7 +94,7 @@ static void Uint8ToString(char *buf, uint8_t val)
*buf = trans[val & 0xF];
}
-static void FillInSha1Sum(char *outbuf, VbPublicKey *key)
+static void FillInSha1Sum(char *outbuf, struct vb2_packed_key *key)
{
uint8_t *buf = ((uint8_t *)key) + key->key_offset;
uint64_t buflen = key->key_size;
@@ -371,7 +371,7 @@ VbError_t VbDisplayDebugInfo(struct vb2_context *ctx)
struct vb2_workbuf wblocal = wb;
ret = vb2_gbb_read_root_key(ctx, &key, NULL, &wblocal);
if (!ret) {
- FillInSha1Sum(sha1sum, (VbPublicKey *)key);
+ FillInSha1Sum(sha1sum, key);
used += StrnAppend(buf + used, "\ngbb.rootkey: ",
DEBUG_INFO_SIZE - used);
used += StrnAppend(buf + used, sha1sum,
@@ -384,7 +384,7 @@ VbError_t VbDisplayDebugInfo(struct vb2_context *ctx)
struct vb2_workbuf wblocal = wb;
ret = vb2_gbb_read_recovery_key(ctx, &key, NULL, &wblocal);
if (!ret) {
- FillInSha1Sum(sha1sum, (VbPublicKey *)key);
+ FillInSha1Sum(sha1sum, key);
used += StrnAppend(buf + used, "\ngbb.recovery_key: ",
DEBUG_INFO_SIZE - used);
used += StrnAppend(buf + used, sha1sum,