Skip to content

Commit 14c7551

Browse files
author
nils
committed
Release the lock in mbedtls_sha256_free if it was not released already. Requires making pico_sha256_unlock include-able. Fixes #2103.
1 parent f0a1ff3 commit 14c7551

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/rp2_common/pico_mbedtls/pico_mbedtls.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ void mbedtls_sha256_init(__unused mbedtls_sha256_context *ctx) {
3636
}
3737

3838
void mbedtls_sha256_free(__unused mbedtls_sha256_context *ctx) {
39+
if (ctx->locked) {
40+
pico_sha256_unlock(ctx);
41+
}
3942
}
4043

4144
int mbedtls_sha256_starts_ret(mbedtls_sha256_context *ctx, int is224) {

src/rp2_common/pico_sha256/include/pico/sha256.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ typedef struct pico_sha256_state {
5858
size_t total_data_size;
5959
} pico_sha256_state_t;
6060

61+
/*! \brief Release the internal lock on the SHA256 hardware
62+
* \ingroup pico_sha256
63+
*
64+
* Release the internal lock on the hardware.
65+
* Fails if the internal lock was not claimed.
66+
*
67+
* @param state A pointer to a pico_sha256_state_t instance
68+
*/
69+
void __weak pico_sha256_unlock(pico_sha256_state_t *state);
70+
6171
/*! \brief Start a SHA-256 calculation returning immediately with an error if the SHA-256 hardware is not available
6272
* \ingroup pico_sha256
6373
*

0 commit comments

Comments
 (0)