summaryrefslogtreecommitdiffstats
path: root/utils/nwztools/upgtools/keysig_search.c
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2020-06-13 16:21:16 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2020-10-11 13:08:03 +0200
commit53d2742a482eba04fab02a5f1b8a5b2fa48206e2 (patch)
tree10f04b099fad6bd3bb42b597f536c0a247fc10ab /utils/nwztools/upgtools/keysig_search.c
parentcda16f9439359c79c4d8f54f63b0cdb10dc79bfb (diff)
downloadrockbox-53d2742a48.tar.gz
rockbox-53d2742a48.tar.bz2
rockbox-53d2742a48.zip
nwztools: add support for new UPG format on post-WM1/A30 devices
The new code supports reading and writing UPG files. I kept the old keysig search code but it only supports the old format (the new format has too long keys anyway). Since we now have to support two types of encryption(DES and AES), I reorganized the crypto routines and clean-up some code. Change-Id: Ie9be220ec2431ec6d0bd11699fa0493b62e1cec2
Diffstat (limited to 'utils/nwztools/upgtools/keysig_search.c')
-rw-r--r--utils/nwztools/upgtools/keysig_search.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/utils/nwztools/upgtools/keysig_search.c b/utils/nwztools/upgtools/keysig_search.c
index 2f234d6358..c16dae5260 100644
--- a/utils/nwztools/upgtools/keysig_search.c
+++ b/utils/nwztools/upgtools/keysig_search.c
@@ -218,11 +218,10 @@ typedef bool (*sig_validate_fn_t)(uint8_t *key);
static bool check_key(uint8_t key[NWZ_KEY_SIZE], sig_validate_fn_t validate)
{
struct upg_header_t hdr;
- mg_decrypt_fw(g_keysig_search.enc_buf, sizeof(hdr.sig), (void *)&hdr, key);
+ mg_decrypt_fw(g_keysig_search.enc_buf, sizeof(hdr), (void *)&hdr, key);
if(validate(hdr.sig))
{
- /* the signature looks correct, so decrypt the header futher to be sure */
- mg_decrypt_fw(g_keysig_search.enc_buf, sizeof(hdr), (void *)&hdr, key);
+ /* the signature looks correct, so check the header to be sure */
/* we expect the number of files to be small and the padding to be 0 */
if(hdr.nr_files == 0 || hdr.nr_files > 10 || hdr.pad != 0)
return false;