Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9c536eb
First cut at a readme.
dirkx Apr 19, 2020
048b476
Refactored the Updater to allow for a filter/processor (both
dirkx Apr 19, 2020
bc68418
Fix for MD parser github
dirkx Apr 19, 2020
91464ee
Add some output as an example
dirkx Apr 19, 2020
1f7a15c
Fix for GH markup
dirkx Apr 19, 2020
33ad4e3
Fix for GH markup 2
dirkx Apr 19, 2020
bb15994
Fix for case sensitive platforms
dirkx Apr 19, 2020
e7d35e8
Make it easier to cut-and-paste key.
dirkx Apr 20, 2020
00a578e
Trigger the watchdog at times - to not get hit by it during a network…
dirkx Apr 20, 2020
36731f3
Changes for PIO
dirkx Apr 20, 2020
0e235ff
Few tiny tweaks; add more debugging output and a more sensible error …
dirkx Jul 20, 2020
0e1cbd6
Clean up compiler warnings
dirkx Jul 20, 2020
be7122c
Fix return values to be in line with other _info calls, follow OpenSS…
dirkx Jul 20, 2020
d1fbe1d
Fix CMake framework
dirkx Jul 20, 2020
09fa18b
Fix/re-add MD5 checksum for plain uploads; also allow SHA256 and othe…
dirkx Jul 21, 2020
9ce71af
Fix exit code.
dirkx Jul 21, 2020
62cfb7e
Remove test key - to avoid confusion/superfluous alerts of scanning t…
dirkx Jul 21, 2020
7350023
Fix debugging output.
dirkx Jul 21, 2020
34fc641
Merge branch 'arduino-signed-updater' of https://github.com/dirkx/ard…
dirkx Jul 21, 2020
8494236
Reduce debug output; fix fingerprint printing.
dirkx Jul 25, 2020
e127327
Merge branch 'arduino-signed-updater' of https://github.com/dirkx/ard…
dirkx Jul 25, 2020
47c2af5
Separate out the updates; improve documentation, reintroduce the MD5 …
dirkx Jul 25, 2020
ce2b641
Fix CMakeList.txt
dirkx Jul 25, 2020
060c4c6
Fix CMakeList - file renamed to legacy.
dirkx Jul 25, 2020
60edc56
Fix CMakeList - file renamed to legacy 2.
dirkx Jul 25, 2020
0e54ded
Fix SD & HTTP upload builds; include new processer, fix erorr message.
dirkx Jul 26, 2020
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
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ set(LIBRARY_SRCS
libraries/SPI/src/SPI.cpp
libraries/Ticker/src/Ticker.cpp
libraries/Update/src/Updater.cpp
libraries/Update/src/UpdateProcessorLegacy.cpp
libraries/Update/src/UpdateProcessorRFC3161.cpp
libraries/Update/src/UpdateProcessorWithChecksum.cpp
libraries/Update/src/mbedtls-ts-addons/signer_info.cpp
libraries/Update/src/mbedtls-ts-addons/x509_ts_utils.cpp
libraries/Update/src/mbedtls-ts-addons/x509_crt_utils.cpp
libraries/Update/src/mbedtls-ts-addons/ts.cpp
libraries/WebServer/src/WebServer.cpp
libraries/WebServer/src/Parsing.cpp
libraries/WebServer/src/detail/mimetable.cpp
Expand Down Expand Up @@ -198,6 +205,7 @@ set(COMPONENT_ADD_INCLUDEDIRS
libraries/SPI/src
libraries/Ticker/src
libraries/Update/src
libraries/Update/src/mbedtls-ts-addons
libraries/WebServer/src
libraries/WiFiClientSecure/src
libraries/WiFi/src
Expand Down
79 changes: 79 additions & 0 deletions libraries/ArduinoOTA/examples/SecureOTA/SecureOTA.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#include <WiFi.h>
#include <ESPmDNS.h>
#include <WiFiUdp.h>
#include "ArduinoOTA.h"
#include "UpdateProcessor.h"
#include "UpdateProcessorRFC3161.h"

#include "hardcoded-roots.h"

UpdateProcessorRFC3161 rfcChecker = UpdateProcessorRFC3161();

void setup() {
Serial.begin(115200);
Serial.println("Booting " __DATE__ " " __TIME__);

WiFi.mode(WIFI_STA);
WiFi.begin("wifi-network", "password");
while (WiFi.waitForConnectResult() != WL_CONNECTED) {
Serial.println("Connection Failed! Rebooting...");
delay(5000);
ESP.restart();
}

// ArduinoOTA.setPort(3232);
// ArduinoOTA.setHostname("some-name");

// No authentication by default
// ArduinoOTA.setPassword(OTA_PASSWD);

// Specify a (root) signature we trust during
// updates.
rfcChecker.addTrustedCertAsDER(ca_interop_redwax_der, ca_interop_redwax_der_len);

// Allow unsiged uploads:
// rfcChecker.setAllowLegacyUploads(true); // default is not to allow this.

// Wire this check into the normal upload process.
//
ArduinoOTA.setProcessor(&rfcChecker);

ArduinoOTA
.onStart([]() {
String type;
if (ArduinoOTA.getCommand() == U_FLASH)
type = "sketch";
else // U_SPIFFS
type = "filesystem";

// NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end()
Serial.println("Updating " + type);
})
.onEnd([]() {
Serial.println(" Ok, completed without errors.");
})
.onError([](ota_error_t error) {
Serial.printf("\nAborted with error[%u]: ", error);
if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");
else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
else if (error == OTA_END_ERROR) Serial.println("End Failed");
});

ArduinoOTA.approveReboot([]() {
Serial.println("Reboot ok");
return true;
});

ArduinoOTA.begin();

Serial.println("Ready");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
}

void loop() {
ArduinoOTA.handle();
}

98 changes: 98 additions & 0 deletions libraries/ArduinoOTA/examples/SecureOTA/hardcoded-roots.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#include "hardcoded-roots.h"

/* Root/Certificate Authority (CA) used by the free/demo
* 'sign anything' server at: https://interop.redwax.eu/rs/timestamp/
*
* Encoded as 'DER' - can easily be (re)created with the 'xxd -i'
* tool on unix.
*/
const unsigned int ca_interop_redwax_der_len = 1041;
const unsigned char ca_interop_redwax_der[] = {
0x30, 0x82, 0x04, 0x0d, 0x30, 0x82, 0x02, 0xf5, 0xa0, 0x03, 0x02, 0x01,
0x02, 0x02, 0x14, 0x6f, 0x11, 0xb7, 0xd8, 0x55, 0xd2, 0x7d, 0x9a, 0x14,
0xf3, 0xb6, 0xe9, 0x15, 0x2b, 0x60, 0xca, 0x8c, 0x4b, 0xe2, 0xaa, 0x30,
0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05,
0x05, 0x00, 0x30, 0x5a, 0x31, 0x3f, 0x30, 0x3d, 0x06, 0x03, 0x55, 0x04,
0x03, 0x13, 0x36, 0x52, 0x65, 0x64, 0x77, 0x61, 0x78, 0x20, 0x49, 0x6e,
0x74, 0x65, 0x72, 0x6f, 0x70, 0x20, 0x54, 0x65, 0x73, 0x74, 0x69, 0x6e,
0x67, 0x20, 0x52, 0x6f, 0x6f, 0x74, 0x20, 0x43, 0x65, 0x72, 0x74, 0x69,
0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x20, 0x41, 0x75, 0x74, 0x68, 0x6f,
0x72, 0x69, 0x74, 0x79, 0x20, 0x32, 0x30, 0x34, 0x30, 0x31, 0x17, 0x30,
0x15, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x0e, 0x52, 0x65, 0x64, 0x77,
0x61, 0x78, 0x20, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x30, 0x1e,
0x17, 0x0d, 0x32, 0x30, 0x30, 0x32, 0x31, 0x31, 0x31, 0x36, 0x33, 0x38,
0x35, 0x36, 0x5a, 0x17, 0x0d, 0x34, 0x30, 0x30, 0x32, 0x30, 0x36, 0x31,
0x36, 0x33, 0x38, 0x35, 0x36, 0x5a, 0x30, 0x5a, 0x31, 0x3f, 0x30, 0x3d,
0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x36, 0x52, 0x65, 0x64, 0x77, 0x61,
0x78, 0x20, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6f, 0x70, 0x20, 0x54, 0x65,
0x73, 0x74, 0x69, 0x6e, 0x67, 0x20, 0x52, 0x6f, 0x6f, 0x74, 0x20, 0x43,
0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x20, 0x41,
0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x20, 0x32, 0x30, 0x34,
0x30, 0x31, 0x17, 0x30, 0x15, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x0e,
0x52, 0x65, 0x64, 0x77, 0x61, 0x78, 0x20, 0x50, 0x72, 0x6f, 0x6a, 0x65,
0x63, 0x74, 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86,
0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01,
0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xe7,
0x20, 0x27, 0x23, 0x18, 0x5f, 0x44, 0x70, 0x7d, 0x24, 0x46, 0xef, 0x53,
0x82, 0xa8, 0x97, 0x01, 0x5f, 0x98, 0x74, 0x15, 0x0e, 0x8d, 0x5e, 0x23,
0x1b, 0xdc, 0x02, 0x6c, 0x97, 0x59, 0x32, 0xfe, 0xad, 0x19, 0x85, 0x98,
0x20, 0xfb, 0x33, 0xac, 0xad, 0xc2, 0x9b, 0x0e, 0x3d, 0xb8, 0xc6, 0xcc,
0x80, 0x01, 0x0b, 0xfe, 0x10, 0x76, 0x9a, 0xbf, 0xe0, 0x64, 0x81, 0x4c,
0x43, 0x4a, 0xec, 0xd8, 0x65, 0xb0, 0x91, 0xa2, 0xa8, 0x96, 0xf8, 0x34,
0xaf, 0x0f, 0x60, 0x13, 0xc3, 0xf0, 0x47, 0x6a, 0x7a, 0x8e, 0xd8, 0x6e,
0x2f, 0xe0, 0xb3, 0xa1, 0xcc, 0x87, 0x91, 0xcd, 0xbb, 0x7f, 0xf5, 0x06,
0x85, 0xe9, 0x18, 0x4a, 0x76, 0xdc, 0x80, 0x88, 0xad, 0x14, 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cc, 0xc2, 0x2b, 0x56, 0x30, 0x81, 0x97,
0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x81, 0x8f, 0x30, 0x81, 0x8c, 0x80,
0x14, 0xed, 0x75, 0xde, 0x35, 0x14, 0x3c, 0x47, 0x23, 0xf1, 0xb1, 0x1a,
0xe4, 0x13, 0x43, 0x8c, 0xbb, 0xcc, 0xc2, 0x2b, 0x56, 0xa1, 0x5e, 0xa4,
0x5c, 0x30, 0x5a, 0x31, 0x3f, 0x30, 0x3d, 0x06, 0x03, 0x55, 0x04, 0x03,
0x13, 0x36, 0x52, 0x65, 0x64, 0x77, 0x61, 0x78, 0x20, 0x49, 0x6e, 0x74,
0x65, 0x72, 0x6f, 0x70, 0x20, 0x54, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67,
0x20, 0x52, 0x6f, 0x6f, 0x74, 0x20, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66,
0x69, 0x63, 0x61, 0x74, 0x65, 0x20, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72,
0x69, 0x74, 0x79, 0x20, 0x32, 0x30, 0x34, 0x30, 0x31, 0x17, 0x30, 0x15,
0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x0e, 0x52, 0x65, 0x64, 0x77, 0x61,
0x78, 0x20, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x82, 0x14, 0x6f,
0x11, 0xb7, 0xd8, 0x55, 0xd2, 0x7d, 0x9a, 0x14, 0xf3, 0xb6, 0xe9, 0x15,
0x2b, 0x60, 0xca, 0x8c, 0x4b, 0xe2, 0xaa, 0x30, 0x0c, 0x06, 0x03, 0x55,
0x1d, 0x13, 0x04, 0x05, 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, 0x0d, 0x06,
0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00,
0x03, 0x82, 0x01, 0x01, 0x00, 0xce, 0x34, 0xe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 0xd0,
0x93, 0xeb, 0xb3, 0x1e, 0xda, 0x00, 0x40, 0x5e, 0x04, 0xe6, 0x6c, 0x2b,
0x84, 0xd8, 0xee, 0x32, 0x7e, 0xaa, 0xd8, 0x23, 0x81, 0xf8, 0xcd, 0xb9,
0xe2, 0xef, 0xe9, 0x19, 0x0b, 0x22, 0xde, 0x2d, 0x4b, 0x33, 0x10, 0x43,
0x72, 0x1e, 0x40, 0x2a, 0xfc, 0x63, 0x3e, 0xc3, 0xb7, 0xa4, 0xb1, 0x62,
0xd6, 0x85, 0xaf, 0x90, 0x93, 0x40, 0xac, 0xac, 0x37, 0x0c, 0x92, 0xdc,
0x4e, 0x70, 0x90, 0x97, 0xb5, 0xa7, 0xe1, 0x9c, 0xd1
};
5 changes: 5 additions & 0 deletions libraries/ArduinoOTA/examples/SecureOTA/hardcoded-roots.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#ifndef _H_HARDCODED_CA
#define _H_HARDCODED_CA
extern const unsigned int ca_interop_redwax_der_len;
extern const unsigned char ca_interop_redwax_der[];
#endif
Loading