Skip to content

Commit d375716

Browse files
committed
Fix comments and formatting
1 parent 78f2efd commit d375716

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

libraries/Update/examples/HTTP_Client_AES_OTA_Update/HTTP_Client_AES_OTA_Update.ino

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/*
2-
An example of how to use HTTpClient to download an encrypted and plain image files OTA from a web server.
2+
An example of how to use HTTPClient to download an encrypted and plain image files OTA from a web server.
33
This example uses Wifi & HTTPClient to connect to webserver and two functions for obtaining firmware image from webserver.
44
One uses the example 'updater.php' code on server to check and/or send relavent download firmware image file,
55
the other directly downloads the firmware file from web server.
66
77
To use:-
8-
Make a folder/directory on your webserve where your firmware images will be uploaded to. ie. /firmware
8+
Make a folder/directory on your webserver where your firmware images will be uploaded to. ie. /firmware
99
The 'updater.php' file can also be uploaded to the same folder. Edit and change definitions in 'update.php' to suit your needs.
1010
In sketch:
11-
set HTTPUPDATE_HOST to domain name or IP address if on LAN of your web server
11+
set HTTPUPDATE_HOST to domain name or IP address if on LAN of your web server
1212
set HTTPUPDATE_UPDATER_URI to path and file to call 'updater.php'
1313
or set HTTPUPDATE_DIRECT_URI to path and firmware file to download
1414
edit other HTTPUPDATE_ as needed
@@ -35,7 +35,8 @@ OTA_MODE options:-
3535
3636
https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/
3737
38-
espsecure.py encrypt_flash_data -k ota_key.bin --flash_crypt_conf 0xf -a 0x1000 -o output_filename.bin source_filename.bin
38+
Example:
39+
espsecure.py encrypt_flash_data -k ota_key.bin --flash_crypt_conf 0xf -a 0x4320 -o output_filename.bin source_filename.bin
3940
4041
espsecure.py encrypt_flash_data = runs the idf encryption function to make a encrypted output file from a source file
4142
-k text = path/filename to the AES 256bit(32byte) encryption key file
@@ -69,7 +70,7 @@ const uint8_t OTA_KEY[32] = {'0', '1', '2', '3', '4', '5', '6', '7',
6970
*/
7071

7172
//const uint8_t OTA_KEY[33] = "0123456789 this a simpletest key";
72-
73+
7374
const uint32_t OTA_ADDRESS = 0x4320;
7475
const uint32_t OTA_CFG = 0x0f;
7576
const uint32_t OTA_MODE = U_AES_DECRYPT_AUTO;
@@ -242,7 +243,7 @@ bool http_updater(const String& host, const uint16_t& port, String uri, const bo
242243
if(!download){
243244
Serial.printf( "Found V%s Firmware\n", http.header("version").c_str() );
244245
}else{
245-
Serial.printf( "Downloading & Installing V%s Firmware\n", http.header("version").c_str() );
246+
Serial.printf( "Downloading & Installing V%s Firmware\n", http.header("version").c_str() );
246247
}
247248
if( !download || http_downloadUpdate(http) ){
248249
http.end(); //end connection

libraries/Update/src/Updater.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ bool UpdateClass::setCryptKey(const uint8_t *cryptKey){
212212
if(!_cryptKey){
213213
log_e("new failed");
214214
return false;
215-
}
215+
}
216216
memcpy(_cryptKey, cryptKey, ENCRYPTED_KEY_SIZE);
217217
return true;
218218
}
@@ -249,12 +249,12 @@ void UpdateClass::_cryptKeyTweak(size_t cryptAddress, uint8_t *tweaked_key){
249249
cryptAddress <<= 8; //bit23 shifted to bit31(MSB)
250250
while(pattern_idx < sizeof(pattern)){
251251
tweak = cryptAddress<<(23 - pattern[pattern_idx]); //bit shift for small patterns
252-
// tweak = rotl32(tweak,8 - bit_len);
252+
// alternative to: tweak = rotl32(tweak,8 - bit_len);
253253
tweak = (tweak<<(8 - bit_len)) | (tweak>>(24 + bit_len)); //rotate to line up with end of previous tweak bits
254254
bit_len += pattern[pattern_idx++] - 4; //add number of bits in next pattern(23-4 = 19bits = 23bit to 5bit)
255255
while(bit_len > 7){
256256
tweaked_key[key_idx++] ^= tweak; //XOR byte
257-
// tweak = rotl32(tweak, 8);
257+
// alternative to: tweak = rotl32(tweak, 8);
258258
tweak = (tweak<<8) | (tweak>>24); //compiler should optimize to use rotate(fast)
259259
bit_len -=8;
260260
}
@@ -300,8 +300,8 @@ bool UpdateClass::_decryptBuffer(){
300300
}
301301
if(_bufferLen%ENCRYPTED_BLOCK_SIZE !=0 ){
302302
log_e("buffer size error");
303-
return false;
304-
}
303+
return false;
304+
}
305305
if(!_cryptBuffer){
306306
_cryptBuffer = new (std::nothrow) uint8_t[ENCRYPTED_BLOCK_SIZE];
307307
}

0 commit comments

Comments
 (0)