summaryrefslogtreecommitdiff
path: root/firmware/lib21/api.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/lib21/api.c')
-rw-r--r--firmware/lib21/api.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/firmware/lib21/api.c b/firmware/lib21/api.c
index 59448695..d9a955e7 100644
--- a/firmware/lib21/api.c
+++ b/firmware/lib21/api.c
@@ -52,10 +52,10 @@ vb2_error_t vb21api_init_hash(struct vb2_context *ctx,
vb2_workbuf_from_ctx(ctx, &wb);
/* Get preamble pointer */
- if (!sd->workbuf_preamble_size)
+ if (!sd->preamble_size)
return VB2_ERROR_API_INIT_HASH_PREAMBLE;
pre = (const struct vb21_fw_preamble *)
- (ctx->workbuf + sd->workbuf_preamble_offset);
+ vb2_member_of(sd, sd->preamble_offset);
/* Find the matching signature */
hash_offset = pre->hash_offset;
@@ -72,9 +72,9 @@ vb2_error_t vb21api_init_hash(struct vb2_context *ctx,
return VB2_ERROR_API_INIT_HASH_ID; /* No match */
/* Allocate workbuf space for the hash */
- if (sd->workbuf_hash_size) {
+ if (sd->hash_size) {
dc = (struct vb2_digest_context *)
- (ctx->workbuf + sd->workbuf_hash_offset);
+ vb2_member_of(sd, sd->hash_offset);
} else {
uint32_t dig_size = sizeof(*dc);
@@ -82,12 +82,12 @@ vb2_error_t vb21api_init_hash(struct vb2_context *ctx,
if (!dc)
return VB2_ERROR_API_INIT_HASH_WORKBUF;
- sd->workbuf_hash_offset = vb2_offset_of(ctx->workbuf, dc);
- sd->workbuf_hash_size = dig_size;
- vb2_set_workbuf_used(ctx, sd->workbuf_hash_offset + dig_size);
+ sd->hash_offset = vb2_offset_of(sd, dc);
+ sd->hash_size = dig_size;
+ vb2_set_workbuf_used(ctx, sd->hash_offset + dig_size);
}
- sd->hash_tag = vb2_offset_of(ctx->workbuf, sig);
+ sd->hash_tag = vb2_offset_of(sd, sig);
sd->hash_remaining_size = sig->data_size;
if (size)
@@ -117,7 +117,7 @@ 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 *)
- (ctx->workbuf + sd->workbuf_hash_offset);
+ vb2_member_of(sd, sd->hash_offset);
struct vb2_workbuf wb;
uint8_t *digest;
@@ -132,10 +132,10 @@ vb2_error_t vb21api_check_hash(struct vb2_context *ctx)
/* Get signature pointer */
if (!sd->hash_tag)
return VB2_ERROR_API_CHECK_HASH_TAG;
- sig = (const struct vb21_signature *)(ctx->workbuf + sd->hash_tag);
+ sig = vb2_member_of(sd, sd->hash_tag);
/* Must have initialized hash digest work area */
- if (!sd->workbuf_hash_size)
+ if (!sd->hash_size)
return VB2_ERROR_API_CHECK_HASH_WORKBUF;
/* Should have hashed the right amount of data */