File tree 4 files changed +23
-40
lines changed
4 files changed +23
-40
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ void setup() {
15
15
Serial.begin (9600 );
16
16
while (!Serial);
17
17
18
- uint8_t sha[SHA256::HASH_SIZE ];
18
+ uint8_t sha[SHA256_DIGEST_SIZE ];
19
19
20
20
SHA256 sha256;
21
21
sha256.begin ();
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ namespace arduino { namespace bpid {
38
38
if (!get (data, sizeof (data))) {
39
39
return String (" " );
40
40
}
41
- uint8_t out[SHA256::HASH_SIZE ];
41
+ uint8_t out[SHA256_DIGEST_SIZE ];
42
42
arduino::sha256::sha256 (data, sizeof (data), out);
43
43
return arduino::hex::encode (out, sizeof (out));
44
44
}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 12
12
13
13
#include " sha2.h"
14
14
15
- class SHA256 {
16
-
17
- public:
18
-
19
- static constexpr uint32_t HASH_SIZE = SHA256_DIGEST_SIZE;
20
-
21
- void begin ();
22
- void update (uint8_t const * data, uint32_t const len);
23
- void finalize (uint8_t * hash);
24
-
25
- private:
26
-
27
- sha256_ctx _ctx;
28
- };
29
-
30
15
namespace arduino { namespace sha256 {
31
16
32
17
inline void begin (sha256_ctx * ctx) {
@@ -42,4 +27,25 @@ namespace arduino { namespace sha256 {
42
27
::sha256 (input, ilen, output);
43
28
}
44
29
30
+ class SHA256 {
31
+ public:
32
+
33
+ inline void begin () {
34
+ return arduino::sha256::begin (&_ctx);
35
+ }
36
+ inline void update (uint8_t const * data, uint32_t const len) {
37
+ return arduino::sha256::update (&_ctx, data, len);
38
+ }
39
+ inline void finalize (uint8_t * hash) {
40
+ return arduino::sha256::finalize (&_ctx, hash);
41
+ }
42
+ static inline void sha256 (uint8_t const * data, uint32_t const len, uint8_t * hash) {
43
+ return arduino::sha256::sha256 (data, len, hash);
44
+ }
45
+
46
+ private:
47
+
48
+ sha256_ctx _ctx;
49
+ };
50
+
45
51
}} // arduino::sha256
You can’t perform that action at this time.
0 commit comments