Skip to content

Commit b3b7477

Browse files
Earle F. Philhower, IIIEarle F. Philhower, III
Earle F. Philhower, III
authored and
Earle F. Philhower, III
committed
Move to new BearSSL:: namespace for classes
1 parent 3f1013e commit b3b7477

File tree

5 files changed

+23
-23
lines changed

5 files changed

+23
-23
lines changed

Diff for: cores/esp8266/Updater.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414
#if ARDUINO_SIGNING
1515
#include "../../libraries/ESP8266WiFi/src/BearSSLHelpers.h"
16-
static BearSSLPublicKey signPubKey(signing_pubkey);
17-
static BearSSLHashSHA256 hash;
18-
static BearSSLSigningVerifier sign(&signPubKey);
16+
static BearSSL::PublicKey signPubKey(signing_pubkey);
17+
static BearSSL::HashSHA256 hash;
18+
static BearSSL::SigningVerifier sign(&signPubKey);
1919
#endif
2020

2121
extern "C" {

Diff for: doc/ota_updates/readme.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ Users may also manually sign executables and require the OTA process to verify t
110110
.. code:: cpp
111111
112112
<in globals>
113-
BearSSLPublicKey signPubKey( ... key contents ... );
114-
BearSSLHashSHA256 hash;
115-
BearSSLSigningVerifier sign( &signPubKey );
113+
BearSSL::PublicKey signPubKey( ... key contents ... );
114+
BearSSL::HashSHA256 hash;
115+
BearSSL::SigningVerifier sign( &signPubKey );
116116
...
117117
<in setup()>
118118
Update.installSignature( &hash, &sign );

Diff for: libraries/ESP8266WiFi/src/BearSSLHelpers.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -826,29 +826,29 @@ bool X509List::append(const uint8_t *derCert, size_t derLen) {
826826
}
827827

828828
// SHA256 hash for updater
829-
void BearSSLHashSHA256::begin() {
829+
void HashSHA256::begin() {
830830
br_sha256_init( &_cc );
831831
memset( _sha256, 0, sizeof(_sha256) );
832832
}
833833

834-
void BearSSLHashSHA256::add(const void *data, uint32_t len) {
834+
void HashSHA256::add(const void *data, uint32_t len) {
835835
br_sha256_update( &_cc, data, len );
836836
}
837837

838-
void BearSSLHashSHA256::end() {
838+
void HashSHA256::end() {
839839
br_sha256_out( &_cc, _sha256 );
840840
}
841841

842-
int BearSSLHashSHA256::len() {
842+
int HashSHA256::len() {
843843
return sizeof(_sha256);
844844
}
845845

846-
const void *BearSSLHashSHA256::hash() {
846+
const void *HashSHA256::hash() {
847847
return (const void*) _sha256;
848848
}
849849

850850
// SHA256 verifier
851-
uint32_t BearSSLSigningVerifier::length()
851+
uint32_t SigningVerifier::length()
852852
{
853853
if (!_pubKey) {
854854
return 0;
@@ -861,7 +861,7 @@ uint32_t BearSSLSigningVerifier::length()
861861
}
862862
}
863863

864-
bool BearSSLSigningVerifier::verify(UpdaterHashClass *hash, const void *signature, uint32_t signatureLen) {
864+
bool SigningVerifier::verify(UpdaterHashClass *hash, const void *signature, uint32_t signatureLen) {
865865
if (!_pubKey || !hash || !signature || signatureLen != length()) return false;
866866

867867
if (_pubKey->isRSA()) {

Diff for: libraries/ESP8266WiFi/src/BearSSLHelpers.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class Session {
139139
};
140140

141141
// Updater SHA256 hash and signature verification
142-
class BearSSLHashSHA256 : public UpdaterHashClass {
142+
class HashSHA256 : public UpdaterHashClass {
143143
public:
144144
virtual void begin() override;
145145
virtual void add(const void *data, uint32_t len) override;
@@ -151,16 +151,16 @@ class BearSSLHashSHA256 : public UpdaterHashClass {
151151
unsigned char _sha256[32];
152152
};
153153

154-
class BearSSLSigningVerifier : public UpdaterVerifyClass {
154+
class SigningVerifier : public UpdaterVerifyClass {
155155
public:
156156
virtual uint32_t length() override;
157157
virtual bool verify(UpdaterHashClass *hash, const void *signature, uint32_t signatureLen) override;
158158

159159
public:
160-
BearSSLSigningVerifier(BearSSLPublicKey *pubKey) { _pubKey = pubKey; }
160+
SigningVerifier(PublicKey *pubKey) { _pubKey = pubKey; }
161161

162162
private:
163-
BearSSLPublicKey *_pubKey;
163+
PublicKey *_pubKey;
164164
};
165165

166166
};

Diff for: libraries/ESP8266httpUpdate/examples/httpUpdateSigned/httpUpdateSigned.ino

+6-6
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ TQIDAQAB
4040
-----END PUBLIC KEY-----
4141
)EOF";
4242
#if MANUAL_SIGNING
43-
BearSSLPublicKey *signPubKey = nullptr;
44-
BearSSLHashSHA256 *hash;
45-
BearSSLSigningVerifier *sign;
43+
BearSSL::PublicKey *signPubKey = nullptr;
44+
BearSSL::HashSHA256 *hash;
45+
BearSSL::SigningVerifier *sign;
4646
#endif
4747

4848
void setup() {
@@ -64,9 +64,9 @@ void setup() {
6464
WiFiMulti.addAP("SSID", "PASS");
6565

6666
#if MANUAL_SIGNING
67-
signPubKey = new BearSSLPublicKey(pubkey);
68-
hash = new BearSSLHashSHA256();
69-
sign = new BearSSLSigningVerifier(signPubKey);
67+
signPubKey = new BearSSL::PublicKey(pubkey);
68+
hash = new BearSSL::HashSHA256();
69+
sign = new BearSSL::SigningVerifier(signPubKey);
7070
#endif
7171
}
7272

0 commit comments

Comments
 (0)