File tree 2 files changed +29
-1
lines changed
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;
33
33
34
34
void SHA256::begin ()
35
35
{
36
+ #if defined(HAS_BEARSSL)
36
37
br_sha256_init (&_ctx);
38
+ #else
39
+ mbedtls_sha256_init (&_ctx);
40
+ mbedtls_sha256_starts (&_ctx, 0 );
41
+ #endif
37
42
}
38
43
39
44
void SHA256::update (uint8_t const * data, size_t const len)
40
45
{
46
+ #if defined(HAS_BEARSSL)
41
47
br_sha256_update (&_ctx, data, len);
48
+ #else
49
+ mbedtls_sha256_update (&_ctx, data, len);
50
+ #endif
42
51
}
43
52
44
53
void SHA256::finalize (uint8_t * hash)
45
54
{
55
+ #if defined(HAS_BEARSSL)
46
56
br_sha256_out (&_ctx, hash);
57
+ #else
58
+ mbedtls_sha256_finish (&_ctx, hash);
59
+ #endif
47
60
}
Original file line number Diff line number Diff line change 21
21
/* *****************************************************************************
22
22
* INCLUDE
23
23
******************************************************************************/
24
+ #include < AIoTC_Config.h>
24
25
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
26
37
27
38
/* *****************************************************************************
28
39
* CLASS DECLARATION
@@ -41,7 +52,11 @@ class SHA256
41
52
42
53
private:
43
54
55
+ #if defined(HAS_BEARSSL)
44
56
br_sha256_context _ctx;
57
+ #else
58
+ mbedtls_sha256_context _ctx;
59
+ #endif
45
60
46
61
};
47
62
You can’t perform that action at this time.
0 commit comments