summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/2lib/2api.c12
-rw-r--r--firmware/2lib/2common.c16
-rw-r--r--firmware/2lib/2gbb.c40
-rw-r--r--firmware/2lib/2misc.c23
-rw-r--r--firmware/2lib/2nvstorage.c2
-rw-r--r--firmware/2lib/2rsa.c12
-rw-r--r--firmware/2lib/2secdata.c18
-rw-r--r--firmware/2lib/2secdatak.c18
-rw-r--r--firmware/2lib/2sha_utility.c28
-rw-r--r--firmware/2lib/2stub.c23
-rw-r--r--firmware/2lib/include/2api.h85
-rw-r--r--firmware/2lib/include/2common.h19
-rw-r--r--firmware/2lib/include/2gbb.h14
-rw-r--r--firmware/2lib/include/2misc.h27
-rw-r--r--firmware/2lib/include/2nvstorage.h2
-rw-r--r--firmware/2lib/include/2rsa.h8
-rw-r--r--firmware/2lib/include/2secdata.h24
-rw-r--r--firmware/2lib/include/2sha.h27
-rw-r--r--firmware/include/vboot_api.h2
-rw-r--r--firmware/include/vboot_test.h3
-rw-r--r--firmware/lib/ec_sync.c16
-rw-r--r--firmware/lib/include/rollback_index.h3
-rw-r--r--firmware/lib/include/vboot_common.h28
-rw-r--r--firmware/lib/include/vboot_kernel.h2
-rw-r--r--firmware/lib/mocked_rollback_index.c2
-rw-r--r--firmware/lib/rollback_index.c2
-rw-r--r--firmware/lib/vboot_api_kernel.c4
-rw-r--r--firmware/lib/vboot_common.c24
-rw-r--r--firmware/lib/vboot_common_init.c2
-rw-r--r--firmware/lib/vboot_display.c2
-rw-r--r--firmware/lib/vboot_kernel.c28
-rw-r--r--firmware/lib/vboot_ui.c6
-rw-r--r--firmware/lib20/api.c16
-rw-r--r--firmware/lib20/api_kernel.c24
-rw-r--r--firmware/lib20/common.c35
-rw-r--r--firmware/lib20/include/vb2_common.h65
-rw-r--r--firmware/lib20/kernel.c24
-rw-r--r--firmware/lib20/misc.c8
-rw-r--r--firmware/lib20/packed_key.c11
-rw-r--r--firmware/lib21/api.c10
-rw-r--r--firmware/lib21/common.c60
-rw-r--r--firmware/lib21/include/vb21_common.h61
-rw-r--r--firmware/lib21/misc.c20
-rw-r--r--firmware/lib21/packed_key.c12
-rw-r--r--firmware/stub/vboot_api_stub.c2
45 files changed, 410 insertions, 460 deletions
diff --git a/firmware/2lib/2api.c b/firmware/2lib/2api.c
index f2e7d6bb..f39ba290 100644
--- a/firmware/2lib/2api.c
+++ b/firmware/2lib/2api.c
@@ -24,9 +24,9 @@ void vb2api_fail(struct vb2_context *ctx, uint8_t reason, uint8_t subcode)
vb2_fail(ctx, reason, subcode);
}
-int vb2api_fw_phase1(struct vb2_context *ctx)
+vb2_error_t vb2api_fw_phase1(struct vb2_context *ctx)
{
- int rv;
+ vb2_error_t rv;
struct vb2_shared_data *sd;
/* Initialize the vboot context if it hasn't been yet */
@@ -116,9 +116,9 @@ int vb2api_fw_phase1(struct vb2_context *ctx)
return VB2_SUCCESS;
}
-int vb2api_fw_phase2(struct vb2_context *ctx)
+vb2_error_t vb2api_fw_phase2(struct vb2_context *ctx)
{
- int rv;
+ vb2_error_t rv;
/*
* Use the slot from the last boot if this is a resume. Do not set
@@ -159,7 +159,7 @@ int vb2api_fw_phase2(struct vb2_context *ctx)
return VB2_SUCCESS;
}
-int vb2api_extend_hash(struct vb2_context *ctx,
+vb2_error_t vb2api_extend_hash(struct vb2_context *ctx,
const void *buf,
uint32_t size)
{
@@ -183,7 +183,7 @@ int vb2api_extend_hash(struct vb2_context *ctx,
return vb2_digest_extend(dc, buf, size);
}
-int vb2api_get_pcr_digest(struct vb2_context *ctx,
+vb2_error_t vb2api_get_pcr_digest(struct vb2_context *ctx,
enum vb2_pcr_digest which_digest,
uint8_t *dest,
uint32_t *dest_size)
diff --git a/firmware/2lib/2common.c b/firmware/2lib/2common.c
index 472d5acc..de1fc498 100644
--- a/firmware/2lib/2common.c
+++ b/firmware/2lib/2common.c
@@ -11,7 +11,7 @@
#include "2rsa.h"
#include "2sha.h"
-int vb2_safe_memcmp(const void *s1, const void *s2, size_t size)
+vb2_error_t vb2_safe_memcmp(const void *s1, const void *s2, size_t size)
{
const unsigned char *us1 = s1;
const unsigned char *us2 = s2;
@@ -30,7 +30,8 @@ int vb2_safe_memcmp(const void *s1, const void *s2, size_t size)
return result != 0;
}
-int vb2_align(uint8_t **ptr, uint32_t *size, uint32_t align, uint32_t want_size)
+vb2_error_t vb2_align(uint8_t **ptr, uint32_t *size, uint32_t align,
+ uint32_t want_size)
{
uintptr_t p = (uintptr_t)*ptr;
uintptr_t offs = p & (align - 1);
@@ -77,8 +78,7 @@ void *vb2_workbuf_alloc(struct vb2_workbuf *wb, uint32_t size)
return ptr;
}
-void *vb2_workbuf_realloc(struct vb2_workbuf *wb,
- uint32_t oldsize,
+void *vb2_workbuf_realloc(struct vb2_workbuf *wb, uint32_t oldsize,
uint32_t newsize)
{
/*
@@ -104,10 +104,10 @@ ptrdiff_t vb2_offset_of(const void *base, const void *ptr)
return (uintptr_t)ptr - (uintptr_t)base;
}
-int vb2_verify_member_inside(const void *parent, size_t parent_size,
- const void *member, size_t member_size,
- ptrdiff_t member_data_offset,
- size_t member_data_size)
+vb2_error_t vb2_verify_member_inside(const void *parent, size_t parent_size,
+ const void *member, size_t member_size,
+ ptrdiff_t member_data_offset,
+ size_t member_data_size)
{
const uintptr_t parent_end = (uintptr_t)parent + parent_size;
const ptrdiff_t member_offs = vb2_offset_of(parent, member);
diff --git a/firmware/2lib/2gbb.c b/firmware/2lib/2gbb.c
index c7f22564..a752c8ba 100644
--- a/firmware/2lib/2gbb.c
+++ b/firmware/2lib/2gbb.c
@@ -8,14 +8,13 @@
#include "2common.h"
#include "2misc.h"
-static int vb2_gbb_read_key(struct vb2_context *ctx,
- uint32_t offset,
- uint32_t *size,
- struct vb2_packed_key **keyp,
- struct vb2_workbuf *wb)
+static vb2_error_t vb2_gbb_read_key(struct vb2_context *ctx, uint32_t offset,
+ uint32_t *size,
+ struct vb2_packed_key **keyp,
+ struct vb2_workbuf *wb)
{
struct vb2_workbuf wblocal = *wb;
- int rv;
+ vb2_error_t rv;
/* Check offset and size. */
if (offset < sizeof(struct vb2_gbb_header))
@@ -56,41 +55,38 @@ static int vb2_gbb_read_key(struct vb2_context *ctx,
return rv;
}
-int vb2_gbb_read_root_key(struct vb2_context *ctx,
- struct vb2_packed_key **keyp,
- uint32_t *size,
- struct vb2_workbuf *wb)
+vb2_error_t vb2_gbb_read_root_key(struct vb2_context *ctx,
+ struct vb2_packed_key **keyp, uint32_t *size,
+ struct vb2_workbuf *wb)
{
struct vb2_gbb_header *gbb = vb2_get_gbb(ctx);
uint32_t size_in = gbb->rootkey_size;
- int ret = vb2_gbb_read_key(ctx, gbb->rootkey_offset,
- &size_in, keyp, wb);
+ vb2_error_t ret = vb2_gbb_read_key(ctx, gbb->rootkey_offset,
+ &size_in, keyp, wb);
if (size)
*size = size_in;
return ret;
}
-int vb2_gbb_read_recovery_key(struct vb2_context *ctx,
- struct vb2_packed_key **keyp,
- uint32_t *size,
- struct vb2_workbuf *wb)
+vb2_error_t vb2_gbb_read_recovery_key(struct vb2_context *ctx,
+ struct vb2_packed_key **keyp,
+ uint32_t *size, struct vb2_workbuf *wb)
{
struct vb2_gbb_header *gbb = vb2_get_gbb(ctx);
uint32_t size_in = gbb->recovery_key_size;
- int ret = vb2_gbb_read_key(ctx, gbb->recovery_key_offset,
- &size_in, keyp, wb);
+ vb2_error_t ret = vb2_gbb_read_key(ctx, gbb->recovery_key_offset,
+ &size_in, keyp, wb);
if (size)
*size = size_in;
return ret;
}
-int vb2api_gbb_read_hwid(struct vb2_context *ctx,
- char *hwid,
- uint32_t *size)
+vb2_error_t vb2api_gbb_read_hwid(struct vb2_context *ctx, char *hwid,
+ uint32_t *size)
{
struct vb2_gbb_header *gbb = vb2_get_gbb(ctx);
uint32_t i;
- int ret;
+ vb2_error_t ret;
if (gbb->hwid_size == 0) {
VB2_DEBUG("invalid HWID size %d\n", gbb->hwid_size);
diff --git a/firmware/2lib/2misc.c b/firmware/2lib/2misc.c
index 03e0353a..19380973 100644
--- a/firmware/2lib/2misc.c
+++ b/firmware/2lib/2misc.c
@@ -14,7 +14,7 @@
#include "2sha.h"
#include "2rsa.h"
-int vb2_validate_gbb_signature(uint8_t *sig)
+vb2_error_t vb2_validate_gbb_signature(uint8_t *sig)
{
const static uint8_t sig_xor[VB2_GBB_SIGNATURE_SIZE] =
VB2_GBB_XOR_SIGNATURE;
@@ -44,9 +44,10 @@ void vb2_set_workbuf_used(struct vb2_context *ctx, uint32_t used)
ctx->workbuf_used = vb2_wb_round_up(used);
}
-int vb2_read_gbb_header(struct vb2_context *ctx, struct vb2_gbb_header *gbb)
+vb2_error_t vb2_read_gbb_header(struct vb2_context *ctx,
+ struct vb2_gbb_header *gbb)
{
- int rv;
+ vb2_error_t rv;
/* Read the entire header */
rv = vb2ex_read_resource(ctx, VB2_RES_GBB, 0, gbb, sizeof(*gbb));
@@ -128,7 +129,7 @@ void vb2_fail(struct vb2_context *ctx, uint8_t reason, uint8_t subcode)
#pragma GCC diagnostic push
/* Don't warn for the version_minor check even if the checked version is 0. */
#pragma GCC diagnostic ignored "-Wtype-limits"
-int vb2_init_context(struct vb2_context *ctx)
+vb2_error_t vb2_init_context(struct vb2_context *ctx)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
@@ -208,12 +209,12 @@ void vb2_check_recovery(struct vb2_context *ctx)
}
}
-int vb2_fw_parse_gbb(struct vb2_context *ctx)
+vb2_error_t vb2_fw_parse_gbb(struct vb2_context *ctx)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
struct vb2_gbb_header *gbb;
struct vb2_workbuf wb;
- int rv;
+ vb2_error_t rv;
vb2_workbuf_from_ctx(ctx, &wb);
@@ -233,7 +234,7 @@ int vb2_fw_parse_gbb(struct vb2_context *ctx)
return VB2_SUCCESS;
}
-int vb2_check_dev_switch(struct vb2_context *ctx)
+vb2_error_t vb2_check_dev_switch(struct vb2_context *ctx)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
struct vb2_gbb_header *gbb = vb2_get_gbb(ctx);
@@ -241,7 +242,7 @@ int vb2_check_dev_switch(struct vb2_context *ctx)
uint32_t old_flags;
int is_dev = 0;
int use_secdata = 1;
- int rv;
+ vb2_error_t rv;
/* Read secure flags */
rv = vb2_secdata_get(ctx, VB2_SECDATA_FLAGS, &flags);
@@ -348,9 +349,9 @@ int vb2_check_dev_switch(struct vb2_context *ctx)
return VB2_SUCCESS;
}
-int vb2_check_tpm_clear(struct vb2_context *ctx)
+vb2_error_t vb2_check_tpm_clear(struct vb2_context *ctx)
{
- int rv;
+ vb2_error_t rv;
/* Check if we've been asked to clear the owner */
if (!vb2_nv_get(ctx, VB2_NV_CLEAR_TPM_OWNER_REQUEST))
@@ -376,7 +377,7 @@ int vb2_check_tpm_clear(struct vb2_context *ctx)
return VB2_SUCCESS;
}
-int vb2_select_fw_slot(struct vb2_context *ctx)
+vb2_error_t vb2_select_fw_slot(struct vb2_context *ctx)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
uint32_t tries;
diff --git a/firmware/2lib/2nvstorage.c b/firmware/2lib/2nvstorage.c
index 95d2f6e7..a418a559 100644
--- a/firmware/2lib/2nvstorage.c
+++ b/firmware/2lib/2nvstorage.c
@@ -38,7 +38,7 @@ int vb2_nv_get_size(const struct vb2_context *ctx)
* @param ctx Context pointer
* @return VB2_SUCCESS, or non-zero error code if error.
*/
-int vb2_nv_check_crc(const struct vb2_context *ctx)
+vb2_error_t vb2_nv_check_crc(const struct vb2_context *ctx)
{
const uint8_t *p = ctx->nvdata;
const int offs = ctx->flags & VB2_CONTEXT_NVDATA_V2 ?
diff --git a/firmware/2lib/2rsa.c b/firmware/2lib/2rsa.c
index 5fda9599..199c1c2e 100644
--- a/firmware/2lib/2rsa.c
+++ b/firmware/2lib/2rsa.c
@@ -320,7 +320,8 @@ static const uint8_t sha512_tail[] = {
* @param key Key to take signature and hash algorithms from
* @return VB2_SUCCESS, or non-zero if error.
*/
-int vb2_check_padding(const uint8_t *sig, const struct vb2_public_key *key)
+vb2_error_t vb2_check_padding(const uint8_t *sig,
+ const struct vb2_public_key *key)
{
/* Determine padding to use depending on the signature type */
uint32_t sig_size = vb2_rsa_sig_size(key->sig_alg);
@@ -368,10 +369,9 @@ int vb2_check_padding(const uint8_t *sig, const struct vb2_public_key *key)
return result ? VB2_ERROR_RSA_PADDING : VB2_SUCCESS;
}
-int vb2_rsa_verify_digest(const struct vb2_public_key *key,
- uint8_t *sig,
- const uint8_t *digest,
- const struct vb2_workbuf *wb)
+vb2_error_t vb2_rsa_verify_digest(const struct vb2_public_key *key,
+ uint8_t *sig, const uint8_t *digest,
+ const struct vb2_workbuf *wb)
{
struct vb2_workbuf wblocal = *wb;
uint32_t *workbuf32;
@@ -379,7 +379,7 @@ int vb2_rsa_verify_digest(const struct vb2_public_key *key,
int sig_size;
int pad_size;
int exp;
- int rv;
+ vb2_error_t rv;
if (!key || !sig || !digest)
return VB2_ERROR_RSA_VERIFY_PARAM;
diff --git a/firmware/2lib/2secdata.c b/firmware/2lib/2secdata.c
index e4b42e44..aaca7683 100644
--- a/firmware/2lib/2secdata.c
+++ b/firmware/2lib/2secdata.c
@@ -11,7 +11,7 @@
#include "2misc.h"
#include "2secdata.h"
-int vb2api_secdata_check(const struct vb2_context *ctx)
+vb2_error_t vb2api_secdata_check(const struct vb2_context *ctx)
{
const struct vb2_secdata *sec =
(const struct vb2_secdata *)ctx->secdata;
@@ -27,7 +27,7 @@ int vb2api_secdata_check(const struct vb2_context *ctx)
return VB2_SUCCESS;
}
-int vb2api_secdata_create(struct vb2_context *ctx)
+vb2_error_t vb2api_secdata_create(struct vb2_context *ctx)
{
struct vb2_secdata *sec = (struct vb2_secdata *)ctx->secdata;
@@ -43,10 +43,10 @@ int vb2api_secdata_create(struct vb2_context *ctx)
return VB2_SUCCESS;
}
-int vb2_secdata_init(struct vb2_context *ctx)
+vb2_error_t vb2_secdata_init(struct vb2_context *ctx)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
- int rv;
+ vb2_error_t rv;
rv = vb2api_secdata_check(ctx);
if (rv)
@@ -65,9 +65,8 @@ int vb2_secdata_init(struct vb2_context *ctx)
return VB2_SUCCESS;
}
-int vb2_secdata_get(struct vb2_context *ctx,
- enum vb2_secdata_param param,
- uint32_t *dest)
+vb2_error_t vb2_secdata_get(struct vb2_context *ctx,
+ enum vb2_secdata_param param, uint32_t *dest)
{
struct vb2_secdata *sec = (struct vb2_secdata *)ctx->secdata;
@@ -88,9 +87,8 @@ int vb2_secdata_get(struct vb2_context *ctx,
}
}
-int vb2_secdata_set(struct vb2_context *ctx,
- enum vb2_secdata_param param,
- uint32_t value)
+vb2_error_t vb2_secdata_set(struct vb2_context *ctx,
+ enum vb2_secdata_param param, uint32_t value)
{
struct vb2_secdata *sec = (struct vb2_secdata *)ctx->secdata;
uint32_t now;
diff --git a/firmware/2lib/2secdatak.c b/firmware/2lib/2secdatak.c
index 228312d8..d965eb44 100644
--- a/firmware/2lib/2secdatak.c
+++ b/firmware/2lib/2secdatak.c
@@ -11,7 +11,7 @@
#include "2misc.h"
#include "2secdata.h"
-int vb2api_secdatak_check(const struct vb2_context *ctx)
+vb2_error_t vb2api_secdatak_check(const struct vb2_context *ctx)
{
const struct vb2_secdatak *sec =
(const struct vb2_secdatak *)ctx->secdatak;
@@ -23,7 +23,7 @@ int vb2api_secdatak_check(const struct vb2_context *ctx)
return VB2_SUCCESS;
}
-int vb2api_secdatak_create(struct vb2_context *ctx)
+vb2_error_t vb2api_secdatak_create(struct vb2_context *ctx)
{
struct vb2_secdatak *sec = (struct vb2_secdatak *)ctx->secdatak;
@@ -42,11 +42,11 @@ int vb2api_secdatak_create(struct vb2_context *ctx)
return VB2_SUCCESS;
}
-int vb2_secdatak_init(struct vb2_context *ctx)
+vb2_error_t vb2_secdatak_init(struct vb2_context *ctx)
{
struct vb2_secdatak *sec = (struct vb2_secdatak *)ctx->secdatak;
struct vb2_shared_data *sd = vb2_get_sd(ctx);
- int rv;
+ vb2_error_t rv;
rv = vb2api_secdatak_check(ctx);
if (rv)
@@ -63,9 +63,8 @@ int vb2_secdatak_init(struct vb2_context *ctx)
return VB2_SUCCESS;
}
-int vb2_secdatak_get(struct vb2_context *ctx,
- enum vb2_secdatak_param param,
- uint32_t *dest)
+vb2_error_t vb2_secdatak_get(struct vb2_context *ctx,
+ enum vb2_secdatak_param param, uint32_t *dest)
{
struct vb2_secdatak *sec = (struct vb2_secdatak *)ctx->secdatak;
@@ -82,9 +81,8 @@ int vb2_secdatak_get(struct vb2_context *ctx,
}
}
-int vb2_secdatak_set(struct vb2_context *ctx,
- enum vb2_secdatak_param param,
- uint32_t value)
+vb2_error_t vb2_secdatak_set(struct vb2_context *ctx,
+ enum vb2_secdatak_param param, uint32_t value)
{
struct vb2_secdatak *sec = (struct vb2_secdatak *)ctx->secdatak;
uint32_t now;
diff --git a/firmware/2lib/2sha_utility.c b/firmware/2lib/2sha_utility.c
index c45606bb..cc36b99f 100644
--- a/firmware/2lib/2sha_utility.c
+++ b/firmware/2lib/2sha_utility.c
@@ -56,7 +56,7 @@ enum vb2_hash_algorithm vb2_crypto_to_hash(uint32_t algorithm)
return VB2_HASH_INVALID;
}
-int vb2_digest_size(enum vb2_hash_algorithm hash_alg)
+vb2_error_t vb2_digest_size(enum vb2_hash_algorithm hash_alg)
{
switch (hash_alg) {
#if VB2_SUPPORT_SHA1
@@ -76,7 +76,7 @@ int vb2_digest_size(enum vb2_hash_algorithm hash_alg)
}
}
-int vb2_hash_block_size(enum vb2_hash_algorithm alg)
+vb2_error_t vb2_hash_block_size(enum vb2_hash_algorithm alg)
{
switch (alg) {
#if VB2_SUPPORT_SHA1
@@ -116,8 +116,8 @@ const char *vb2_get_hash_algorithm_name(enum vb2_hash_algorithm alg)
}
}
-int vb2_digest_init(struct vb2_digest_context *dc,
- enum vb2_hash_algorithm hash_alg)
+vb2_error_t vb2_digest_init(struct vb2_digest_context *dc,
+ enum vb2_hash_algorithm hash_alg)
{
dc->hash_alg = hash_alg;
dc->using_hwcrypto = 0;
@@ -143,9 +143,8 @@ int vb2_digest_init(struct vb2_digest_context *dc,
}
}
-int vb2_digest_extend(struct vb2_digest_context *dc,
- const uint8_t *buf,
- uint32_t size)
+vb2_error_t vb2_digest_extend(struct vb2_digest_context *dc, const uint8_t *buf,
+ uint32_t size)
{
switch (dc->hash_alg) {
#if VB2_SUPPORT_SHA1
@@ -168,9 +167,8 @@ int vb2_digest_extend(struct vb2_digest_context *dc,
}
}
-int vb2_digest_finalize(struct vb2_digest_context *dc,
- uint8_t *digest,
- uint32_t digest_size)
+vb2_error_t vb2_digest_finalize(struct vb2_digest_context *dc, uint8_t *digest,
+ uint32_t digest_size)
{
if (digest_size < vb2_digest_size(dc->hash_alg))
return VB2_ERROR_SHA_FINALIZE_DIGEST_SIZE;
@@ -196,14 +194,12 @@ int vb2_digest_finalize(struct vb2_digest_context *dc,
}
}
-int vb2_digest_buffer(const uint8_t *buf,
- uint32_t size,
- enum vb2_hash_algorithm hash_alg,
- uint8_t *digest,
- uint32_t digest_size)
+vb2_error_t vb2_digest_buffer(const uint8_t *buf, uint32_t size,
+ enum vb2_hash_algorithm hash_alg, uint8_t *digest,
+ uint32_t digest_size)
{
struct vb2_digest_context dc;
- int rv;
+ vb2_error_t rv;
rv = vb2_digest_init(&dc, hash_alg);
if (rv)
diff --git a/firmware/2lib/2stub.c b/firmware/2lib/2stub.c
index 39503a58..0818ed8e 100644
--- a/firmware/2lib/2stub.c
+++ b/firmware/2lib/2stub.c
@@ -25,46 +25,43 @@ void vb2ex_printf(const char *func, const char *fmt, ...)
}
__attribute__((weak))
-int vb2ex_tpm_clear_owner(struct vb2_context *ctx)
+vb2_error_t vb2ex_tpm_clear_owner(struct vb2_context *ctx)
{
fprintf(stderr, "%s: function not implemented\n", __func__);
return VB2_ERROR_EX_UNIMPLEMENTED;
}
__attribute__((weak))
-int vb2ex_read_resource(struct vb2_context *ctx,
- enum vb2_resource_index index,
- uint32_t offset,
- void *buf,
- uint32_t size)
+vb2_error_t vb2ex_read_resource(struct vb2_context *ctx,
+ enum vb2_resource_index index, uint32_t offset,
+ void *buf, uint32_t size)
{
fprintf(stderr, "%s: function not implemented\n", __func__);
return VB2_ERROR_EX_UNIMPLEMENTED;
}
__attribute__((weak))
-int vb2ex_hwcrypto_digest_init(enum vb2_hash_algorithm hash_alg,
- uint32_t data_size)
+vb2_error_t vb2ex_hwcrypto_digest_init(enum vb2_hash_algorithm hash_alg,
+ uint32_t data_size)
{
return VB2_ERROR_EX_HWCRYPTO_UNSUPPORTED;
}
__attribute__((weak))
-int vb2ex_hwcrypto_digest_extend(const uint8_t *buf,
- uint32_t size)
+vb2_error_t vb2ex_hwcrypto_digest_extend(const uint8_t *buf, uint32_t size)
{
return VB2_ERROR_SHA_EXTEND_ALGORITHM; /* Should not be called. */
}
__attribute__((weak))
-int vb2ex_hwcrypto_digest_finalize(uint8_t *digest,
- uint32_t digest_size)
+vb2_error_t vb2ex_hwcrypto_digest_finalize(uint8_t *digest,
+ uint32_t digest_size)
{
return VB2_ERROR_SHA_FINALIZE_ALGORITHM; /* Should not be called. */
}
__attribute__((weak))
-int vb2ex_tpm_set_mode(enum vb2_tpm_mode mode_val)
+vb2_error_t vb2ex_tpm_set_mode(enum vb2_tpm_mode mode_val)
{
fprintf(stderr, "%s: function not implemented\n", __func__);
return VB2_ERROR_EX_UNIMPLEMENTED;
diff --git a/firmware/2lib/include/2api.h b/firmware/2lib/include/2api.h
index 487616d4..98f9ff08 100644
--- a/firmware/2lib/include/2api.h
+++ b/firmware/2lib/include/2api.h
@@ -404,7 +404,7 @@ enum vb2_pcr_digest {
* @param ctx Context pointer
* @return VB2_SUCCESS, or non-zero error code if error.
*/
-int vb2api_secdata_check(const struct vb2_context *ctx);
+vb2_error_t vb2api_secdata_check(const struct vb2_context *ctx);
/**
* Create fresh data in the secure storage context.
@@ -420,7 +420,7 @@ int vb2api_secdata_check(const struct vb2_context *ctx);
* @param ctx Context pointer
* @return VB2_SUCCESS, or non-zero error code if error.
*/
-int vb2api_secdata_create(struct vb2_context *ctx);
+vb2_error_t vb2api_secdata_create(struct vb2_context *ctx);
/**
* Check the CRC of the kernel version secure storage context.
@@ -434,7 +434,7 @@ int vb2api_secdata_create(struct vb2_context *ctx);
* @param ctx Context pointer
* @return VB2_SUCCESS, or non-zero error code if error.
*/
-int vb2api_secdatak_check(const struct vb2_context *ctx);
+vb2_error_t vb2api_secdatak_check(const struct vb2_context *ctx);
/**
* Create fresh data in the kernel version secure storage context.
@@ -450,7 +450,7 @@ int vb2api_secdatak_check(const struct vb2_context *ctx);
* @param ctx Context pointer
* @return VB2_SUCCESS, or non-zero error code if error.
*/
-int vb2api_secdatak_create(struct vb2_context *ctx);
+vb2_error_t vb2api_secdatak_create(struct vb2_context *ctx);
/**
* Report firmware failure to vboot.
@@ -478,7 +478,7 @@ void vb2api_fail(struct vb2_context *ctx, uint8_t reason, uint8_t subcode);
* @param ctx Vboot context
* @return VB2_SUCCESS, or error code on error.
*/
-int vb2api_fw_phase1(struct vb2_context *ctx);
+vb2_error_t vb2api_fw_phase1(struct vb2_context *ctx);
/**
* Firmware selection, phase 2.
@@ -489,7 +489,7 @@ int vb2api_fw_phase1(struct vb2_context *ctx);
* @param ctx Vboot context
* @return VB2_SUCCESS, or error code on error.
*/
-int vb2api_fw_phase2(struct vb2_context *ctx);
+vb2_error_t vb2api_fw_phase2(struct vb2_context *ctx);
/**
* Firmware selection, phase 3.
@@ -503,12 +503,12 @@ int vb2api_fw_phase2(struct vb2_context *ctx);
* @param ctx Vboot context
* @return VB2_SUCCESS, or error code on error.
*/
-int vb2api_fw_phase3(struct vb2_context *ctx);
+vb2_error_t vb2api_fw_phase3(struct vb2_context *ctx);
/**
* Same, but for new-style structs.
*/
-int vb21api_fw_phase3(struct vb2_context *ctx);
+vb2_error_t vb21api_fw_phase3(struct vb2_context *ctx);
/**
* Initialize hashing data for the specified tag.
@@ -519,14 +519,14 @@ int vb21api_fw_phase3(struct vb2_context *ctx);
* stored here on output.
* @return VB2_SUCCESS, or error code on error.
*/
-int vb2api_init_hash(struct vb2_context *ctx, uint32_t tag, uint32_t *size);
+vb2_error_t vb2api_init_hash(struct vb2_context *ctx, uint32_t tag,
+ uint32_t *size);
/**
* Same, but for new-style structs.
*/
-int vb21api_init_hash(struct vb2_context *ctx,
- const struct vb2_id *id,
- uint32_t *size);
+vb2_error_t vb21api_init_hash(struct vb2_context *ctx, const struct vb2_id *id,
+ uint32_t *size);
/**
* Extend the hash started by vb2api_init_hash() with additional data.
@@ -538,9 +538,8 @@ int vb21api_init_hash(struct vb2_context *ctx,
* @param size Size of data in bytes
* @return VB2_SUCCESS, or error code on error.
*/
-int vb2api_extend_hash(struct vb2_context *ctx,
- const void *buf,
- uint32_t size);
+vb2_error_t vb2api_extend_hash(struct vb2_context *ctx, const void *buf,
+ uint32_t size);
/**
* Check the hash value started by vb2api_init_hash().
@@ -553,7 +552,7 @@ int vb2api_check_hash(struct vb2_context *ctx);
/**
* Same, but for new-style structs.
*/
-int vb21api_check_hash(struct vb2_context *ctx);
+vb2_error_t vb21api_check_hash(struct vb2_context *ctx);
/**
* Check the hash value started by vb2api_init_hash() while retrieving
@@ -564,8 +563,9 @@ int vb21api_check_hash(struct vb2_context *ctx);
* @param digest_out_size optional size of buffer to store digest
* @return VB2_SUCCESS, or error code on error.
*/
-int vb2api_check_hash_get_digest(struct vb2_context *ctx, void *digest_out,
- uint32_t digest_out_size);
+vb2_error_t vb2api_check_hash_get_digest(struct vb2_context *ctx,
+ void *digest_out,
+ uint32_t digest_out_size);
/**
* Get a PCR digest
@@ -578,10 +578,9 @@ int vb2api_check_hash_get_digest(struct vb2_context *ctx, void *digest_out,
* OUT: size of the copied digest
* @return VB2_SUCCESS, or error code on error
*/
-int vb2api_get_pcr_digest(struct vb2_context *ctx,
- enum vb2_pcr_digest which_digest,
- uint8_t *dest,
- uint32_t *dest_size);
+vb2_error_t vb2api_get_pcr_digest(struct vb2_context *ctx,
+ enum vb2_pcr_digest which_digest,
+ uint8_t *dest, uint32_t *dest_size);
/**
* Prepare for kernel verification stage.
@@ -591,7 +590,7 @@ int vb2api_get_pcr_digest(struct vb2_context *ctx,
* @param ctx Vboot context
* @return VB2_SUCCESS, or error code on error.
*/
-int vb2api_kernel_phase1(struct vb2_context *ctx);
+vb2_error_t vb2api_kernel_phase1(struct vb2_context *ctx);
/**
* Load the verified boot block (vblock) for a kernel.
@@ -603,7 +602,7 @@ int vb2api_kernel_phase1(struct vb2_context *ctx);
* @param stream Kernel stream
* @return VB2_SUCCESS, or error code on error.
*/
-int vb2api_load_kernel_vblock(struct vb2_context *ctx);
+vb2_error_t vb2api_load_kernel_vblock(struct vb2_context *ctx);
/**
* Get the size and offset of the kernel data for the most recent vblock.
@@ -616,9 +615,8 @@ int vb2api_load_kernel_vblock(struct vb2_context *ctx);
* @param size_ptr Destination for size of kernel data in bytes.
* @return VB2_SUCCESS, or error code on error.
*/
-int vb2api_get_kernel_size(struct vb2_context *ctx,
- uint32_t *offset_ptr,
- uint32_t *size_ptr);
+vb2_error_t vb2api_get_kernel_size(struct vb2_context *ctx,
+ uint32_t *offset_ptr, uint32_t *size_ptr);
/**
* Verify kernel data using the previously loaded kernel vblock.
@@ -632,9 +630,8 @@ int vb2api_get_kernel_size(struct vb2_context *ctx,
* @param size Size of kernel data in bytes
* @return VB2_SUCCESS, or error code on error.
*/
-int vb2api_verify_kernel_data(struct vb2_context *ctx,
- const void *buf,
- uint32_t size);
+vb2_error_t vb2api_verify_kernel_data(struct vb2_context *ctx, const void *buf,
+ uint32_t size);
/**
* Clean up after kernel verification.
@@ -645,7 +642,7 @@ int vb2api_verify_kernel_data(struct vb2_context *ctx,
* This cleans up intermediate data structures in the vboot context, and
* updates the version in the secure data if necessary.
*/
-int vb2api_kernel_phase3(struct vb2_context *ctx);
+vb2_error_t vb2api_kernel_phase3(struct vb2_context *ctx);
/**
* Read the hardware ID from the GBB, and store it onto the given buffer.
@@ -660,9 +657,8 @@ int vb2api_kernel_phase3(struct vb2_context *ctx);
* also including null terminator.
* @return VB2_SUCCESS, or error code on error.
*/
-int vb2api_gbb_read_hwid(struct vb2_context *ctx,
- char *hwid,
- uint32_t *size);
+vb2_error_t vb2api_gbb_read_hwid(struct vb2_context *ctx, char *hwid,
+ uint32_t *size);
/**
* Retrieve current GBB flags.
@@ -684,7 +680,7 @@ vb2_gbb_flags_t vb2api_gbb_get_flags(struct vb2_context *ctx);
* @param ctx Vboot context
* @return VB2_SUCCESS, or error code on error.
*/
-int vb2ex_tpm_clear_owner(struct vb2_context *ctx);
+vb2_error_t vb2ex_tpm_clear_owner(struct vb2_context *ctx);
/**
* Read a verified boot resource.
@@ -696,11 +692,9 @@ int vb2ex_tpm_clear_owner(struct vb2_context *ctx);
* @param size Amount of data to read
* @return VB2_SUCCESS, or error code on error.
*/
-int vb2ex_read_resource(struct vb2_context *ctx,
- enum vb2_resource_index index,
- uint32_t offset,
- void *buf,
- uint32_t size);
+vb2_error_t vb2ex_read_resource(struct vb2_context *ctx,
+ enum vb2_resource_index index, uint32_t offset,
+ void *buf, uint32_t size);
/**
* Print debug output
@@ -723,8 +717,8 @@ void vb2ex_printf(const char *func, const char *fmt, ...);
* @param data_size Expected total size of data to hash
* @return VB2_SUCCESS, or non-zero error code (HWCRYPTO_UNSUPPORTED not fatal).
*/
-int vb2ex_hwcrypto_digest_init(enum vb2_hash_algorithm hash_alg,
- uint32_t data_size);
+vb2_error_t vb2ex_hwcrypto_digest_init(enum vb2_hash_algorithm hash_alg,
+ uint32_t data_size);
/**
* Extend the hash in the hardware crypto engine with another block of data.
@@ -733,7 +727,7 @@ int vb2ex_hwcrypto_digest_init(enum vb2_hash_algorithm hash_alg,
* @param size Length of data block in bytes
* @return VB2_SUCCESS, or non-zero error code.
*/
-int vb2ex_hwcrypto_digest_extend(const uint8_t *buf, uint32_t size);
+vb2_error_t vb2ex_hwcrypto_digest_extend(const uint8_t *buf, uint32_t size);
/**
* Finalize the digest in the hardware crypto engine and extract the result.
@@ -742,7 +736,8 @@ int vb2ex_hwcrypto_digest_extend(const uint8_t *buf, uint32_t size);
* @param digest_size Length of digest buffer in bytes
* @return VB2_SUCCESS, or non-zero error code.
*/
-int vb2ex_hwcrypto_digest_finalize(uint8_t *digest, uint32_t digest_size);
+vb2_error_t vb2ex_hwcrypto_digest_finalize(uint8_t *digest,
+ uint32_t digest_size);
/*
* Set the current TPM mode value, and validate that it was changed. If one
@@ -757,6 +752,6 @@ int vb2ex_hwcrypto_digest_finalize(uint8_t *digest, uint32_t digest_size);
* or DISABLED from vb2_tpm_mode enum.
* @returns VB2_SUCCESS, or non-zero error code.
*/
-int vb2ex_tpm_set_mode(enum vb2_tpm_mode mode_val);
+vb2_error_t vb2ex_tpm_set_mode(enum vb2_tpm_mode mode_val);
#endif /* VBOOT_2_API_H_ */
diff --git a/firmware/2lib/include/2common.h b/firmware/2lib/include/2common.h
index 7cd8c041..f0df9c0b 100644
--- a/firmware/2lib/include/2common.h
+++ b/firmware/2lib/include/2common.h
@@ -111,8 +111,7 @@ void *vb2_workbuf_alloc(struct vb2_workbuf *wb, uint32_t size);
* @param newsize Requested size in bytes
* @return A pointer to the allocated space, or NULL if error.
*/
-void *vb2_workbuf_realloc(struct vb2_workbuf *wb,
- uint32_t oldsize,
+void *vb2_workbuf_realloc(struct vb2_workbuf *wb, uint32_t oldsize,
uint32_t newsize);
/**
@@ -143,7 +142,7 @@ void vb2_workbuf_free(struct vb2_workbuf *wb, uint32_t size);
* @param size Number of bytes to compare
* @return 0 if match or size=0, non-zero if at least one byte mismatched.
*/
-int vb2_safe_memcmp(const void *s1, const void *s2, size_t size);
+vb2_error_t vb2_safe_memcmp(const void *s1, const void *s2, size_t size);
/**
* Align a buffer and check its size.
@@ -154,10 +153,8 @@ int vb2_safe_memcmp(const void *s1, const void *s2, size_t size);
* @param want_size Required size
* @return VB2_SUCCESS, or non-zero if error.
*/
-int vb2_align(uint8_t **ptr,
- uint32_t *size,
- uint32_t align,
- uint32_t want_size);
+vb2_error_t vb2_align(uint8_t **ptr, uint32_t *size, uint32_t align,
+ uint32_t want_size);
/**
* Return offset of ptr from base.
@@ -233,10 +230,10 @@ const struct vb2_id *vb2_hash_id(enum vb2_hash_algorithm hash_alg);
* @param member_data_size Size of member data in bytes
* @return VB2_SUCCESS, or non-zero if error.
*/
-int vb2_verify_member_inside(const void *parent, size_t parent_size,
- const void *member, size_t member_size,
- ptrdiff_t member_data_offset,
- size_t member_data_size);
+vb2_error_t vb2_verify_member_inside(const void *parent, size_t parent_size,
+ const void *member, size_t member_size,
+ ptrdiff_t member_data_offset,
+ size_t member_data_size);
/*
* Helper function to get data pointed to by a public key.
diff --git a/firmware/2lib/include/2gbb.h b/firmware/2lib/include/2gbb.h
index 6ad0eb3b..4e4bd906 100644
--- a/firmware/2lib/include/2gbb.h
+++ b/firmware/2lib/include/2gbb.h
@@ -24,10 +24,9 @@ struct vb2_workbuf;
* @param wb Workbuf for data storage.
* @return VB2_SUCCESS, or error code on error.
*/
-int vb2_gbb_read_root_key(struct vb2_context *ctx,
- struct vb2_packed_key **keyp,
- uint32_t *size,
- struct vb2_workbuf *wb);
+vb2_error_t vb2_gbb_read_root_key(struct vb2_context *ctx,
+ struct vb2_packed_key **keyp, uint32_t *size,
+ struct vb2_workbuf *wb);
/**
* Read the recovery key from the GBB, and store it onto the given workbuf.
@@ -40,9 +39,8 @@ int vb2_gbb_read_root_key(struct vb2_context *ctx,
* @param wb Workbuf for data storage.
* @return VB2_SUCCESS, or error code on error.
*/
-int vb2_gbb_read_recovery_key(struct vb2_context *ctx,
- struct vb2_packed_key **keyp,
- uint32_t *size,
- struct vb2_workbuf *wb);
+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_ */
diff --git a/firmware/2lib/include/2misc.h b/firmware/2lib/include/2misc.h
index 3e1f1000..3b61bda4 100644
--- a/firmware/2lib/include/2misc.h
+++ b/firmware/2lib/include/2misc.h
@@ -39,7 +39,7 @@ struct vb2_gbb_header *vb2_get_gbb(struct vb2_context *ctx);
* @param sig Pointer to the signature bytes to validate
* @return VB2_SUCCESS if valid or non-zero if error.
*/
-int vb2_validate_gbb_signature(uint8_t *sig);
+vb2_error_t vb2_validate_gbb_signature(uint8_t *sig);
/**
* Initialize a work buffer from the vboot context.
@@ -69,7 +69,8 @@ void vb2_set_workbuf_used(struct vb2_context *ctx, uint32_t used);
* @param gbb Destination for header
* @return VB2_SUCCESS, or non-zero if error.
*/
-int vb2_read_gbb_header(struct vb2_context *ctx, struct vb2_gbb_header *gbb);
+vb2_error_t vb2_read_gbb_header(struct vb2_context *ctx,
+ struct vb2_gbb_header *gbb);
/**
* Handle vboot failure.
@@ -95,7 +96,7 @@ void vb2_fail(struct vb2_context *ctx, uint8_t reason, uint8_t subcode);
* @param ctx Vboot context to initialize
* @return VB2_SUCCESS, or error code on error.
*/
-int vb2_init_context(struct vb2_context *ctx);
+vb2_error_t vb2_init_context(struct vb2_context *ctx);
/**
* Check for recovery reasons we can determine early in the boot process.
@@ -116,7 +117,7 @@ void vb2_check_recovery(struct vb2_context *ctx);
* @param ctx Vboot context
* @return VB2_SUCCESS, or error code on error.
*/
-int vb2_fw_parse_gbb(struct vb2_context *ctx);
+vb2_error_t vb2_fw_parse_gbb(struct vb2_context *ctx);
/**
* Check developer switch position.
@@ -124,7 +125,7 @@ int vb2_fw_parse_gbb(struct vb2_context *ctx);
* @param ctx Vboot context
* @return VB2_SUCCESS, or error code on error.
*/
-int vb2_check_dev_switch(struct vb2_context *ctx);
+vb2_error_t vb2_check_dev_switch(struct vb2_context *ctx);
/**
* Check if we need to clear the TPM owner.
@@ -132,7 +133,7 @@ int vb2_check_dev_switch(struct vb2_context *ctx);
* @param ctx Vboot context
* @return VB2_SUCCESS, or error code on error.
*/
-int vb2_check_tpm_clear(struct vb2_context *ctx);
+vb2_error_t vb2_check_tpm_clear(struct vb2_context *ctx);
/**
* Decide which firmware slot to try this boot.
@@ -140,7 +141,7 @@ int vb2_check_tpm_clear(struct vb2_context *ctx);
* @param ctx Vboot context
* @return VB2_SUCCESS, or error code on error.
*/
-int vb2_select_fw_slot(struct vb2_context *ctx);
+vb2_error_t vb2_select_fw_slot(struct vb2_context *ctx);
/**
* Verify the firmware keyblock using the root key.
@@ -150,8 +151,8 @@ int vb2_select_fw_slot(struct vb2_context *ctx);
* @param ctx Vboot context
* @return VB2_SUCCESS, or error code on error.
*/
-int vb2_load_fw_keyblock(struct vb2_context *ctx);
-int vb21_load_fw_keyblock(struct vb2_context *ctx);
+vb2_error_t vb2_load_fw_keyblock(struct vb2_context *ctx);
+vb2_error_t vb21_load_fw_keyblock(struct vb2_context *ctx);
/**
* Verify the firmware preamble using the data subkey from the keyblock.
@@ -161,8 +162,8 @@ int vb21_load_fw_keyblock(struct vb2_context *ctx);
* @param ctx Vboot context
* @return VB2_SUCCESS, or error code on error.
*/
-int vb2_load_fw_preamble(struct vb2_context *ctx);
-int vb21_load_fw_preamble(struct vb2_context *ctx);
+vb2_error_t vb2_load_fw_preamble(struct vb2_context *ctx);
+vb2_error_t vb21_load_fw_preamble(struct vb2_context *ctx);
/**
* Verify the kernel keyblock using the previously-loaded kernel key.
@@ -172,7 +173,7 @@ int vb21_load_fw_preamble(struct vb2_context *ctx);
* @param ctx Vboot context
* @return VB2_SUCCESS, or error code on error.
*/
-int vb2_load_kernel_keyblock(struct vb2_context *ctx);
+vb2_error_t vb2_load_kernel_keyblock(struct vb2_context *ctx);
/**
* Verify the kernel preamble using the data subkey from the keyblock.
@@ -182,6 +183,6 @@ int vb2_load_kernel_keyblock(struct vb2_context *ctx);
* @param ctx Vboot context
* @return VB2_SUCCESS, or error code on error.
*/
-int vb2_load_kernel_preamble(struct vb2_context *ctx);
+vb2_error_t vb2_load_kernel_preamble(struct vb2_context *ctx);
#endif /* VBOOT_REFERENCE_VBOOT_2MISC_H_ */
diff --git a/firmware/2lib/include/2nvstorage.h b/firmware/2lib/include/2nvstorage.h
index b51cb6fa..1a6ab8ad 100644
--- a/firmware/2lib/include/2nvstorage.h
+++ b/firmware/2lib/include/2nvstorage.h
@@ -186,7 +186,7 @@ int vb2_nv_get_size(const struct vb2_context *ctx);
* @param ctx Context pointer
* @return VB2_SUCCESS, or non-zero error code if error.
*/
-int vb2_nv_check_crc(const struct vb2_context *ctx);
+vb2_error_t vb2_nv_check_crc(const struct vb2_context *ctx);
/**
* Initialize the non-volatile storage context and verify its CRC.
diff --git a/firmware/2lib/include/2rsa.h b/firmware/2lib/include/2rsa.h
index 4357029a..0ee72ca5 100644
--- a/firmware/2lib/include/2rsa.h
+++ b/firmware/2lib/include/2rsa.h
@@ -7,6 +7,7 @@
#define VBOOT_REFERENCE_2RSA_H_
#include "2crypto.h"
+#include "2return_codes.h"
#include "2struct.h"
struct vb2_workbuf;
@@ -63,9 +64,8 @@ uint32_t vb2_packed_key_size(enum vb2_signature_algorithm sig_alg);
* @param wb Work buffer
* @return VB2_SUCCESS, or non-zero if error.
*/
-int vb2_rsa_verify_digest(const struct vb2_public_key *key,
- uint8_t *sig,
- const uint8_t *digest,
- const struct vb2_workbuf *wb);
+vb2_error_t vb2_rsa_verify_digest(const struct vb2_public_key *key,
+ uint8_t *sig, const uint8_t *digest,
+ const struct vb2_workbuf *wb);
#endif /* VBOOT_REFERENCE_2RSA_H_ */
diff --git a/firmware/2lib/include/2secdata.h b/firmware/2lib/include/2secdata.h
index 2563b3fb..90f4bf23 100644
--- a/firmware/2lib/include/2secdata.h
+++ b/firmware/2lib/include/2secdata.h
@@ -99,7 +99,7 @@ enum vb2_secdatak_param {
* @param ctx Context pointer
* @return VB2_SUCCESS, or non-zero error code if error.
*/
-int vb2_secdata_init(struct vb2_context *ctx);
+vb2_error_t vb2_secdata_init(struct vb2_context *ctx);
/**
* Read a secure storage value.
@@ -109,9 +109,8 @@ int vb2_secdata_init(struct vb2_context *ctx);
* @param dest Destination for value
* @return VB2_SUCCESS, or non-zero error code if error.
*/
-int vb2_secdata_get(struct vb2_context *ctx,
- enum vb2_secdata_param param,
- uint32_t *dest);
+vb2_error_t vb2_secdata_get(struct vb2_context *ctx,
+ enum vb2_secdata_param param, uint32_t *dest);
/**
* Write a secure storage value.
@@ -121,9 +120,8 @@ int vb2_secdata_get(struct vb2_context *ctx,
* @param value New value
* @return VB2_SUCCESS, or non-zero error code if error.
*/
-int vb2_secdata_set(struct vb2_context *ctx,
- enum vb2_secdata_param param,
- uint32_t value);
+vb2_error_t vb2_secdata_set(struct vb2_context *ctx,
+ enum vb2_secdata_param param, uint32_t value);
/*****************************************************************************/
/* Kernel version space functions.
@@ -140,7 +138,7 @@ int vb2_secdata_set(struct vb2_context *ctx,
* @param ctx Context pointer
* @return VB2_SUCCESS, or non-zero error code if error.
*/
-int vb2_secdatak_init(struct vb2_context *ctx);
+vb2_error_t vb2_secdatak_init(struct vb2_context *ctx);
/**
* Read a secure storage value.
@@ -150,9 +148,8 @@ int vb2_secdatak_init(struct vb2_context *ctx);
* @param dest Destination for value
* @return VB2_SUCCESS, or non-zero error code if error.
*/
-int vb2_secdatak_get(struct vb2_context *ctx,
- enum vb2_secdatak_param param,
- uint32_t *dest);
+vb2_error_t vb2_secdatak_get(struct vb2_context *ctx,
+ enum vb2_secdatak_param param, uint32_t *dest);
/**
* Write a secure storage value.
@@ -162,8 +159,7 @@ int vb2_secdatak_get(struct vb2_context *ctx,
* @param value New value
* @return VB2_SUCCESS, or non-zero error code if error.
*/
-int vb2_secdatak_set(struct vb2_context *ctx,
- enum vb2_secdatak_param param,
- uint32_t value);
+vb2_error_t vb2_secdatak_set(struct vb2_context *ctx,
+ enum vb2_secdatak_param param, uint32_t value);
#endif /* VBOOT_REFERENCE_VBOOT_2SECDATA_H_ */
diff --git a/firmware/2lib/include/2sha.h b/firmware/2lib/include/2sha.h
index f41d8e15..646c7c17 100644
--- a/firmware/2lib/include/2sha.h
+++ b/firmware/2lib/include/2sha.h
@@ -12,6 +12,7 @@
#define VBOOT_REFERENCE_2SHA_H_
#include "2crypto.h"
+#include "2return_codes.h"
/* Hash algorithms may be disabled individually to save code space */
@@ -158,7 +159,7 @@ enum vb2_hash_algorithm vb2_crypto_to_hash(uint32_t algorithm);
* @param hash_alg Hash algorithm
* @return The size of the digest, or 0 if error.
*/
-int vb2_digest_size(enum vb2_hash_algorithm hash_alg);
+vb2_error_t vb2_digest_size(enum vb2_hash_algorithm hash_alg);
/**
* Return the block size of a hash algorithm.
@@ -166,7 +167,7 @@ int vb2_digest_size(enum vb2_hash_algorithm hash_alg);
* @param hash_alg Hash algorithm
* @return The block size of the algorithm, or 0 if error.
*/
-int vb2_hash_block_size(enum vb2_hash_algorithm alg);
+vb2_error_t vb2_hash_block_size(enum vb2_hash_algorithm alg);
/**
* Return the name of a hash algorithm
@@ -184,8 +185,8 @@ const char *vb2_get_hash_algorithm_name(enum vb2_hash_algorithm alg);
* @param hash_alg Hash algorithm
* @return VB2_SUCCESS, or non-zero on error.
*/
-int vb2_digest_init(struct vb2_digest_context *dc,
- enum vb2_hash_algorithm hash_alg);
+vb2_error_t vb2_digest_init(struct vb2_digest_context *dc,
+ enum vb2_hash_algorithm hash_alg);
/**
* Extend a digest's hash with another block of data.
@@ -195,9 +196,8 @@ int vb2_digest_init(struct vb2_digest_context *dc,
* @param size Length of data in bytes
* @return VB2_SUCCESS, or non-zero on error.
*/
-int vb2_digest_extend(struct vb2_digest_context *dc,
- const uint8_t *buf,
- uint32_t size);
+vb2_error_t vb2_digest_extend(struct vb2_digest_context *dc, const uint8_t *buf,
+ uint32_t size);
/**
* Finalize a digest and store the result.
@@ -209,9 +209,8 @@ int vb2_digest_extend(struct vb2_digest_context *dc,
* @param digest_size Length of digest buffer in bytes.
* @return VB2_SUCCESS, or non-zero on error.
*/
-int vb2_digest_finalize(struct vb2_digest_context *dc,
- uint8_t *digest,
- uint32_t digest_size);
+vb2_error_t vb2_digest_finalize(struct vb2_digest_context *dc,
+ uint8_t *digest, uint32_t digest_size);
/**
* Calculate the digest of a buffer and store the result.
@@ -223,10 +222,8 @@ int vb2_digest_finalize(struct vb2_digest_context *dc,
* @param digest_size Length of digest buffer in bytes.
* @return VB2_SUCCESS, or non-zero on error.
*/
-int vb2_digest_buffer(const uint8_t *buf,
- uint32_t size,
- enum vb2_hash_algorithm hash_alg,
- uint8_t *digest,
- uint32_t digest_size);
+vb2_error_t vb2_digest_buffer(const uint8_t *buf, uint32_t size,
+ enum vb2_hash_algorithm hash_alg, uint8_t *digest,
+ uint32_t digest_size);
#endif /* VBOOT_REFERENCE_2SHA_H_ */
diff --git a/firmware/include/vboot_api.h b/firmware/include/vboot_api.h
index 0621750b..8fdc18f7 100644
--- a/firmware/include/vboot_api.h
+++ b/firmware/include/vboot_api.h
@@ -877,7 +877,7 @@ enum VbAltFwIndex_t {
* verified before they are run. Currently these #s are defined:
* -1 diagnostic payload
*/
-int VbExLegacy(enum VbAltFwIndex_t altfw_num);
+vb2_error_t VbExLegacy(enum VbAltFwIndex_t altfw_num);
/* Regions for VbExRegionRead() */
enum vb_firmware_region {
diff --git a/firmware/include/vboot_test.h b/firmware/include/vboot_test.h
index b8e59a22..03dc54db 100644
--- a/firmware/include/vboot_test.h
+++ b/firmware/include/vboot_test.h
@@ -19,7 +19,8 @@
*/
struct vb2_public_key;
int vb2_mont_ge(const struct vb2_public_key *key, uint32_t *a);
-int vb2_check_padding(const uint8_t *sig, const struct vb2_public_key *key);
+vb2_error_t vb2_check_padding(const uint8_t *sig,
+ const struct vb2_public_key *key);
enum VbEcBootMode_t;
enum VbEcBootMode_t VbGetMode(void);
diff --git a/firmware/lib/ec_sync.c b/firmware/lib/ec_sync.c
index 23951aff..bdea2f9a 100644
--- a/firmware/lib/ec_sync.c
+++ b/firmware/lib/ec_sync.c
@@ -46,7 +46,7 @@ static void request_recovery(struct vb2_context *ctx, uint32_t recovery_request)
static vb2_error_t protect_ec(struct vb2_context *ctx, int devidx,
enum VbSelectFirmware_t select)
{
- int rv = VbExEcProtect(devidx, select);
+ vb2_error_t rv = VbExEcProtect(devidx, select);
if (rv == VBERROR_EC_REBOOT_TO_RO_REQUIRED) {
VB2_DEBUG("VbExEcProtect() needs reboot\n");
@@ -97,15 +97,16 @@ static const char *image_name_to_string(enum VbSelectFirmware_t select)
* @param select Which firmware image to check
* @return VB2_SUCCESS, or non-zero error code.
*/
-static int check_ec_hash(struct vb2_context *ctx, int devidx,
- enum VbSelectFirmware_t select)
+static vb2_error_t check_ec_hash(struct vb2_context *ctx, int devidx,
+ enum VbSelectFirmware_t select)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
/* Get current EC hash. */
const uint8_t *ec_hash = NULL;
int ec_hash_size;
- int rv = VbExEcHashImage(devidx, select, &ec_hash, &ec_hash_size);
+ vb2_error_t rv = VbExEcHashImage(devidx, select, &ec_hash,
+ &ec_hash_size);
if (rv) {
VB2_DEBUG("VbExEcHashImage() returned %d\n", rv);
request_recovery(ctx, VB2_RECOVERY_EC_HASH_FAILED);
@@ -155,7 +156,8 @@ static vb2_error_t update_ec(struct vb2_context *ctx, int devidx,
/* Get expected EC image */
const uint8_t *want = NULL;
int want_size;
- int rv = VbExEcGetExpectedImage(devidx, select, &want, &want_size);
+ vb2_error_t rv = VbExEcGetExpectedImage(devidx, select, &want,
+ &want_size);
if (rv) {
VB2_DEBUG("VbExEcGetExpectedImage() returned %d\n", rv);
request_recovery(ctx, VB2_RECOVERY_EC_EXPECTED_IMAGE);
@@ -211,7 +213,7 @@ static vb2_error_t check_ec_active(struct vb2_context *ctx, int devidx)
* trust what EC-RW says. If it lies it's in RO, we'll flash RW while
* it's in RW.
*/
- int rv = VbExEcRunningRW(devidx, &in_rw);
+ vb2_error_t rv = VbExEcRunningRW(devidx, &in_rw);
/* If we couldn't determine where the EC was, reboot to recovery. */
if (rv != VBERROR_SUCCESS) {
@@ -239,7 +241,7 @@ static vb2_error_t sync_one_ec(struct vb2_context *ctx, int devidx)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
int is_rw_ab = ctx->flags & RW_AB(devidx);
- int rv;
+ vb2_error_t rv;
const enum VbSelectFirmware_t select_rw = is_rw_ab ?
VB_SELECT_FIRMWARE_EC_UPDATE :
diff --git a/firmware/lib/include/rollback_index.h b/firmware/lib/include/rollback_index.h
index ff369114..c5b119e2 100644
--- a/firmware/lib/include/rollback_index.h
+++ b/firmware/lib/include/rollback_index.h
@@ -9,6 +9,7 @@
#ifndef VBOOT_REFERENCE_ROLLBACK_INDEX_H_
#define VBOOT_REFERENCE_ROLLBACK_INDEX_H_
+#include "2return_codes.h"
#include "sysincludes.h"
#include "tss_constants.h"
@@ -164,6 +165,6 @@ uint32_t SafeWrite(uint32_t index, const void *data, uint32_t length);
/**
* Utility function to turn the virtual dev-mode flag on or off. 0=off, 1=on.
*/
-uint32_t SetVirtualDevMode(int val);
+vb2_error_t SetVirtualDevMode(int val);
#endif /* VBOOT_REFERENCE_ROLLBACK_INDEX_H_ */
diff --git a/firmware/lib/include/vboot_common.h b/firmware/lib/include/vboot_common.h
index 95916488..ac020cc3 100644
--- a/firmware/lib/include/vboot_common.h
+++ b/firmware/lib/include/vboot_common.h
@@ -55,14 +55,14 @@ const uint8_t *GetSignatureDataC(const VbSignature *sig);
/*
* Helper functions to verify the data pointed to by a subfield is inside the
- * parent data. Returns 0 if inside, 1 if error.
+ * parent data.
*/
-int VerifyPublicKeyInside(const void *parent, uint64_t parent_size,
- const struct vb2_packed_key *key);
+vb2_error_t VerifyPublicKeyInside(const void *parent, uint64_t parent_size,
+ const struct vb2_packed_key *key);
-int VerifySignatureInside(const void *parent, uint64_t parent_size,
- const VbSignature *sig);
+vb2_error_t VerifySignatureInside(const void *parent, uint64_t parent_size,
+ const VbSignature *sig);
/**
* Initialize a public key to refer to [key_data].
@@ -86,9 +86,9 @@ int PublicKeyCopy(struct vb2_packed_key *dest,
*
* Returns VBOOT_SUCCESS if successful.
*/
-int VbGetKernelVmlinuzHeader(const VbKernelPreambleHeader *preamble,
- uint64_t *vmlinuz_header_address,
- uint64_t *vmlinuz_header_size);
+vb2_error_t VbGetKernelVmlinuzHeader(const VbKernelPreambleHeader *preamble,
+ uint64_t *vmlinuz_header_address,
+ uint64_t *vmlinuz_header_size);
/**
* Checks if the kernel preamble has flags field. This is available only if the
@@ -97,21 +97,21 @@ int VbGetKernelVmlinuzHeader(const VbKernelPreambleHeader *preamble,
*
* Returns VBOOT_SUCCESS if version is >=2.2.
*/
-int VbKernelHasFlags(const VbKernelPreambleHeader *preamble);
+vb2_error_t VbKernelHasFlags(const VbKernelPreambleHeader *preamble);
/**
* Verify that the Vmlinuz Header is contained inside of the kernel blob.
*
* Returns VBOOT_SUCCESS or VBOOT_PREAMBLE_INVALID on error
*/
-int VerifyVmlinuzInsideKBlob(uint64_t kblob, uint64_t kblob_size,
- uint64_t header, uint64_t header_size);
+vb2_error_t VerifyVmlinuzInsideKBlob(uint64_t kblob, uint64_t kblob_size,
+ uint64_t header, uint64_t header_size);
/**
* Initialize a verified boot shared data structure.
*
* Returns 0 if success, non-zero if error.
*/
-int VbSharedDataInit(VbSharedDataHeader *header, uint64_t size);
+vb2_error_t VbSharedDataInit(VbSharedDataHeader *header, uint64_t size);
/**
* Reserve [size] bytes of the shared data area. Returns the offset of the
@@ -124,8 +124,8 @@ uint64_t VbSharedDataReserve(VbSharedDataHeader *header, uint64_t size);
*
* Returns 0 if success, non-zero if error.
*/
-int VbSharedDataSetKernelKey(VbSharedDataHeader *header,
- const struct vb2_packed_key *src);
+vb2_error_t VbSharedDataSetKernelKey(VbSharedDataHeader *header,
+ const struct vb2_packed_key *src);
/**
* Check whether recovery is allowed or not.
diff --git a/firmware/lib/include/vboot_kernel.h b/firmware/lib/include/vboot_kernel.h
index 61ce2c93..7044ba10 100644
--- a/firmware/lib/include/vboot_kernel.h
+++ b/firmware/lib/include/vboot_kernel.h
@@ -27,7 +27,7 @@ struct vb2_context;
* @return VBERROR_SUCCESS, VBERROR_NO_DISK_FOUND if no disks of the specified
* type were found, or other non-zero VBERROR_ codes for other failures.
*/
-uint32_t VbTryLoadKernel(struct vb2_context *ctx, uint32_t get_info_flags);
+vb2_error_t VbTryLoadKernel(struct vb2_context *ctx, uint32_t get_info_flags);
/* Flags for VbUserConfirms() */
#define VB_CONFIRM_MUST_TRUST_KEYBOARD (1 << 0)
diff --git a/firmware/lib/mocked_rollback_index.c b/firmware/lib/mocked_rollback_index.c
index a4b0ceb0..733b0a54 100644
--- a/firmware/lib/mocked_rollback_index.c
+++ b/firmware/lib/mocked_rollback_index.c
@@ -14,7 +14,7 @@
#include "tss_constants.h"
-uint32_t SetVirtualDevMode(int val)
+vb2_error_t SetVirtualDevMode(int val)
{
return TPM_SUCCESS;
}
diff --git a/firmware/lib/rollback_index.c b/firmware/lib/rollback_index.c
index f52c8b59..41df72bb 100644
--- a/firmware/lib/rollback_index.c
+++ b/firmware/lib/rollback_index.c
@@ -143,7 +143,7 @@ uint32_t WriteSpaceFirmware(RollbackSpaceFirmware *rsf)
return TPM_E_CORRUPTED_STATE;
}
-uint32_t SetVirtualDevMode(int val)
+vb2_error_t SetVirtualDevMode(int val)
{
RollbackSpaceFirmware rsf;
diff --git a/firmware/lib/vboot_api_kernel.c b/firmware/lib/vboot_api_kernel.c
index 9202c6b8..6187655b 100644
--- a/firmware/lib/vboot_api_kernel.c
+++ b/firmware/lib/vboot_api_kernel.c
@@ -66,7 +66,7 @@ uint32_t vb2_get_fwmp_flags(void)
return fwmp.flags;
}
-uint32_t VbTryLoadKernel(struct vb2_context *ctx, uint32_t get_info_flags)
+vb2_error_t VbTryLoadKernel(struct vb2_context *ctx, uint32_t get_info_flags)
{
vb2_error_t retval = VBERROR_UNKNOWN;
VbDiskInfo* disk_info = NULL;
@@ -473,7 +473,7 @@ vb2_error_t VbVerifyMemoryBootImage(struct vb2_context *ctx,
uint32_t allow_fastboot_full_cap = 0;
struct vb2_workbuf wb;
vb2_error_t retval;
- int rv;
+ vb2_error_t rv;
/* Allocate work buffer */
vb2_workbuf_from_ctx(ctx, &wb);
diff --git a/firmware/lib/vboot_common.c b/firmware/lib/vboot_common.c
index e9516476..87500452 100644
--- a/firmware/lib/vboot_common.c
+++ b/firmware/lib/vboot_common.c
@@ -55,16 +55,16 @@ const uint8_t *GetSignatureDataC(const VbSignature *sig)
* the parent data.
*/
-int VerifyPublicKeyInside(const void *parent, uint64_t parent_size,
- const struct vb2_packed_key *key)
+vb2_error_t VerifyPublicKeyInside(const void *parent, uint64_t parent_size,
+ const struct vb2_packed_key *key)
{
return vb2_verify_member_inside(parent, parent_size,
key, sizeof(struct vb2_packed_key),
key->key_offset, key->key_size);
}
-int VerifySignatureInside(const void *parent, uint64_t parent_size,
- const VbSignature *sig)
+vb2_error_t VerifySignatureInside(const void *parent, uint64_t parent_size,
+ const VbSignature *sig)
{
return vb2_verify_member_inside(parent, parent_size,
sig, sizeof(VbSignature),
@@ -92,9 +92,9 @@ int PublicKeyCopy(struct vb2_packed_key *dest, const struct vb2_packed_key *src)
return 0;
}
-int VbGetKernelVmlinuzHeader(const VbKernelPreambleHeader *preamble,
- uint64_t *vmlinuz_header_address,
- uint64_t *vmlinuz_header_size)
+vb2_error_t VbGetKernelVmlinuzHeader(const VbKernelPreambleHeader *preamble,
+ uint64_t *vmlinuz_header_address,
+ uint64_t *vmlinuz_header_size)
{
*vmlinuz_header_address = 0;
*vmlinuz_header_size = 0;
@@ -111,7 +111,7 @@ int VbGetKernelVmlinuzHeader(const VbKernelPreambleHeader *preamble,
return VBOOT_SUCCESS;
}
-int VbKernelHasFlags(const VbKernelPreambleHeader *preamble)
+vb2_error_t VbKernelHasFlags(const VbKernelPreambleHeader *preamble)
{
if (preamble->header_version_minor > 1)
return VBOOT_SUCCESS;
@@ -119,8 +119,8 @@ int VbKernelHasFlags(const VbKernelPreambleHeader *preamble)
return VBOOT_KERNEL_PREAMBLE_NO_FLAGS;
}
-int VerifyVmlinuzInsideKBlob(uint64_t kblob, uint64_t kblob_size,
- uint64_t header, uint64_t header_size)
+vb2_error_t VerifyVmlinuzInsideKBlob(uint64_t kblob, uint64_t kblob_size,
+ uint64_t header, uint64_t header_size)
{
uint64_t end = header-kblob;
if (end > kblob_size)
@@ -147,8 +147,8 @@ uint64_t VbSharedDataReserve(VbSharedDataHeader *header, uint64_t size)
return offs;
}
-int VbSharedDataSetKernelKey(VbSharedDataHeader *header,
- const struct vb2_packed_key *src)
+vb2_error_t VbSharedDataSetKernelKey(VbSharedDataHeader *header,
+ const struct vb2_packed_key *src)
{
struct vb2_packed_key *kdest;
diff --git a/firmware/lib/vboot_common_init.c b/firmware/lib/vboot_common_init.c
index b85c3cc3..44b3eb26 100644
--- a/firmware/lib/vboot_common_init.c
+++ b/firmware/lib/vboot_common_init.c
@@ -14,7 +14,7 @@
#include "vboot_common.h"
#include "utility.h"
-int VbSharedDataInit(VbSharedDataHeader *header, uint64_t size)
+vb2_error_t VbSharedDataInit(VbSharedDataHeader *header, uint64_t size)
{
VB2_DEBUG("VbSharedDataInit, %d bytes, header %d bytes\n", (int)size,
(int)sizeof(VbSharedDataHeader));
diff --git a/firmware/lib/vboot_display.c b/firmware/lib/vboot_display.c
index a2b57ef4..364cd131 100644
--- a/firmware/lib/vboot_display.c
+++ b/firmware/lib/vboot_display.c
@@ -278,7 +278,7 @@ vb2_error_t VbDisplayDebugInfo(struct vb2_context *ctx)
char buf[DEBUG_INFO_SIZE] = "";
char sha1sum[VB2_SHA1_DIGEST_SIZE * 2 + 1];
uint32_t used = 0;
- int ret;
+ vb2_error_t ret;
uint32_t i;
vb2_workbuf_from_ctx(ctx, &wb);
diff --git a/firmware/lib/vboot_kernel.c b/firmware/lib/vboot_kernel.c
index 96461d9f..a8c536d5 100644
--- a/firmware/lib/vboot_kernel.c
+++ b/firmware/lib/vboot_kernel.c
@@ -126,14 +126,11 @@ static uint32_t get_body_offset(uint8_t *kbuf)
* VB2_VERIFY_KERNEL_PREAMBLE_WORKBUF_BYTES bytes.
* @return VB2_SUCCESS, or non-zero error code.
*/
-static int vb2_verify_kernel_vblock(struct vb2_context *ctx,
- uint8_t *kbuf,
- uint32_t kbuf_size,
- const struct vb2_packed_key *kernel_subkey,
- const LoadKernelParams *params,
- uint32_t min_version,
- VbSharedDataKernelPart *shpart,
- struct vb2_workbuf *wb)
+static vb2_error_t vb2_verify_kernel_vblock(
+ struct vb2_context *ctx, uint8_t *kbuf, uint32_t kbuf_size,
+ const struct vb2_packed_key *kernel_subkey,
+ const LoadKernelParams *params, uint32_t min_version,
+ VbSharedDataKernelPart *shpart, struct vb2_workbuf *wb)
{
/* Unpack kernel subkey */
struct vb2_public_key kernel_subkey2;
@@ -311,14 +308,11 @@ enum vb2_load_partition_flags {
* @param wb Workbuf for data storage
* @return VB2_SUCCESS, or non-zero error code.
*/
-static int vb2_load_partition(struct vb2_context *ctx,
- VbExStream_t stream,
- const struct vb2_packed_key *kernel_subkey,
- uint32_t flags,
- LoadKernelParams *params,
- uint32_t min_version,
- VbSharedDataKernelPart *shpart,
- struct vb2_workbuf *wb)
+static vb2_error_t vb2_load_partition(
+ struct vb2_context *ctx, VbExStream_t stream,
+ const struct vb2_packed_key *kernel_subkey, uint32_t flags,
+ LoadKernelParams *params, uint32_t min_version,
+ VbSharedDataKernelPart *shpart, struct vb2_workbuf *wb)
{
uint64_t read_us = 0, start_ts;
struct vb2_workbuf wblocal = *wb;
@@ -444,7 +438,7 @@ vb2_error_t LoadKernel(struct vb2_context *ctx, LoadKernelParams *params)
uint32_t lowest_version = LOWEST_TPM_VERSION;
vb2_error_t retval = VBERROR_UNKNOWN;
int recovery = VB2_RECOVERY_LK_UNSPECIFIED;
- int rv;
+ vb2_error_t rv;
vb2_workbuf_from_ctx(ctx, &wb);
diff --git a/firmware/lib/vboot_ui.c b/firmware/lib/vboot_ui.c
index acce8ca9..cbf653d9 100644
--- a/firmware/lib/vboot_ui.c
+++ b/firmware/lib/vboot_ui.c
@@ -83,7 +83,7 @@ static int VbWantShutdown(struct vb2_context *ctx, uint32_t key)
return shutdown_request;
}
-static uint32_t VbTryUsb(struct vb2_context *ctx)
+static vb2_error_t VbTryUsb(struct vb2_context *ctx)
{
uint32_t retval = VbTryLoadKernel(ctx, VB_DISK_FLAG_REMOVABLE);
if (VBERROR_SUCCESS == retval) {
@@ -677,7 +677,7 @@ static vb2_error_t vb2_developer_ui(struct vb2_context *ctx)
VB2_DEBUG("VbBootDeveloper() - "
"user pressed Ctrl+L; Try alt firmware\n");
if (allow_legacy) {
- int ret;
+ vb2_error_t ret;
ret = vb2_altfw_ui(ctx);
if (ret)
@@ -693,7 +693,7 @@ static vb2_error_t vb2_developer_ui(struct vb2_context *ctx)
* Only show the vendor data ui if it is tag is settable
*/
if (ctx->flags & VB2_CONTEXT_VENDOR_DATA_SETTABLE) {
- int ret;
+ vb2_error_t ret;
VB2_DEBUG("VbBootDeveloper() - user pressed "
"Ctrl+S; Try set vendor data\n");
diff --git a/firmware/lib20/api.c b/firmware/lib20/api.c
index 606b5ceb..7c6b0d46 100644
--- a/firmware/lib20/api.c
+++ b/firmware/lib20/api.c
@@ -15,9 +15,9 @@
#include "2rsa.h"
#include "vb2_common.h"
-int vb2api_fw_phase3(struct vb2_context *ctx)
+vb2_error_t vb2api_fw_phase3(struct vb2_context *ctx)
{
- int rv;
+ vb2_error_t rv;
/* Verify firmware keyblock */
rv = vb2_load_fw_keyblock(ctx);
@@ -36,14 +36,15 @@ int vb2api_fw_phase3(struct vb2_context *ctx)
return VB2_SUCCESS;
}
-int vb2api_init_hash(struct vb2_context *ctx, uint32_t tag, uint32_t *size)
+vb2_error_t vb2api_init_hash(struct vb2_context *ctx, uint32_t tag,
+ uint32_t *size)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
const struct vb2_fw_preamble *pre;
struct vb2_digest_context *dc;
struct vb2_public_key key;
struct vb2_workbuf wb;
- int rv;
+ vb2_error_t rv;
vb2_workbuf_from_ctx(ctx, &wb);
@@ -129,8 +130,9 @@ int vb2api_init_hash(struct vb2_context *ctx, uint32_t tag, uint32_t *size)
return vb2_digest_init(dc, key.hash_alg);
}
-int vb2api_check_hash_get_digest(struct vb2_context *ctx, void *digest_out,
- uint32_t digest_out_size)
+vb2_error_t vb2api_check_hash_get_digest(struct vb2_context *ctx,
+ void *digest_out,
+ uint32_t digest_out_size)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
struct vb2_digest_context *dc = (struct vb2_digest_context *)
@@ -142,7 +144,7 @@ int vb2api_check_hash_get_digest(struct vb2_context *ctx, void *digest_out,
struct vb2_fw_preamble *pre;
struct vb2_public_key key;
- int rv;
+ vb2_error_t rv;
vb2_workbuf_from_ctx(ctx, &wb);
diff --git a/firmware/lib20/api_kernel.c b/firmware/lib20/api_kernel.c
index dbe47e61..8e5f5e61 100644
--- a/firmware/lib20/api_kernel.c
+++ b/firmware/lib20/api_kernel.c
@@ -15,13 +15,13 @@
#include "2rsa.h"
#include "vb2_common.h"
-int vb2api_kernel_phase1(struct vb2_context *ctx)
+vb2_error_t vb2api_kernel_phase1(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;
- int rv;
+ vb2_error_t rv;
vb2_workbuf_from_ctx(ctx, &wb);
@@ -125,9 +125,9 @@ int vb2api_kernel_phase1(struct vb2_context *ctx)
return VB2_SUCCESS;
}
-int vb2api_load_kernel_vblock(struct vb2_context *ctx)
+vb2_error_t vb2api_load_kernel_vblock(struct vb2_context *ctx)
{
- int rv;
+ vb2_error_t rv;
/* Verify kernel keyblock */
rv = vb2_load_kernel_keyblock(ctx);
@@ -142,9 +142,8 @@ int vb2api_load_kernel_vblock(struct vb2_context *ctx)
return VB2_SUCCESS;
}
-int vb2api_get_kernel_size(struct vb2_context *ctx,
- uint32_t *offset_ptr,
- uint32_t *size_ptr)
+vb2_error_t vb2api_get_kernel_size(struct vb2_context *ctx,
+ uint32_t *offset_ptr, uint32_t *size_ptr)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
const struct vb2_kernel_preamble *pre;
@@ -170,9 +169,8 @@ int vb2api_get_kernel_size(struct vb2_context *ctx,
return VB2_SUCCESS;
}
-int vb2api_verify_kernel_data(struct vb2_context *ctx,
- const void *buf,
- uint32_t size)
+vb2_error_t vb2api_verify_kernel_data(struct vb2_context *ctx, const void *buf,
+ uint32_t size)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
struct vb2_kernel_preamble *pre;
@@ -183,7 +181,7 @@ int vb2api_verify_kernel_data(struct vb2_context *ctx,
uint8_t *digest;
uint32_t digest_size;
- int rv;
+ vb2_error_t rv;
vb2_workbuf_from_ctx(ctx, &wb);
@@ -250,10 +248,10 @@ int vb2api_verify_kernel_data(struct vb2_context *ctx,
return vb2_verify_digest(&key, &pre->body_signature, digest, &wb);
}
-int vb2api_kernel_phase3(struct vb2_context *ctx)
+vb2_error_t vb2api_kernel_phase3(struct vb2_context *ctx)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
- int rv;
+ vb2_error_t rv;
/*
* If the kernel is a newer version than in secure storage, and the
diff --git a/firmware/lib20/common.c b/firmware/lib20/common.c
index 64644d4a..8e9a2d85 100644
--- a/firmware/lib20/common.c
+++ b/firmware/lib20/common.c
@@ -16,7 +16,7 @@ uint8_t *vb2_signature_data(struct vb2_signature *sig)
return (uint8_t *)sig + sig->sig_offset;
}
-int vb2_verify_signature_inside(const void *parent,
+vb2_error_t vb2_verify_signature_inside(const void *parent,
uint32_t parent_size,
const struct vb2_signature *sig)
{
@@ -25,10 +25,9 @@ int vb2_verify_signature_inside(const void *parent,
sig->sig_offset, sig->sig_size);
}
-int vb2_verify_digest(const struct vb2_public_key *key,
- struct vb2_signature *sig,
- const uint8_t *digest,
- const struct vb2_workbuf *wb)
+vb2_error_t vb2_verify_digest(const struct vb2_public_key *key,
+ struct vb2_signature *sig, const uint8_t *digest,
+ const struct vb2_workbuf *wb)
{
uint8_t *sig_data = vb2_signature_data(sig);
@@ -43,7 +42,7 @@ int vb2_verify_digest(const struct vb2_public_key *key,
return vb2_rsa_verify_digest(key, sig_data, digest, wb);
}
-int vb2_verify_data(const uint8_t *data,
+vb2_error_t vb2_verify_data(const uint8_t *data,
uint32_t size,
struct vb2_signature *sig,
const struct vb2_public_key *key,
@@ -53,7 +52,7 @@ int vb2_verify_data(const uint8_t *data,
struct vb2_digest_context *dc;
uint8_t *digest;
uint32_t digest_size;
- int rv;
+ vb2_error_t rv;
if (sig->data_size > size) {
VB2_DEBUG("Data buffer smaller than length of signed data.\n");
@@ -91,9 +90,8 @@ int vb2_verify_data(const uint8_t *data,
return vb2_verify_digest(key, sig, digest, &wblocal);
}
-int vb2_check_keyblock(const struct vb2_keyblock *block,
- uint32_t size,
- const struct vb2_signature *sig)
+vb2_error_t vb2_check_keyblock(const struct vb2_keyblock *block, uint32_t size,
+ const struct vb2_signature *sig)
{
if(size < sizeof(*block)) {
VB2_DEBUG("Not enough space for key block header.\n");
@@ -147,13 +145,12 @@ int vb2_check_keyblock(const struct vb2_keyblock *block,
return VB2_SUCCESS;
}
-int vb2_verify_keyblock(struct vb2_keyblock *block,
- uint32_t size,
- const struct vb2_public_key *key,
- const struct vb2_workbuf *wb)
+vb2_error_t vb2_verify_keyblock(struct vb2_keyblock *block, uint32_t size,
+ const struct vb2_public_key *key,
+ const struct vb2_workbuf *wb)
{
struct vb2_signature *sig = &block->keyblock_signature;
- int rv;
+ vb2_error_t rv;
/* Sanity check keyblock before attempting signature check of data */
rv = vb2_check_keyblock(block, size, sig);
@@ -171,10 +168,10 @@ int vb2_verify_keyblock(struct vb2_keyblock *block,
return VB2_SUCCESS;
}
-int vb2_verify_fw_preamble(struct vb2_fw_preamble *preamble,
- uint32_t size,
- const struct vb2_public_key *key,
- const struct vb2_workbuf *wb)
+vb2_error_t 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_signature *sig = &preamble->preamble_signature;
diff --git a/firmware/lib20/include/vb2_common.h b/firmware/lib20/include/vb2_common.h
index 2f70d544..d16572a5 100644
--- a/firmware/lib20/include/vb2_common.h
+++ b/firmware/lib20/include/vb2_common.h
@@ -32,9 +32,9 @@ uint8_t *vb2_signature_data(struct vb2_signature *sig);
* @param sig Signature pointer
* @return VB2_SUCCESS, or non-zero if error.
*/
-int vb2_verify_signature_inside(const void *parent,
- uint32_t parent_size,
- const struct vb2_signature *sig);
+vb2_error_t vb2_verify_signature_inside(const void *parent,
+ uint32_t parent_size,
+ const struct vb2_signature *sig);
/**
* Unpack a vboot1-format key buffer for use in verification
@@ -47,9 +47,8 @@ int vb2_verify_signature_inside(const void *parent,
* @param size Size of buffer in bytes
* @return VB2_SUCCESS, or non-zero error code if error.
*/
-int vb2_unpack_key_buffer(struct vb2_public_key *key,
- const uint8_t *buf,
- uint32_t size);
+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
@@ -62,8 +61,8 @@ int vb2_unpack_key_buffer(struct vb2_public_key *key,
* @param size Size of buffer in bytes
* @return VB2_SUCCESS, or non-zero error code if error.
*/
-int vb2_unpack_key(struct vb2_public_key *key,
- const struct vb2_packed_key *packed_key);
+vb2_error_t vb2_unpack_key(struct vb2_public_key *key,
+ const struct vb2_packed_key *packed_key);
/**
* Verify a signature against an expected hash digest.
@@ -74,10 +73,9 @@ int vb2_unpack_key(struct vb2_public_key *key,
* @param wb Work buffer
* @return VB2_SUCCESS, or non-zero if error.
*/
-int vb2_verify_digest(const struct vb2_public_key *key,
- struct vb2_signature *sig,
- const uint8_t *digest,
- const struct vb2_workbuf *wb);
+vb2_error_t 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.
@@ -90,11 +88,10 @@ int vb2_verify_digest(const struct vb2_public_key *key,
* @param wb Work buffer
* @return VB2_SUCCESS, or non-zero error code if error.
*/
-int vb2_verify_data(const uint8_t *data,
- uint32_t size,
- struct vb2_signature *sig,
- const struct vb2_public_key *key,
- const struct vb2_workbuf *wb);
+vb2_error_t vb2_verify_data(const uint8_t *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 structure.
@@ -108,9 +105,8 @@ int vb2_verify_data(const uint8_t *data,
* @param size Size of key block buffer
* @param sig Which signature inside the keyblock to use
*/
-int vb2_check_keyblock(const struct vb2_keyblock *block,
- uint32_t size,
- const struct vb2_signature *sig);
+vb2_error_t vb2_check_keyblock(const struct vb2_keyblock *block, uint32_t size,
+ const struct vb2_signature *sig);
/**
* Verify a key block using a public key.
@@ -124,10 +120,9 @@ int vb2_check_keyblock(const struct vb2_keyblock *block,
* @param wb Work buffer
* @return VB2_SUCCESS, or non-zero error code if error.
*/
-int vb2_verify_keyblock(struct vb2_keyblock *block,
- uint32_t size,
- const struct vb2_public_key *key,
- const struct vb2_workbuf *wb);
+vb2_error_t vb2_verify_keyblock(struct vb2_keyblock *block, uint32_t size,
+ const struct vb2_public_key *key,
+ const struct vb2_workbuf *wb);
/**
* Verify a key block using its hash.
@@ -141,9 +136,9 @@ int vb2_verify_keyblock(struct vb2_keyblock *block,
* @param wb Work buffer
* @return VB2_SUCCESS, or non-zero error code if error.
*/
-int vb2_verify_keyblock_hash(const struct vb2_keyblock *block,
- uint32_t size,
- const struct vb2_workbuf *wb);
+vb2_error_t vb2_verify_keyblock_hash(const struct vb2_keyblock *block,
+ uint32_t size,
+ const struct vb2_workbuf *wb);
/**
* Check the sanity of a firmware preamble using a public key.
@@ -156,10 +151,10 @@ int vb2_verify_keyblock_hash(const struct vb2_keyblock *block,
* @param wb Work buffer
* @return VB2_SUCCESS, or non-zero error code if error.
*/
-int vb2_verify_fw_preamble(struct vb2_fw_preamble *preamble,
- uint32_t size,
- const struct vb2_public_key *key,
- const struct vb2_workbuf *wb);
+vb2_error_t vb2_verify_fw_preamble(struct vb2_fw_preamble *preamble,
+ uint32_t size,
+ const struct vb2_public_key *key,
+ const struct vb2_workbuf *wb);
/**
* Check the sanity of a kernel preamble using a public key.
@@ -172,10 +167,10 @@ int vb2_verify_fw_preamble(struct vb2_fw_preamble *preamble,
* @param wb Work buffer
* @return VB2_SUCCESS, or non-zero error code if error.
*/
-int vb2_verify_kernel_preamble(struct vb2_kernel_preamble *preamble,
- uint32_t size,
- const struct vb2_public_key *key,
- const struct vb2_workbuf *wb);
+vb2_error_t vb2_verify_kernel_preamble(struct vb2_kernel_preamble *preamble,
+ uint32_t size,
+ const struct vb2_public_key *key,
+ const struct vb2_workbuf *wb);
/**
* Retrieve the 16-bit vmlinuz header address and size from the preamble.
diff --git a/firmware/lib20/kernel.c b/firmware/lib20/kernel.c
index c192b892..4d8f7721 100644
--- a/firmware/lib20/kernel.c
+++ b/firmware/lib20/kernel.c
@@ -40,16 +40,16 @@ static int vb2_need_signed_kernel(struct vb2_context *ctx)
return 0;
}
-int vb2_verify_keyblock_hash(const struct vb2_keyblock *block,
- uint32_t size,
- const struct vb2_workbuf *wb)
+vb2_error_t vb2_verify_keyblock_hash(const struct vb2_keyblock *block,
+ uint32_t size,
+ const struct vb2_workbuf *wb)
{
const struct vb2_signature *sig = &block->keyblock_hash;
struct vb2_workbuf wblocal = *wb;
struct vb2_digest_context *dc;
uint8_t *digest;
uint32_t digest_size;
- int rv;
+ vb2_error_t rv;
/* Sanity check keyblock before attempting hash check of data */
rv = vb2_check_keyblock(block, size, sig);
@@ -91,7 +91,7 @@ int vb2_verify_keyblock_hash(const struct vb2_keyblock *block,
return VB2_SUCCESS;
}
-int vb2_load_kernel_keyblock(struct vb2_context *ctx)
+vb2_error_t vb2_load_kernel_keyblock(struct vb2_context *ctx)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
struct vb2_workbuf wb;
@@ -109,7 +109,7 @@ int vb2_load_kernel_keyblock(struct vb2_context *ctx)
int need_keyblock_valid = vb2_need_signed_kernel(ctx);
int keyblock_is_valid = 1;
- int rv;
+ vb2_error_t rv;
vb2_workbuf_from_ctx(ctx, &wb);
@@ -244,10 +244,10 @@ int vb2_load_kernel_keyblock(struct vb2_context *ctx)
return VB2_SUCCESS;
}
-int vb2_verify_kernel_preamble(struct vb2_kernel_preamble *preamble,
- uint32_t size,
- const struct vb2_public_key *key,
- const struct vb2_workbuf *wb)
+vb2_error_t vb2_verify_kernel_preamble(struct vb2_kernel_preamble *preamble,
+ uint32_t size,
+ const struct vb2_public_key *key,
+ const struct vb2_workbuf *wb)
{
struct vb2_signature *sig = &preamble->preamble_signature;
uint32_t min_size = EXPECTED_VB2_KERNEL_PREAMBLE_2_0_SIZE;
@@ -352,7 +352,7 @@ int vb2_verify_kernel_preamble(struct vb2_kernel_preamble *preamble,
return VB2_SUCCESS;
}
-int vb2_load_kernel_preamble(struct vb2_context *ctx)
+vb2_error_t vb2_load_kernel_preamble(struct vb2_context *ctx)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
struct vb2_workbuf wb;
@@ -367,7 +367,7 @@ int vb2_load_kernel_preamble(struct vb2_context *ctx)
struct vb2_kernel_preamble *pre;
uint32_t pre_size;
- int rv;
+ vb2_error_t rv;
vb2_workbuf_from_ctx(ctx, &wb);
diff --git a/firmware/lib20/misc.c b/firmware/lib20/misc.c
index bc479ab7..70f3ab80 100644
--- a/firmware/lib20/misc.c
+++ b/firmware/lib20/misc.c
@@ -65,7 +65,7 @@ static void vb2_report_dev_firmware(struct vb2_public_key *root)
VB2_DEBUG("This is developer signed firmware\n");
}
-int vb2_load_fw_keyblock(struct vb2_context *ctx)
+vb2_error_t vb2_load_fw_keyblock(struct vb2_context *ctx)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
struct vb2_gbb_header *gbb = vb2_get_gbb(ctx);
@@ -79,7 +79,7 @@ int vb2_load_fw_keyblock(struct vb2_context *ctx)
struct vb2_keyblock *kb;
uint32_t block_size;
- int rv;
+ vb2_error_t rv;
vb2_workbuf_from_ctx(ctx, &wb);
@@ -192,7 +192,7 @@ int vb2_load_fw_keyblock(struct vb2_context *ctx)
return VB2_SUCCESS;
}
-int vb2_load_fw_preamble(struct vb2_context *ctx)
+vb2_error_t vb2_load_fw_preamble(struct vb2_context *ctx)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
struct vb2_gbb_header *gbb = vb2_get_gbb(ctx);
@@ -206,7 +206,7 @@ int vb2_load_fw_preamble(struct vb2_context *ctx)
struct vb2_fw_preamble *pre;
uint32_t pre_size;
- int rv;
+ vb2_error_t rv;
vb2_workbuf_from_ctx(ctx, &wb);
diff --git a/firmware/lib20/packed_key.c b/firmware/lib20/packed_key.c
index 2e1c9cbc..af888e6e 100644
--- a/firmware/lib20/packed_key.c
+++ b/firmware/lib20/packed_key.c
@@ -11,15 +11,14 @@
#include "vb2_common.h"
test_mockable
-int vb2_unpack_key_buffer(struct vb2_public_key *key,
- const uint8_t *buf,
- uint32_t size)
+vb2_error_t vb2_unpack_key_buffer(struct vb2_public_key *key,
+ const uint8_t *buf, uint32_t size)
{
const struct vb2_packed_key *packed_key =
(const struct vb2_packed_key *)buf;
const uint32_t *buf32;
uint32_t expected_key_size;
- int rv;
+ vb2_error_t rv;
/* Make sure passed buffer is big enough for the packed key */
rv = vb2_verify_packed_key_inside(buf, size, packed_key);
@@ -64,8 +63,8 @@ int vb2_unpack_key_buffer(struct vb2_public_key *key,
return VB2_SUCCESS;
}
-int vb2_unpack_key(struct vb2_public_key *key,
- const struct vb2_packed_key *packed_key)
+vb2_error_t vb2_unpack_key(struct vb2_public_key *key,
+ const struct vb2_packed_key *packed_key)
{
if (!packed_key)
return VB2_ERROR_UNPACK_KEY_BUFFER;
diff --git a/firmware/lib21/api.c b/firmware/lib21/api.c
index 9f14579e..59448695 100644
--- a/firmware/lib21/api.c
+++ b/firmware/lib21/api.c
@@ -16,9 +16,9 @@
#include "2rsa.h"
#include "vb21_common.h"
-int vb21api_fw_phase3(struct vb2_context *ctx)
+vb2_error_t vb21api_fw_phase3(struct vb2_context *ctx)
{
- int rv;
+ vb2_error_t rv;
/* Verify firmware keyblock */
rv = vb21_load_fw_keyblock(ctx);
@@ -37,7 +37,7 @@ int vb21api_fw_phase3(struct vb2_context *ctx)
return VB2_SUCCESS;
}
-int vb21api_init_hash(struct vb2_context *ctx,
+vb2_error_t vb21api_init_hash(struct vb2_context *ctx,
const struct vb2_id *id,
uint32_t *size)
{
@@ -113,7 +113,7 @@ int vb21api_init_hash(struct vb2_context *ctx,
return vb2_digest_init(dc, sig->hash_alg);
}
-int vb21api_check_hash(struct vb2_context *ctx)
+vb2_error_t vb21api_check_hash(struct vb2_context *ctx)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
struct vb2_digest_context *dc = (struct vb2_digest_context *)
@@ -125,7 +125,7 @@ int vb21api_check_hash(struct vb2_context *ctx)
const struct vb21_signature *sig;
- int rv;
+ vb2_error_t rv;
vb2_workbuf_from_ctx(ctx, &wb);
diff --git a/firmware/lib21/common.c b/firmware/lib21/common.c
index c38a39ef..ed96ea08 100644
--- a/firmware/lib21/common.c
+++ b/firmware/lib21/common.c
@@ -18,7 +18,7 @@ const char *vb21_common_desc(const void *buf)
return c->desc_size ? (const char *)c + c->fixed_size : "";
}
-int vb21_verify_common_header(const void *parent, uint32_t parent_size)
+vb2_error_t vb21_verify_common_header(const void *parent, uint32_t parent_size)
{
const struct vb21_struct_common *c = parent;
@@ -57,10 +57,9 @@ int vb21_verify_common_header(const void *parent, uint32_t parent_size)
return VB2_SUCCESS;
}
-int vb21_verify_common_member(const void *parent,
- uint32_t *min_offset,
- uint32_t member_offset,
- uint32_t member_size)
+vb2_error_t vb21_verify_common_member(const void *parent, uint32_t *min_offset,
+ uint32_t member_offset,
+ uint32_t member_size)
{
const struct vb21_struct_common *c = parent;
uint32_t member_end = member_offset + member_size;
@@ -92,15 +91,15 @@ int vb21_verify_common_member(const void *parent,
return VB2_SUCCESS;
}
-int vb21_verify_common_subobject(const void *parent,
- uint32_t *min_offset,
- uint32_t member_offset)
+vb2_error_t vb21_verify_common_subobject(const void *parent,
+ uint32_t *min_offset,
+ uint32_t member_offset)
{
const struct vb21_struct_common *p = parent;
const struct vb21_struct_common *m =
(const struct vb21_struct_common *)
((const uint8_t *)parent + member_offset);
- int rv;
+ vb2_error_t rv;
/*
* Verify the parent has space at the member offset for the common
@@ -171,11 +170,12 @@ const struct vb2_id *vb2_hash_id(enum vb2_hash_algorithm hash_alg)
}
}
-int vb21_verify_signature(const struct vb21_signature *sig, uint32_t size)
+vb2_error_t vb21_verify_signature(const struct vb21_signature *sig,
+ uint32_t size)
{
uint32_t min_offset = 0;
uint32_t expect_sig_size;
- int rv;
+ vb2_error_t rv;
/* Check magic number */
if (sig->c.magic != VB21_MAGIC_SIGNATURE)
@@ -222,10 +222,10 @@ static uint8_t *vb21_signature_data(struct vb21_signature *sig)
return (uint8_t *)sig + sig->sig_offset;
}
-int vb21_verify_digest(const struct vb2_public_key *key,
- struct vb21_signature *sig,
- const uint8_t *digest,
- const struct vb2_workbuf *wb)
+vb2_error_t vb21_verify_digest(const struct vb2_public_key *key,
+ struct vb21_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);
@@ -255,17 +255,16 @@ int vb21_verify_digest(const struct vb2_public_key *key,
}
}
-int vb21_verify_data(const void *data,
- uint32_t size,
- struct vb21_signature *sig,
- const struct vb2_public_key *key,
- const struct vb2_workbuf *wb)
+vb2_error_t vb21_verify_data(const void *data, uint32_t size,
+ struct vb21_signature *sig,
+ const struct vb2_public_key *key,
+ const struct vb2_workbuf *wb)
{
struct vb2_workbuf wblocal = *wb;
struct vb2_digest_context *dc;
uint8_t *digest;
uint32_t digest_size;
- int rv;
+ vb2_error_t rv;
if (sig->data_size != size) {
VB2_DEBUG("Wrong amount of data signed.\n");
@@ -303,13 +302,12 @@ int vb21_verify_data(const void *data,
return vb21_verify_digest(key, sig, digest, &wblocal);
}
-int vb21_verify_keyblock(struct vb21_keyblock *block,
- uint32_t size,
- const struct vb2_public_key *key,
- const struct vb2_workbuf *wb)
+vb2_error_t vb21_verify_keyblock(struct vb21_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;
+ vb2_error_t rv, i;
/* Check magic number */
if (block->c.magic != VB21_MAGIC_KEYBLOCK)
@@ -372,14 +370,14 @@ int vb21_verify_keyblock(struct vb21_keyblock *block,
return VB2_ERROR_KEYBLOCK_SIG_ID;
}
-int vb21_verify_fw_preamble(struct vb21_fw_preamble *preamble,
- uint32_t size,
- const struct vb2_public_key *key,
- const struct vb2_workbuf *wb)
+vb2_error_t vb21_verify_fw_preamble(struct vb21_fw_preamble *preamble,
+ uint32_t size,
+ const struct vb2_public_key *key,
+ const struct vb2_workbuf *wb)
{
struct vb21_signature *sig;
uint32_t min_offset = 0, hash_offset;
- int rv, i;
+ vb2_error_t rv, i;
/* Check magic number */
if (preamble->c.magic != VB21_MAGIC_FW_PREAMBLE)
diff --git a/firmware/lib21/include/vb21_common.h b/firmware/lib21/include/vb21_common.h
index e89eb6cc..7ca5b4f5 100644
--- a/firmware/lib21/include/vb21_common.h
+++ b/firmware/lib21/include/vb21_common.h
@@ -37,7 +37,7 @@ const char *vb21_common_desc(const void *buf);
* @param parent_size Parent size in bytes
* @return VB2_SUCCESS, or non-zero if error.
*/
-int vb21_verify_common_header(const void *parent, uint32_t parent_size);
+vb2_error_t vb21_verify_common_header(const void *parent, uint32_t parent_size);
/**
* Verify a member is within the data for a parent object
@@ -52,10 +52,9 @@ int vb21_verify_common_header(const void *parent, uint32_t parent_size);
* @param member_size Size of member data, in bytes
* @return VB2_SUCCESS, or non-zero if error.
*/
-int vb21_verify_common_member(const void *parent,
- uint32_t *min_offset,
- uint32_t member_offset,
- uint32_t member_size);
+vb2_error_t vb21_verify_common_member(const void *parent, uint32_t *min_offset,
+ uint32_t member_offset,
+ uint32_t member_size);
/**
* Verify a member which starts with a common header is within the parent
@@ -75,9 +74,9 @@ int vb21_verify_common_member(const void *parent,
* member.
* @return VB2_SUCCESS, or non-zero if error.
*/
-int vb21_verify_common_subobject(const void *parent,
- uint32_t *min_offset,
- uint32_t member_offset);
+vb2_error_t vb21_verify_common_subobject(const void *parent,
+ uint32_t *min_offset,
+ uint32_t member_offset);
/**
* Unpack a key for use in verification
@@ -90,9 +89,8 @@ int vb21_verify_common_subobject(const void *parent,
* @param size Size of buffer in bytes
* @return VB2_SUCCESS, or non-zero error code if error.
*/
-int vb21_unpack_key(struct vb2_public_key *key,
- const uint8_t *buf,
- uint32_t size);
+vb2_error_t vb21_unpack_key(struct vb2_public_key *key, const uint8_t *buf,
+ uint32_t size);
/**
* Unpack the RSA data fields for a public key
@@ -104,9 +102,8 @@ int vb21_unpack_key(struct vb2_public_key *key,
* @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_key_data(struct vb2_public_key *key,
- const uint8_t *key_data,
- uint32_t key_size);
+vb2_error_t 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
@@ -114,8 +111,8 @@ int vb2_unpack_key_data(struct vb2_public_key *key,
* @param size Size of buffer containing signature struct
* @return VB2_SUCCESS, or non-zero if error.
*/
-int vb21_verify_signature(const struct vb21_signature *sig,
- uint32_t size);
+vb2_error_t vb21_verify_signature(const struct vb21_signature *sig,
+ uint32_t size);
/**
* Verify a signature against an expected hash digest.
@@ -126,10 +123,10 @@ int vb21_verify_signature(const struct vb21_signature *sig,
* @param wb Work buffer
* @return VB2_SUCCESS, or non-zero if error.
*/
-int vb21_verify_digest(const struct vb2_public_key *key,
- struct vb21_signature *sig,
- const uint8_t *digest,
- const struct vb2_workbuf *wb);
+vb2_error_t vb21_verify_digest(const struct vb2_public_key *key,
+ struct vb21_signature *sig,
+ const uint8_t *digest,
+ const struct vb2_workbuf *wb);
/**
* Verify data matches signature.
@@ -142,11 +139,10 @@ int vb21_verify_digest(const struct vb2_public_key *key,
* @param wb Work buffer
* @return VB2_SUCCESS, or non-zero error code if error.
*/
-int vb21_verify_data(const void *data,
- uint32_t size,
- struct vb21_signature *sig,
- const struct vb2_public_key *key,
- const struct vb2_workbuf *wb);
+vb2_error_t vb21_verify_data(const void *data, uint32_t size,
+ struct vb21_signature *sig,
+ const struct vb2_public_key *key,
+ const struct vb2_workbuf *wb);
/**
* Check the sanity of a key block using a public key.
@@ -160,10 +156,9 @@ int vb21_verify_data(const void *data,
* @param wb Work buffer
* @return VB2_SUCCESS, or non-zero error code if error.
*/
-int vb21_verify_keyblock(struct vb21_keyblock *block,
- uint32_t size,
- const struct vb2_public_key *key,
- const struct vb2_workbuf *wb);
+vb2_error_t vb21_verify_keyblock(struct vb21_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.
@@ -176,10 +171,10 @@ int vb21_verify_keyblock(struct vb21_keyblock *block,
* @param wb Work buffer
* @return VB2_SUCCESS, or non-zero error code if error.
*/
-int vb21_verify_fw_preamble(struct vb21_fw_preamble *preamble,
- uint32_t size,
- const struct vb2_public_key *key,
- const struct vb2_workbuf *wb);
+vb2_error_t vb21_verify_fw_preamble(struct vb21_fw_preamble *preamble,
+ uint32_t size,
+ const struct vb2_public_key *key,
+ const struct vb2_workbuf *wb);
#ifdef __cplusplus
}
diff --git a/firmware/lib21/misc.c b/firmware/lib21/misc.c
index c1d0169c..de7d4477 100644
--- a/firmware/lib21/misc.c
+++ b/firmware/lib21/misc.c
@@ -28,15 +28,15 @@
* @param buf_ptr Destination for object pointer
* @return VB2_SUCCESS, or error code on error.
*/
-static int vb21_read_resource_object(struct vb2_context *ctx,
- enum vb2_resource_index index,
- uint32_t offset,
- struct vb2_workbuf *wb,
- void **buf_ptr)
+static vb2_error_t vb21_read_resource_object(struct vb2_context *ctx,
+ enum vb2_resource_index index,
+ uint32_t offset,
+ struct vb2_workbuf *wb,
+ void **buf_ptr)
{
struct vb21_struct_common c;
void *buf;
- int rv;
+ vb2_error_t rv;
*buf_ptr = NULL;
@@ -62,7 +62,7 @@ static int vb21_read_resource_object(struct vb2_context *ctx,
return VB2_SUCCESS;
}
-int vb21_load_fw_keyblock(struct vb2_context *ctx)
+vb2_error_t vb21_load_fw_keyblock(struct vb2_context *ctx)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
struct vb2_gbb_header *gbb = vb2_get_gbb(ctx);
@@ -74,7 +74,7 @@ int vb21_load_fw_keyblock(struct vb2_context *ctx)
struct vb2_public_key root_key;
struct vb21_keyblock *kb;
- int rv;
+ vb2_error_t rv;
vb2_workbuf_from_ctx(ctx, &wb);
@@ -155,7 +155,7 @@ int vb21_load_fw_keyblock(struct vb2_context *ctx)
return VB2_SUCCESS;
}
-int vb21_load_fw_preamble(struct vb2_context *ctx)
+vb2_error_t vb21_load_fw_preamble(struct vb2_context *ctx)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
struct vb2_gbb_header *gbb = vb2_get_gbb(ctx);
@@ -168,7 +168,7 @@ int vb21_load_fw_preamble(struct vb2_context *ctx)
/* Preamble goes in the next unused chunk of work buffer */
struct vb21_fw_preamble *pre;
- int rv;
+ vb2_error_t rv;
vb2_workbuf_from_ctx(ctx, &wb);
diff --git a/firmware/lib21/packed_key.c b/firmware/lib21/packed_key.c
index 71248dd4..b962da9e 100644
--- a/firmware/lib21/packed_key.c
+++ b/firmware/lib21/packed_key.c
@@ -10,9 +10,8 @@
#include "2rsa.h"
#include "vb21_common.h"
-int vb2_unpack_key_data(struct vb2_public_key *key,
- const uint8_t *key_data,
- uint32_t key_size)
+vb2_error_t vb2_unpack_key_data(struct vb2_public_key *key,
+ const uint8_t *key_data, uint32_t key_size)
{
const uint32_t *buf32 = (const uint32_t *)key_data;
uint32_t expected_key_size = vb2_packed_key_size(key->sig_alg);
@@ -42,15 +41,14 @@ int vb2_unpack_key_data(struct vb2_public_key *key,
return VB2_SUCCESS;
}
-int vb21_unpack_key(struct vb2_public_key *key,
- const uint8_t *buf,
- uint32_t size)
+vb2_error_t vb21_unpack_key(struct vb2_public_key *key, const uint8_t *buf,
+ uint32_t size)
{
const struct vb21_packed_key *pkey =
(const struct vb21_packed_key *)buf;
uint32_t sig_size;
uint32_t min_offset = 0;
- int rv;
+ vb2_error_t rv;
/* Check magic number */
if (pkey->c.magic != VB21_MAGIC_PACKED_KEY)
diff --git a/firmware/stub/vboot_api_stub.c b/firmware/stub/vboot_api_stub.c
index 8d4719e9..bc2aa59f 100644
--- a/firmware/stub/vboot_api_stub.c
+++ b/firmware/stub/vboot_api_stub.c
@@ -162,7 +162,7 @@ enum VbEcBootMode_t VbGetMode(void)
return vboot_mode;
}
-int VbExLegacy(enum VbAltFwIndex_t altfw_num)
+vb2_error_t VbExLegacy(enum VbAltFwIndex_t altfw_num)
{
return 1;
}