Skip to content

Commit 51f11c1

Browse files
committed
OTA: use sha256 from ArduinoBearSSL
1 parent 1727756 commit 51f11c1

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/ota/interface/OTAInterface.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ OTACloudProcessInterface::State OTACloudProcessInterface::otaBegin() {
108108
OtaBeginUpId,
109109
};
110110

111-
SHA256 sha256_calc;
111+
SHA256Class sha256_calc;
112112
calculateSHA256(sha256_calc);
113113

114-
sha256_calc.finalize(sha256);
115-
memcpy(msg.params.sha, sha256, SHA256::HASH_SIZE);
114+
sha256_calc.endHash();
115+
sha256_calc.readBytes(msg.params.sha, SHA256_DIGEST_SIZE);
116116

117117
DEBUG_VERBOSE("calculated SHA256: "
118118
"0x%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X"
@@ -128,15 +128,15 @@ OTACloudProcessInterface::State OTACloudProcessInterface::otaBegin() {
128128
return Idle;
129129
}
130130

131-
void OTACloudProcessInterface::calculateSHA256(SHA256& sha256_calc) {
131+
void OTACloudProcessInterface::calculateSHA256(SHA256Class& sha256_calc) {
132132
auto res = appFlashOpen();
133133
if(!res) {
134134
// TODO return error
135135
return;
136136
}
137137

138-
sha256_calc.begin();
139-
sha256_calc.update(
138+
sha256_calc.beginHash();
139+
sha256_calc.write(
140140
reinterpret_cast<const uint8_t*>(appStartAddress()),
141141
appSize());
142142
appFlashClose();

src/ota/interface/OTAInterface.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
#if OTA_ENABLED
2020
#include "../OTATypes.h"
21-
#include "tls/utility/SHA256.h"
21+
#include <SHA256.h>
2222

2323
#include <interfaces/CloudProcess.h>
2424
#include <Arduino_DebugUtils.h>
@@ -156,10 +156,10 @@ class OTACloudProcessInterface: public CloudProcess {
156156
virtual bool appFlashClose() = 0;
157157

158158
// sha256 is going to be used in the ota process for validation, avoid calculating it twice
159-
uint8_t sha256[SHA256::HASH_SIZE];
159+
uint8_t sha256[SHA256_DIGEST_SIZE];
160160

161161
// calculateSHA256 method is overridable for platforms that do not support access through pointer to program memory
162-
virtual void calculateSHA256(SHA256&); // FIXME return error
162+
virtual void calculateSHA256(SHA256Class&); // FIXME return error
163163
private:
164164
void clean();
165165

0 commit comments

Comments
 (0)