Skip to content

Commit

Permalink
bootutil/crypto: SHA256 abort function return state
Browse files Browse the repository at this point in the history
Similarly to what has been done for the init function, also
the abort function should return a state in case the caller
needs to implement some error recovery procedure, or even
just for debugging reasons.

Signed-off-by: Antonio de Angelis <[email protected]>
Change-Id: I5b8bc8fc2da57cfbc6ddea3f7e95ed7a7ae8e5a9
  • Loading branch information
adeaarm authored and davidvincze committed Jun 9, 2023
1 parent 0361ad3 commit a5db515
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions boot/bootutil/include/bootutil/crypto/sha256.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ static inline int bootutil_sha256_init(bootutil_sha256_context *ctx)
return (int)psa_hash_setup(ctx, PSA_ALG_SHA_256);
}

static inline void bootutil_sha256_drop(bootutil_sha256_context *ctx)
static inline int bootutil_sha256_drop(bootutil_sha256_context *ctx)
{
(void)psa_hash_abort(ctx);
return (int)psa_hash_abort(ctx);
}

static inline int bootutil_sha256_update(bootutil_sha256_context *ctx,
Expand Down Expand Up @@ -107,11 +107,12 @@ static inline int bootutil_sha256_init(bootutil_sha256_context *ctx)
return mbedtls_sha256_starts_ret(ctx, 0);
}

static inline void bootutil_sha256_drop(bootutil_sha256_context *ctx)
static inline int bootutil_sha256_drop(bootutil_sha256_context *ctx)
{
/* XXX: config defines MBEDTLS_PLATFORM_NO_STD_FUNCTIONS so no need to free */
/* (void)mbedtls_sha256_free(ctx); */
(void)ctx;
return 0;
}

static inline int bootutil_sha256_update(bootutil_sha256_context *ctx,
Expand All @@ -137,9 +138,10 @@ static inline int bootutil_sha256_init(bootutil_sha256_context *ctx)
return 0;
}

static inline void bootutil_sha256_drop(bootutil_sha256_context *ctx)
static inline int bootutil_sha256_drop(bootutil_sha256_context *ctx)
{
(void)ctx;
return 0;
}

static inline int bootutil_sha256_update(bootutil_sha256_context *ctx,
Expand All @@ -163,10 +165,11 @@ static inline int bootutil_sha256_init(bootutil_sha256_context *ctx)
return 0;
}

static inline void bootutil_sha256_drop(bootutil_sha256_context *ctx)
static inline int bootutil_sha256_drop(bootutil_sha256_context *ctx)
{
(void)ctx;
nrf_cc310_disable();
return 0;
}

static inline int bootutil_sha256_update(bootutil_sha256_context *ctx,
Expand Down

0 comments on commit a5db515

Please sign in to comment.