You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/ota_updates/readme.rst
+9-6
Original file line number
Diff line number
Diff line change
@@ -44,20 +44,20 @@ Make your own risk analysis and depending on application decide what library fun
44
44
Advanced Security - Signed Updates
45
45
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
46
46
47
-
While the above password-based security will dissuade casual hacking attempts, it is not highly secure. For applications where a higher level of security is needed, cryptographically signed OTA updates can be required. This is a significantly higher level of security for your application than the basic levels described above. It uses SHA256 hashing in place of MD5 (which is known to be cryptographically broken) and RSA-2048 bit level encryption to guarantee only the holder of a cryptographic private key can generate code accepted by the OTA update mechanisms.
47
+
While the above password-based security will dissuade casual hacking attempts, it is not highly secure. For applications where a higher level of security is needed, cryptographically signed OTA updates can be required. It uses SHA256 hashing in place of MD5 (which is known to be cryptographically broken) and RSA-2048 bit level encryption to guarantee only the holder of a cryptographic private key can generate code accepted by the OTA update mechanisms.
48
48
49
49
These are updates whose compiled binary are signed with a private key (held by the developer) and verified with a public key (stored in the application and available for all to see). The signing process computes a hash of the binary code, encrypts the hash with the developer's private key, and appends this encrypted hash to the binary that is uploaded (via OTA, web, or HTTP server). If the code is modified or replaced in any way by anyone by the developer with the key, the hash will not match and the ESP8266 will reject the upload and not accept it.
50
50
51
51
Cryptographic signing only protects against tampering of binaries delivered OTA. If someone has physical access they will always be able to flash the device over the serial port. Signing also does not encrypt anything but the hash (so that it can't be modified), so this does not provide protection for code inside the device. Again, if a user has physical access they can read out your program.
52
52
53
-
Securing your private key is paramount. The same private/public keypair needs to be used to sign binaries as the original upload. Loss of the private key associated with a binary means that you will not be able to OTA to update any of your devices in the field. Alternatively, if the private key is copied, then the copy can be used to sign binaries which will be accepted.
53
+
**Securing your private key is paramount. The same private/public keypair needs to be used to sign binaries as the original upload. Loss of the private key associated with a binary means that you will not be able to OTA to update any of your devices in the field. Alternatively, if the private key is copied, then the copy can be used to sign binaries which will be accepted.**
54
54
55
55
Signed Binary Format
56
56
^^^^^^^^^^^^^^^^^^^^
57
57
58
58
The format of a signed binary is compatible with the standard binary format, and can be uploaded to a non-signed ESP8266 via serial or OTA without any conditions. Note, however, that once an unsigned OTA app is overwritten by this signed version, further updates will require signing.
59
59
60
-
As shown below, the signed hash is appended to the unsigned binary followed by the total length of the signed hash and length dword (i.e. if the signed has was 64 bytes, then this uint32 will contain 64+4=68). This format allows for extensibility (such as adding in a CA-based validation scheme allowing multiple signing keys all based off of a trust anchor), and pull requests are always welcome.
60
+
As shown below, the signed hash is appended to the unsigned binary followed by the total length of the signed hash (i.e. if the signed has was 64 bytes, then this uint32 will contain 64). This format allows for extensibility (such as adding in a CA-based validation scheme allowing multiple signing keys all based off of a trust anchor), and pull requests are always welcome.
61
61
62
62
.. code::
63
63
@@ -83,24 +83,27 @@ The simplest way of implementing signing is to use the automatic mode. This mod
83
83
To enable this mode, just include `private.key` and `public.key` in the sketch `.ino` directory. The IDE will call a helper script (`tools/signing.py`) before the build begins to create a header to enable key validation using the given public key, and after the build process to actually do the signing, generating a `sketch.bin.signed` file. When OTA is enabled (ArduinoOTA, Web, or HTTP) the binary will only accept signed updates automatically.
84
84
85
85
When the signing process starts, the message:
86
+
86
87
.. code::
87
88
88
89
Enabling binary signing
89
90
90
91
Will appear in the IDE window before a compile is launched, and at the completion of the build the signed binary file well be displayed in the IDE build window as:
92
+
91
93
.. code::
92
94
93
95
Signed binary: /full/path/to/sketch.bin.signed
94
96
95
97
If you receive either of the following messages in the IDE window, the signing was not completed and you will need to verify the `public.key` and `private.key`:
98
+
96
99
.. code::
97
100
98
101
Not enabling binary signing
99
102
... or ...
100
103
Not signing the generated binary
101
104
102
-
Manual Signing
103
-
^^^^^^^^^^^^^^
105
+
Manual Signing Binaries
106
+
^^^^^^^^^^^^^^^^^^^^^^^
104
107
105
108
Users may also manually sign executables and require the OTA process to verify their signature. In the main code, before enabling any update methods, add the call:
106
109
@@ -116,7 +119,7 @@ Users may also manually sign executables and require the OTA process to verify t
116
119
117
120
The above snipped creates a BearSSL public key, a SHA256 hash verifier, and tells the Update object to use them to validate any updates it receives from any method.
118
121
119
-
Compile the sketch normally and, onve a `.bin` file is available, sign it using the signer script:
122
+
Compile the sketch normally and, once a `.bin` file is available, sign it using the signer script:
0 commit comments