8000 Add cryptographically signed update support by earlephilhower · Pull Request #5213 · esp8266/Arduino · GitHub
[go: up one dir, main page]

Skip to content

Add cryptographically signed update support #5213

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Dec 3, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
71bf243
Add cryptographically signed update support
earlephilhower Oct 6, 2018
ac25877
Add a simple example
earlephilhower Oct 6, 2018
882e546
Make verifier EC/RSA compatible at any bit length
earlephilhower Oct 6, 2018
29d8c63
Make certain hash bits constant
earlephilhower Oct 7, 2018
e33eb7d
Merge branch 'master' into signedupdates
d-a-v Oct 8, 2018
d9ce799
Merge branch 'master' into signedupdates
earlephilhower Oct 8, 2018
5fb8cd5
When update signed, don't do MD5 work or checking
earlephilhower Oct 10, 2018
b9344f6
Add python automatic signing if keys present
Oct 15, 2018
0ae91ae
Automatically include validation in updater
Oct 15, 2018
dd5c2b0
Merge branch 'master' into signedupdates
earlephilhower Oct 26, 2018
68f703e
Merge branch 'master' into signedupdates
earlephilhower Nov 5, 2018
9823290
Add documentation on signing process
Nov 5, 2018
3de43d6
Update documentation formatting
earlephilhower Nov 6, 2018
3f1013e
Merge branch 'master' into signedupdates
earlephilhower Nov 9, 2018
b3b7477
Move to new BearSSL:: namespace for classes
Nov 9, 2018
2b4016e
Merge branch 'master' into signedupdates
earlephilhower Nov 19, 2018
31b22fb
Move 2 strings into PROGMEM
earlephilhower Nov 29, 2018
b3ed528
Merge branch 'master' into signedupdates
earlephilhower Nov 29, 2018
4164bce
Add openssl return code error checking
earlephilhower Nov 29, 2018
5b2a882
Merge branch 'signedupdates' of https://github.com/earlephilhower/Ard…
earlephilhower Nov 29, 2018
e530a8a
Completely silence normal unsigned builds
earlephilhower Nov 29, 2018
5b243e2
Move debug strings to PMEM
earlephilhower Nov 29, 2018
f1eca3f
Merge branch 'master' into signedupdates
earlephilhower Nov 30, 2018
30e9d9b
Fix prebuild numbering, typo in docs
Nov 30, 2018
15ca564
Warn about Windows incompatibility in build and docs
earlephilhower Nov 30, 2018
d61a8ff
Merge branch 'master' into signedupdates
earlephilhower Dec 1, 2018
f9d340c
Merge branch 'master' into signedupdates
devyte Dec 3, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move to new BearSSL:: namespace for classes
  • Loading branch information
Earle F. Philhower, III authored and Earle F. Philhower, III committed Nov 9, 2018
commit b3b7477c3c96e65deee90d1cdcf5876f955494eb
6 changes: 3 additions & 3 deletions cores/esp8266/Updater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

#if ARDUINO_SIGNING
#include "../../libraries/ESP8266WiFi/src/BearSSLHelpers.h"
static BearSSLPublicKey signPubKey(signing_pubkey);
static BearSSLHashSHA256 hash;
static BearSSLSigningVerifier sign(&signPubKey);
static BearSSL::PublicKey signPubKey(signing_pubkey);
static BearSSL::HashSHA256 hash;
static BearSSL::SigningVerifier sign(&signPubKey);
#endif

extern "C" {
Expand Down
6 changes: 3 additions & 3 deletions doc/ota_updates/readme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ Users may also manually sign executables and require the OTA process to verify t
.. code:: cpp

<in globals>
BearSSLPublicKey signPubKey( ... key contents ... );
BearSSLHashSHA256 hash;
BearSSLSigningVerifier sign( &signPubKey );
BearSSL::PublicKey signPubKey( ... key contents ... );
BearSSL::HashSHA256 hash;
BearSSL::SigningVerifier sign( &signPubKey );
...
<in setup()>
Update.installSignature( &hash, &sign );
Expand Down
14 changes: 7 additions & 7 deletions libraries/ESP8266WiFi/src/BearSSLHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -826,29 +826,29 @@ bool X509List::append(const uint8_t *derCert, size_t derLen) {
}

// SHA256 hash for updater
void BearSSLHashSHA256::begin() {
void HashSHA256::begin() {
br_sha256_init( &_cc );
memset( _sha256, 0, sizeof(_sha256) );
}

void BearSSLHashSHA256::add(const void *data, uint32_t len) {
void HashSHA256::add(const void *data, uint32_t len) {
br_sha256_update( &_cc, data, len );
}

void BearSSLHashSHA256::end() {
void HashSHA256::end() {
br_sha256_out( &_cc, _sha256 );
}

int BearSSLHashSHA256::len() {
int HashSHA256::len() {
return sizeof(_sha256);
}

const void *BearSSLHashSHA256::hash() {
const void *HashSHA256::hash() {
return (const void*) _sha256;
}

// SHA256 verifier
uint32_t BearSSLSigningVerifier::length()
uint32_t SigningVerifier::length()
{
if (!_pubKey) {
return 0;
Expand All @@ -861,7 +861,7 @@ uint32_t BearSSLSigningVerifier::length()
}
}

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

if (_pubKey->isRSA()) {
Expand Down
8 changes: 4 additions & 4 deletions libraries/ESP8266WiFi/src/BearSSLHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class Session {
};

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

class BearSSLSigningVerifier : public UpdaterVerifyClass {
class SigningVerifier : public UpdaterVerifyClass {
public:
virtual uint32_t length() override;
virtual bool verify(UpdaterHashClass *hash, const void *signature, uint32_t signatureLen) override;

public:
BearSSLSigningVerifier(BearSSLPublicKey *pubKey) { _pubKey = pubKey; }
SigningVerifier(PublicKey *pubKey) { _pubKey = pubKey; }

private:
BearSSLPublicKey *_pubKey;
PublicKey *_pubKey;
};

};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ TQIDAQAB
-----END PUBLIC KEY-----
)EOF";
#if MANUAL_SIGNING
BearSSLPublicKey *signPubKey = nullptr;
BearSSLHashSHA256 *hash;
BearSSLSigningVerifier *sign;
BearSSL::PublicKey *signPubKey = nullptr;
BearSSL::HashSHA256 *hash;
BearSSL::SigningVerifier *sign;
#endif

void setup() {
Expand All @@ -64,9 +64,9 @@ void setup() {
WiFiMulti.addAP("SSID", "PASS");

#if MANUAL_SIGNING
signPubKey = new BearSSLPublicKey(pubkey);
hash = new BearSSLHashSHA256();
sign = new BearSSLSigningVerifier(signPubKey);
signPubKey = new BearSSL::PublicKey(pubkey);
hash = new BearSSL::HashSHA256();
sign = new BearSSL::SigningVerifier(signPubKey);
#endif
}

Expand Down
0