Skip to content

Commit 7a41b87

Browse files
committed
OTA Portenta: fix sha256 using Arduino_BearSSL
1 parent 3dc5a1e commit 7a41b87

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/utility/ota/OTA-portenta-h7.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ String portenta_h7_getOTAImageSHA256()
101101
* communicated to the bootloader, that is by writing to the non-volatile
102102
* storage registers of the RTC.
103103
*/
104-
SHA256 sha256;
104+
SHA256Class sha256;
105105
uint32_t const app_start = 0x8040000;
106106
uint32_t const app_size = HAL_RTCEx_BKUPRead(&RTCHandle, RTC_BKP_DR3);
107107

108-
sha256.begin();
108+
sha256.beginHash();
109109
uint32_t b = 0;
110110
uint32_t bytes_read = 0; for(uint32_t a = app_start;
111111
bytes_read < app_size;
@@ -114,11 +114,13 @@ String portenta_h7_getOTAImageSHA256()
114114
/* Read the next chunk of memory. */
115115
memcpy(&b, reinterpret_cast<const void *>(a), sizeof(b));
116116
/* Feed it to SHA256. */
117-
sha256.update(reinterpret_cast<uint8_t *>(&b), sizeof(b));
117+
sha256.write(reinterpret_cast<uint8_t *>(&b), sizeof(b));
118118
}
119+
sha256.endHash();
119120
/* Retrieve the final hash string. */
120121
uint8_t sha256_hash[SHA256_DIGEST_SIZE] = {0};
121-
sha256.finalize(sha256_hash);
122+
sha256.readBytes(sha256_hash, SHA256_DIGEST_SIZE);
123+
122124
String sha256_str;
123125
std::for_each(sha256_hash,
124126
sha256_hash + SHA256_DIGEST_SIZE,

0 commit comments

Comments
 (0)