File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -33,15 +33,28 @@ constexpr size_t SHA256::HASH_SIZE;
3333
3434void SHA256::begin ()
3535{
36+ #if defined(HAS_BEARSSL)
3637 br_sha256_init (&_ctx);
38+ #else
39+ mbedtls_sha256_init (&_ctx);
40+ mbedtls_sha256_starts (&_ctx, 0 );
41+ #endif
3742}
3843
3944void SHA256::update (uint8_t const * data, size_t const len)
4045{
46+ #if defined(HAS_BEARSSL)
4147 br_sha256_update (&_ctx, data, len);
48+ #else
49+ mbedtls_sha256_update (&_ctx, data, len);
50+ #endif
4251}
4352
4453void SHA256::finalize (uint8_t * hash)
4554{
55+ #if defined(HAS_BEARSSL)
4656 br_sha256_out (&_ctx, hash);
57+ #else
58+ mbedtls_sha256_finish (&_ctx, hash);
59+ #endif
4760}
Original file line number Diff line number Diff line change 2121/* *****************************************************************************
2222 * INCLUDE
2323 ******************************************************************************/
24+ #include < AIoTC_Config.h>
2425
25- #include " ../bearssl/bearssl_hash.h"
26+ #if defined(BOARD_HAS_OFFLOADED_ECCX08) || defined(BOARD_HAS_ECCX08)
27+ #define HAS_BEARSSL
28+ #else
29+ #define HAS_MBEDTLS
30+ #endif
31+
32+ #if defined(HAS_BEARSSL)
33+ #include < bearssl/bearssl_hash.h>
34+ #else
35+ #include < mbedtls/sha256.h>
36+ #endif
2637
2738/* *****************************************************************************
2839 * CLASS DECLARATION
@@ -41,7 +52,11 @@ class SHA256
4152
4253private:
4354
55+ #if defined(HAS_BEARSSL)
4456 br_sha256_context _ctx;
57+ #else
58+ mbedtls_sha256_context _ctx;
59+ #endif
4560
4661};
4762
You can’t perform that action at this time.
0 commit comments