You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ut...@apache.org on 2021/02/19 10:57:11 UTC
[mynewt-core] branch master updated: hw: drivers: hash: fix Mbed
TLS md interface usage
This is an automated email from the ASF dual-hosted git repository.
utzig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
The following commit(s) were added to refs/heads/master by this push:
new 804035c hw: drivers: hash: fix Mbed TLS md interface usage
804035c is described below
commit 804035c8f6a1856d5f99c051058c353cb45afdba
Author: Fabio Utzig <ut...@apache.org>
AuthorDate: Fri Feb 19 06:49:55 2021 -0300
hw: drivers: hash: fix Mbed TLS md interface usage
Using the md interface in Mynewt when a HW hash driver is enabled fails
because SHA-224 is calling `mbedtls_internal_sha256_process` directly.
Since SHA-224 is not commonly used, add a placeholder to allow building.
Signed-off-by: Fabio Utzig <ut...@apache.org>
---
hw/drivers/hash/include/hash/sha256_alt.h | 8 +++++---
hw/drivers/hash/src/mbedtls_sha256_alt.c | 33 ++++++++++++++++++++++---------
2 files changed, 29 insertions(+), 12 deletions(-)
diff --git a/hw/drivers/hash/include/hash/sha256_alt.h b/hw/drivers/hash/include/hash/sha256_alt.h
index b594eba..1529c1f 100644
--- a/hw/drivers/hash/include/hash/sha256_alt.h
+++ b/hw/drivers/hash/include/hash/sha256_alt.h
@@ -38,12 +38,14 @@ typedef struct mbedtls_sha256_context {
void mbedtls_sha256_init(mbedtls_sha256_context *ctx);
void mbedtls_sha256_free(mbedtls_sha256_context *ctx);
void mbedtls_sha256_clone(mbedtls_sha256_context *dst,
- const mbedtls_sha256_context *src);
+ const mbedtls_sha256_context *src);
int mbedtls_sha256_starts_ret(mbedtls_sha256_context *ctx, int is224);
int mbedtls_sha256_update_ret(mbedtls_sha256_context *ctx,
- const unsigned char *input, size_t ilen);
+ const unsigned char *input, size_t ilen);
int mbedtls_sha256_finish_ret(mbedtls_sha256_context *ctx,
- unsigned char output[32]);
+ unsigned char output[32]);
+int mbedtls_internal_sha256_process(mbedtls_sha256_context *ctx,
+ const unsigned char data[64]);
/*
* XXX deprecated functions
diff --git a/hw/drivers/hash/src/mbedtls_sha256_alt.c b/hw/drivers/hash/src/mbedtls_sha256_alt.c
index 82b2af6..ac8a02c 100644
--- a/hw/drivers/hash/src/mbedtls_sha256_alt.c
+++ b/hw/drivers/hash/src/mbedtls_sha256_alt.c
@@ -42,7 +42,7 @@ mbedtls_sha256_free(mbedtls_sha256_context *ctx)
void
mbedtls_sha256_clone(mbedtls_sha256_context *dst,
- const mbedtls_sha256_context *src)
+ const mbedtls_sha256_context *src)
{
memcpy(dst, src, sizeof(*dst));
}
@@ -57,14 +57,16 @@ mbedtls_sha256_starts_ret(mbedtls_sha256_context *ctx, int is224)
return hash_sha256_start(&ctx->sha256ctx, ctx->hash);
}
-int mbedtls_sha256_update_ret(mbedtls_sha256_context *ctx,
- const unsigned char *input, size_t ilen)
+int
+mbedtls_sha256_update_ret(mbedtls_sha256_context *ctx,
+ const unsigned char *input, size_t ilen)
{
return hash_sha256_update(&ctx->sha256ctx, input, ilen);
}
-int mbedtls_sha256_finish_ret(mbedtls_sha256_context *ctx,
- unsigned char output[32])
+int
+mbedtls_sha256_finish_ret(mbedtls_sha256_context *ctx,
+ unsigned char output[32])
{
return hash_sha256_finish(&ctx->sha256ctx, output);
}
@@ -83,16 +85,29 @@ mbedtls_sha256_starts(mbedtls_sha256_context *ctx, int is224)
(void)hash_sha256_start(&ctx->sha256ctx, ctx->hash);
}
-void mbedtls_sha256_update(mbedtls_sha256_context *ctx,
- const unsigned char *input, size_t ilen)
+void
+mbedtls_sha256_update(mbedtls_sha256_context *ctx,
+ const unsigned char *input, size_t ilen)
{
(void)hash_sha256_update(&ctx->sha256ctx, input, ilen);
}
-void mbedtls_sha256_finish(mbedtls_sha256_context *ctx,
- unsigned char output[32])
+void
+mbedtls_sha256_finish(mbedtls_sha256_context *ctx,
+ unsigned char output[32])
{
(void)hash_sha256_finish(&ctx->sha256ctx, output);
}
+int
+mbedtls_internal_sha256_process(mbedtls_sha256_context *ctx,
+ const unsigned char data[64])
+{
+ /*
+ * Note: This function is only called by SHA-224 functions, only
+ * needed for building, shouldn't ever be called in practice.
+ */
+ assert(0);
+}
+
#endif /* MYNEWT_VAL(MBEDTLS_SHA256_ALT) */