Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-esp32
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-esp32
Commits
58bea5c1
Unverified
Commit
58bea5c1
authored
Feb 09, 2024
by
Lucas Saavedra Vaz
Committed by
GitHub
Feb 09, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix C2 compilation for Updater.cpp (#9228)
parent
f18b690d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
5 deletions
+15
-5
libraries/Update/src/Update.h
libraries/Update/src/Update.h
+0
-1
libraries/Update/src/Updater.cpp
libraries/Update/src/Updater.cpp
+15
-4
No files found.
libraries/Update/src/Update.h
View file @
58bea5c1
...
...
@@ -5,7 +5,6 @@
#include <MD5Builder.h>
#include <functional>
#include "esp_partition.h"
#include "aes/esp_aes.h"
#define UPDATE_ERROR_OK (0)
#define UPDATE_ERROR_WRITE (1)
...
...
libraries/Update/src/Updater.cpp
View file @
58bea5c1
...
...
@@ -3,6 +3,7 @@
#include "spi_flash_mmap.h"
#include "esp_ota_ops.h"
#include "esp_image_format.h"
#include "mbedtls/aes.h"
static
const
char
*
_err2str
(
uint8_t
_error
){
if
(
_error
==
UPDATE_ERROR_OK
){
...
...
@@ -312,17 +313,27 @@ bool UpdateClass::_decryptBuffer(){
uint8_t
tweaked_key
[
ENCRYPTED_KEY_SIZE
];
//tweaked crypt key
int
done
=
0
;
esp_aes_context
ctx
;
//initialize AES
esp_aes_init
(
&
ctx
);
/*
Mbedtls functions will be replaced with esp_aes functions when hardware acceleration is available
To Do:
Replace mbedtls for the cases where there's no hardware acceleration
*/
mbedtls_aes_context
ctx
;
//initialize AES
mbedtls_aes_init
(
&
ctx
);
while
((
_bufferLen
-
done
)
>=
ENCRYPTED_BLOCK_SIZE
){
for
(
int
i
=
0
;
i
<
ENCRYPTED_BLOCK_SIZE
;
i
++
)
_cryptBuffer
[(
ENCRYPTED_BLOCK_SIZE
-
1
)
-
i
]
=
_buffer
[
i
+
done
];
//reverse order 16 bytes to decrypt
if
(
((
_cryptAddress
+
_progress
+
done
)
%
ENCRYPTED_TWEAK_BLOCK_SIZE
)
==
0
||
done
==
0
){
_cryptKeyTweak
(
_cryptAddress
+
_progress
+
done
,
tweaked_key
);
//update tweaked crypt key
if
(
esp_aes_setkey
(
&
ctx
,
tweaked_key
,
256
)
){
if
(
mbedtls_aes_setkey_enc
(
&
ctx
,
tweaked_key
,
256
)
){
return
false
;
}
if
(
mbedtls_aes_setkey_dec
(
&
ctx
,
tweaked_key
,
256
)
){
return
false
;
}
}
if
(
esp_aes_crypt_ecb
(
&
ctx
,
ESP_AES_ENCRYPT
,
_cryptBuffer
,
_cryptBuffer
)
){
//use ESP
_AES_ENCRYPT to decrypt flash code
if
(
mbedtls_aes_crypt_ecb
(
&
ctx
,
MBEDTLS_AES_ENCRYPT
,
_cryptBuffer
,
_cryptBuffer
)
){
//use MBEDTLS
_AES_ENCRYPT to decrypt flash code
return
false
;
}
for
(
int
i
=
0
;
i
<
ENCRYPTED_BLOCK_SIZE
;
i
++
)
_buffer
[
i
+
done
]
=
_cryptBuffer
[(
ENCRYPTED_BLOCK_SIZE
-
1
)
-
i
];
//reverse order 16 bytes from decrypt
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment