|
24 | 24 |
|
25 | 25 | #include "FlashSHA256.h"
|
26 | 26 |
|
27 |
| -#include "../../tls/utility/SHA256.h" |
| 27 | +#include <SHA256.h> |
28 | 28 |
|
29 | 29 | #include <Arduino_DebugUtils.h>
|
30 | 30 |
|
|
38 | 38 |
|
39 | 39 | String FlashSHA256::calc(uint32_t const start_addr, uint32_t const max_flash_size)
|
40 | 40 | {
|
41 |
| - SHA256 sha256; |
| 41 | + SHA256Class sha256; |
42 | 42 | uint8_t chunk [FLASH_READ_CHUNK_SIZE],
|
43 | 43 | next_chunk[FLASH_READ_CHUNK_SIZE];
|
44 | 44 |
|
45 |
| - sha256.begin(); |
| 45 | + sha256.beginHash(); |
46 | 46 |
|
47 | 47 | /* Read the first two chunks of flash. */
|
48 | 48 | uint32_t flash_addr = start_addr;
|
@@ -75,27 +75,28 @@ String FlashSHA256::calc(uint32_t const start_addr, uint32_t const max_flash_siz
|
75 | 75 | break;
|
76 | 76 | }
|
77 | 77 | /* Update with the remaining bytes. */
|
78 |
| - sha256.update(chunk, valid_bytes_in_chunk); |
| 78 | + sha256.write(chunk, valid_bytes_in_chunk); |
79 | 79 | bytes_read += valid_bytes_in_chunk;
|
80 | 80 | break;
|
81 | 81 | }
|
82 | 82 |
|
83 | 83 | /* We've read a normal segment with the next segment not containing
|
84 | 84 | * any erased elements, just update the SHA256 hash calculation.
|
85 | 85 | */
|
86 |
| - sha256.update(chunk, FLASH_READ_CHUNK_SIZE); |
| 86 | + sha256.write(chunk, FLASH_READ_CHUNK_SIZE); |
87 | 87 | bytes_read += FLASH_READ_CHUNK_SIZE;
|
88 | 88 |
|
89 | 89 | /* Copy next_chunk to chunk. */
|
90 | 90 | memcpy(chunk, next_chunk, FLASH_READ_CHUNK_SIZE);
|
91 | 91 | }
|
92 | 92 |
|
93 | 93 | /* Retrieve the final hash string. */
|
94 |
| - uint8_t sha256_hash[SHA256::HASH_SIZE] = {0}; |
95 |
| - sha256.finalize(sha256_hash); |
| 94 | + uint8_t sha256_hash[SHA256_DIGEST_SIZE] = {0}; |
| 95 | + sha256.endHash(); |
| 96 | + sha256.readBytes(sha256_hash, SHA256_DIGEST_SIZE); |
96 | 97 | String sha256_str;
|
97 | 98 | std::for_each(sha256_hash,
|
98 |
| - sha256_hash + SHA256::HASH_SIZE, |
| 99 | + sha256_hash + SHA256_DIGEST_SIZE, |
99 | 100 | [&sha256_str](uint8_t const elem)
|
100 | 101 | {
|
101 | 102 | char buf[4];
|
|
0 commit comments