summaryrefslogtreecommitdiff
path: root/futility
diff options
context:
space:
mode:
Diffstat (limited to 'futility')
-rw-r--r--futility/cmd_gbb_utility.c28
-rw-r--r--futility/cmd_sign.c1
-rw-r--r--futility/file_type.c1
-rw-r--r--futility/file_type_bios.c3
-rw-r--r--futility/futility.h13
-rw-r--r--futility/misc.c32
-rw-r--r--futility/ryu_root_header.c7
-rw-r--r--futility/updater.c7
8 files changed, 41 insertions, 51 deletions
diff --git a/futility/cmd_gbb_utility.c b/futility/cmd_gbb_utility.c
index 02f4757f..84531c4a 100644
--- a/futility/cmd_gbb_utility.c
+++ b/futility/cmd_gbb_utility.c
@@ -16,7 +16,6 @@
#include <unistd.h>
#include "futility.h"
-#include "gbb_header.h"
static void print_help(int argc, char *argv[])
{
@@ -99,18 +98,19 @@ static void opt_has_arg(const char *name, int val)
static int errorcnt;
#define GBB_SEARCH_STRIDE 4
-static GoogleBinaryBlockHeader *FindGbbHeader(uint8_t *ptr, size_t size)
+static struct vb2_gbb_header *FindGbbHeader(uint8_t *ptr, size_t size)
{
size_t i;
- GoogleBinaryBlockHeader *tmp, *gbb_header = NULL;
+ struct vb2_gbb_header *tmp, *gbb_header = NULL;
int count = 0;
for (i = 0; i <= size - GBB_SEARCH_STRIDE; i += GBB_SEARCH_STRIDE) {
- if (0 != memcmp(ptr + i, GBB_SIGNATURE, GBB_SIGNATURE_SIZE))
+ if (0 != memcmp(ptr + i, VB2_GBB_SIGNATURE,
+ VB2_GBB_SIGNATURE_SIZE))
continue;
/* Found something. See if it's any good. */
- tmp = (GoogleBinaryBlockHeader *) (ptr + i);
+ tmp = (struct vb2_gbb_header *) (ptr + i);
if (futil_valid_gbb_header(tmp, size - i, NULL))
if (!count++)
gbb_header = tmp;
@@ -132,12 +132,12 @@ static GoogleBinaryBlockHeader *FindGbbHeader(uint8_t *ptr, size_t size)
static uint8_t *create_gbb(const char *desc, off_t *sizeptr)
{
char *str, *sizes, *param, *e = NULL;
- size_t size = GBB_HEADER_SIZE;
+ size_t size = EXPECTED_VB2_GBB_HEADER_SIZE;
int i = 0;
/* Danger Will Robinson! four entries ==> four paramater blocks */
uint32_t val[] = { 0, 0, 0, 0 };
uint8_t *buf;
- GoogleBinaryBlockHeader *gbb;
+ struct vb2_gbb_header *gbb;
sizes = strdup(desc);
if (!sizes) {
@@ -173,14 +173,14 @@ static uint8_t *create_gbb(const char *desc, off_t *sizeptr)
*sizeptr = size;
}
- gbb = (GoogleBinaryBlockHeader *) buf;
- memcpy(gbb->signature, GBB_SIGNATURE, GBB_SIGNATURE_SIZE);
- gbb->major_version = GBB_MAJOR_VER;
- gbb->minor_version = GBB_MINOR_VER;
- gbb->header_size = GBB_HEADER_SIZE;
+ gbb = (struct vb2_gbb_header *) buf;
+ memcpy(gbb->signature, VB2_GBB_SIGNATURE, VB2_GBB_SIGNATURE_SIZE);
+ gbb->major_version = VB2_GBB_MAJOR_VER;
+ gbb->minor_version = VB2_GBB_MINOR_VER;
+ gbb->header_size = EXPECTED_VB2_GBB_HEADER_SIZE;
gbb->flags = 0;
- i = GBB_HEADER_SIZE;
+ i = EXPECTED_VB2_GBB_HEADER_SIZE;
gbb->hwid_offset = i;
gbb->hwid_size = val[0];
i += val[0];
@@ -371,7 +371,7 @@ static int do_gbb(int argc, char *argv[])
uint8_t *inbuf = NULL;
off_t filesize;
uint8_t *outbuf = NULL;
- GoogleBinaryBlockHeader *gbb;
+ struct vb2_gbb_header *gbb;
uint8_t *gbb_base;
int i;
diff --git a/futility/cmd_sign.c b/futility/cmd_sign.c
index 8b6b2520..c458eef6 100644
--- a/futility/cmd_sign.c
+++ b/futility/cmd_sign.c
@@ -22,7 +22,6 @@
#include "fmap.h"
#include "futility.h"
#include "futility_options.h"
-#include "gbb_header.h"
#include "host_common.h"
#include "host_key2.h"
#include "kernel_blob.h"
diff --git a/futility/file_type.c b/futility/file_type.c
index 0b45be18..2e24b75f 100644
--- a/futility/file_type.c
+++ b/futility/file_type.c
@@ -16,7 +16,6 @@
#include "file_type.h"
#include "futility.h"
-#include "gbb_header.h"
/* Description and functions to handle each file type */
struct futil_file_type_s {
diff --git a/futility/file_type_bios.c b/futility/file_type_bios.c
index d79e76f8..a04c044b 100644
--- a/futility/file_type_bios.c
+++ b/futility/file_type_bios.c
@@ -14,7 +14,6 @@
#include "file_type_bios.h"
#include "futility.h"
#include "futility_options.h"
-#include "gbb_header.h"
#include "host_common.h"
#include "vb1_helper.h"
#include "vb2_common.h"
@@ -52,7 +51,7 @@ static void fmap_limit_area(FmapAreaHeader *ah, uint32_t len)
int ft_show_gbb(const char *name, uint8_t *buf, uint32_t len, void *data)
{
- GoogleBinaryBlockHeader *gbb = (GoogleBinaryBlockHeader *)buf;
+ struct vb2_gbb_header *gbb = (struct vb2_gbb_header *)buf;
struct bios_state_s *state = (struct bios_state_s *)data;
int retval = 0;
uint32_t maxlen = 0;
diff --git a/futility/futility.h b/futility/futility.h
index 9a1ac6dc..1de17f7f 100644
--- a/futility/futility.h
+++ b/futility/futility.h
@@ -9,7 +9,6 @@
#include "2common.h"
#include "vboot_common.h"
-#include "gbb_header.h"
#include "host_key.h"
/* This program */
@@ -105,24 +104,24 @@ extern const struct futil_cmd_t *const futil_cmds[];
extern int debugging_enabled;
/* Returns true if this looks enough like a GBB header to proceed. */
-int futil_looks_like_gbb(GoogleBinaryBlockHeader *gbb, uint32_t len);
+int futil_looks_like_gbb(struct vb2_gbb_header *gbb, uint32_t len);
/*
* Returns true if the gbb header is valid (and optionally updates *maxlen).
* This doesn't verify the contents, though.
*/
-int futil_valid_gbb_header(GoogleBinaryBlockHeader *gbb, uint32_t len,
+int futil_valid_gbb_header(struct vb2_gbb_header *gbb, uint32_t len,
uint32_t *maxlen);
/* Sets the HWID string field inside a GBB header. */
int futil_set_gbb_hwid(struct vb2_gbb_header *gbb, const char *hwid);
/* For GBB v1.2 and later, update the hwid_digest */
-void update_hwid_digest(GoogleBinaryBlockHeader *gbb);
+void update_hwid_digest(struct vb2_gbb_header *gbb);
/* For GBB v1.2 and later, print the stored digest of the HWID (and whether
* it's correct). Return true if it is correct. */
-int print_hwid_digest(GoogleBinaryBlockHeader *gbb,
+int print_hwid_digest(struct vb2_gbb_header *gbb,
const char *banner, const char *footer);
/* Copies a file or dies with an error message */
@@ -130,11 +129,11 @@ void futil_copy_file_or_die(const char *infile, const char *outfile);
/* Update ryu root key header in the image */
int fill_ryu_root_header(uint8_t *ptr, size_t size,
- const GoogleBinaryBlockHeader *gbb);
+ const struct vb2_gbb_header *gbb);
/* Verify ryu root key header */
int verify_ryu_root_header(uint8_t *ptr, size_t size,
- const GoogleBinaryBlockHeader *gbb);
+ const struct vb2_gbb_header *gbb);
/* Possible file operation errors */
enum futil_file_err {
diff --git a/futility/misc.c b/futility/misc.c
index 333360a8..82385c1a 100644
--- a/futility/misc.c
+++ b/futility/misc.c
@@ -28,7 +28,6 @@
#include "cgptlib_internal.h"
#include "file_type.h"
#include "futility.h"
-#include "gbb_header.h"
/* Default is to support everything we can */
enum vboot_version vboot_version = VBOOT_VERSION_ALL;
@@ -63,28 +62,28 @@ static inline uint32_t max(uint32_t a, uint32_t b)
enum futil_file_type ft_recognize_gbb(uint8_t *buf, uint32_t len)
{
- GoogleBinaryBlockHeader *gbb = (GoogleBinaryBlockHeader *)buf;
+ struct vb2_gbb_header *gbb = (struct vb2_gbb_header *)buf;
- if (memcmp(gbb->signature, GBB_SIGNATURE, GBB_SIGNATURE_SIZE))
+ if (memcmp(gbb->signature, VB2_GBB_SIGNATURE, VB2_GBB_SIGNATURE_SIZE))
return FILE_TYPE_UNKNOWN;
- if (gbb->major_version > GBB_MAJOR_VER)
+ if (gbb->major_version > VB2_GBB_MAJOR_VER)
return FILE_TYPE_UNKNOWN;
- if (sizeof(GoogleBinaryBlockHeader) > len)
+ if (sizeof(struct vb2_gbb_header) > len)
return FILE_TYPE_UNKNOWN;
/* close enough */
return FILE_TYPE_GBB;
}
-int futil_valid_gbb_header(GoogleBinaryBlockHeader *gbb, uint32_t len,
+int futil_valid_gbb_header(struct vb2_gbb_header *gbb, uint32_t len,
uint32_t *maxlen_ptr)
{
- if (len < sizeof(GoogleBinaryBlockHeader))
+ if (len < sizeof(struct vb2_gbb_header))
return 0;
- if (memcmp(gbb->signature, GBB_SIGNATURE, GBB_SIGNATURE_SIZE))
+ if (memcmp(gbb->signature, VB2_GBB_SIGNATURE, VB2_GBB_SIGNATURE_SIZE))
return 0;
- if (gbb->major_version != GBB_MAJOR_VER)
+ if (gbb->major_version != VB2_GBB_MAJOR_VER)
return 0;
/* Check limits first, to help identify problems */
@@ -101,9 +100,10 @@ int futil_valid_gbb_header(GoogleBinaryBlockHeader *gbb, uint32_t len,
*maxlen_ptr = maxlen;
}
- if (gbb->header_size != GBB_HEADER_SIZE || gbb->header_size > len)
+ if (gbb->header_size != EXPECTED_VB2_GBB_HEADER_SIZE ||
+ gbb->header_size > len)
return 0;
- if (gbb->hwid_offset < GBB_HEADER_SIZE)
+ if (gbb->hwid_offset < EXPECTED_VB2_GBB_HEADER_SIZE)
return 0;
if (gbb->hwid_offset + gbb->hwid_size > len)
return 0;
@@ -113,16 +113,16 @@ int futil_valid_gbb_header(GoogleBinaryBlockHeader *gbb, uint32_t len,
if (!is_null_terminated(s, gbb->hwid_size))
return 0;
}
- if (gbb->rootkey_offset < GBB_HEADER_SIZE)
+ if (gbb->rootkey_offset < EXPECTED_VB2_GBB_HEADER_SIZE)
return 0;
if (gbb->rootkey_offset + gbb->rootkey_size > len)
return 0;
- if (gbb->bmpfv_offset < GBB_HEADER_SIZE)
+ if (gbb->bmpfv_offset < EXPECTED_VB2_GBB_HEADER_SIZE)
return 0;
if (gbb->bmpfv_offset + gbb->bmpfv_size > len)
return 0;
- if (gbb->recovery_key_offset < GBB_HEADER_SIZE)
+ if (gbb->recovery_key_offset < EXPECTED_VB2_GBB_HEADER_SIZE)
return 0;
if (gbb->recovery_key_offset + gbb->recovery_key_size > len)
return 0;
@@ -133,7 +133,7 @@ int futil_valid_gbb_header(GoogleBinaryBlockHeader *gbb, uint32_t len,
/* For GBB v1.2 and later, print the stored digest of the HWID (and whether
* it's correct). Return true if it is correct. */
-int print_hwid_digest(GoogleBinaryBlockHeader *gbb,
+int print_hwid_digest(struct vb2_gbb_header *gbb,
const char *banner, const char *footer)
{
printf("%s", banner);
@@ -169,7 +169,7 @@ int print_hwid_digest(GoogleBinaryBlockHeader *gbb,
/* Deprecated. Use futil_set_gbb_hwid in future. */
/* For GBB v1.2 and later, update the hwid_digest field. */
-void update_hwid_digest(GoogleBinaryBlockHeader *gbb)
+void update_hwid_digest(struct vb2_gbb_header *gbb)
{
/* There isn't one for v1.1 and earlier */
if (gbb->minor_version < 2)
diff --git a/futility/ryu_root_header.c b/futility/ryu_root_header.c
index 1865b75c..48aef431 100644
--- a/futility/ryu_root_header.c
+++ b/futility/ryu_root_header.c
@@ -19,7 +19,6 @@
#include "2common.h"
#include "2sha.h"
#include "futility.h"
-#include "gbb_header.h"
#define SEARCH_STRIDE 4
@@ -97,7 +96,7 @@ static struct vb2_ryu_root_key_hash *find_ryu_root_header(uint8_t *ptr,
}
static void calculate_root_key_hash(uint8_t *digest, size_t digest_size,
- const GoogleBinaryBlockHeader *gbb)
+ const struct vb2_gbb_header *gbb)
{
const uint8_t *gbb_base = (const uint8_t *)gbb;
@@ -109,7 +108,7 @@ static void calculate_root_key_hash(uint8_t *digest, size_t digest_size,
}
int fill_ryu_root_header(uint8_t *ptr, size_t size,
- const GoogleBinaryBlockHeader *gbb)
+ const struct vb2_gbb_header *gbb)
{
struct vb2_ryu_root_key_hash *hash;
@@ -131,7 +130,7 @@ int fill_ryu_root_header(uint8_t *ptr, size_t size,
}
int verify_ryu_root_header(uint8_t *ptr, size_t size,
- const GoogleBinaryBlockHeader *gbb)
+ const struct vb2_gbb_header *gbb)
{
uint8_t digest[VB2_SHA256_DIGEST_SIZE] = {0};
diff --git a/futility/updater.c b/futility/updater.c
index 8dad7d41..859dedee 100644
--- a/futility/updater.c
+++ b/futility/updater.c
@@ -955,12 +955,7 @@ const struct vb2_gbb_header *find_gbb(const struct firmware_image *image)
find_firmware_section(&section, image, FMAP_RO_GBB);
gbb_header = (struct vb2_gbb_header *)section.data;
- /*
- * futil_valid_gbb_header needs v1 header (GoogleBinaryBlockHeader)
- * but that should be compatible with vb2_gbb_header
- */
- if (!futil_valid_gbb_header((GoogleBinaryBlockHeader *)gbb_header,
- section.size, NULL)) {
+ if (!futil_valid_gbb_header(gbb_header, section.size, NULL)) {
ERROR("Cannot find GBB in image: %s.\n", image->file_name);
return NULL;
}