Skip to content

Fix reverse dependency core Updater -> library ESP8266WiFi #6398

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 5 commits into from
Aug 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 5 additions & 6 deletions cores/esp8266/Updater.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "Updater.h"
#include "Arduino.h"
#include "eboot_command.h"
#include <esp8266_peri.h>

Expand All @@ -11,10 +10,10 @@
#endif

#if ARDUINO_SIGNING
#include "../../libraries/ESP8266WiFi/src/BearSSLHelpers.h"
static BearSSL::PublicKey signPubKey(signing_pubkey);
static BearSSL::HashSHA256 hash;
static BearSSL::SigningVerifier sign(&signPubKey);
namespace esp8266 {
extern UpdaterHashClass& updaterSigningHash;
extern UpdaterVerifyClass& updaterSigningVerifier;
}
#endif

extern "C" {
Expand All @@ -39,7 +38,7 @@ UpdaterClass::UpdaterClass()
, _progress_callback(nullptr)
{
#if ARDUINO_SIGNING
installSignature(&hash, &sign);
installSignature(&esp8266::updaterSigningHash, &esp8266::updaterSigningVerifier);
#endif
}

Expand Down
20 changes: 19 additions & 1 deletion libraries/ESP8266WiFi/src/BearSSLHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include "BearSSLHelpers.h"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the move of this include before the others?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use this idiom as good practice to ensure that headers are self contained - I don't want other people having to find out the hard way that some header dependencies must be manually resolved each time.

#include <memory>
#include <vector>
#include <bearssl/bearssl.h>
Expand All @@ -28,7 +29,10 @@
#include <string.h>
#include <Arduino.h>
#include <StackThunk.h>
#include "BearSSLHelpers.h"
#include <Updater_Signing.h>
#ifndef ARDUINO_SIGNING
#define ARDUINO_SIGNING 0
#endif

namespace brssl {
// Code here is pulled from brssl sources, with the copyright and license
Expand Down Expand Up @@ -901,3 +905,17 @@ make_stack_thunk(br_ssl_engine_sendrec_buf);
#endif

};

#if ARDUINO_SIGNING
namespace {
static BearSSL::PublicKey signingPubKey(signing_pubkey);
static BearSSL::HashSHA256 __signingHash;
static BearSSL::SigningVerifier __signingVerifier(&signingPubKey);
};

namespace esp8266 {
UpdaterHashClass& updaterSigningHash = __signingHash;
UpdaterVerifyClass& updaterSigningVerifier = __signingVerifier;
};
#endif

1 change: 0 additions & 1 deletion libraries/ESP8266WiFi/src/BearSSLHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include <bearssl/bearssl.h>
#include <Updater.h>


// Internal opaque structures, not needed by user applications
namespace brssl {
class public_key;
Expand Down