summaryrefslogtreecommitdiffstats
path: root/utils/nwztools/upgtools/mg.h
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/mg.h
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/mg.h')
-rw-r--r--utils/nwztools/upgtools/mg.h26
1 files changed, 21 insertions, 5 deletions
diff --git a/utils/nwztools/upgtools/mg.h b/utils/nwztools/upgtools/mg.h
index ef8dcd5ecb..fe6ec7c2f6 100644
--- a/utils/nwztools/upgtools/mg.h
+++ b/utils/nwztools/upgtools/mg.h
@@ -26,11 +26,27 @@
#ifdef __cplusplus
extern "C" {
#endif
-/* size must be a multiple of 8 */
-void mg_decrypt_fw(void *in, int size, void *out, uint8_t *key);
-void mg_encrypt_fw(void *in, int size, void *out, uint8_t *key);
-void mg_decrypt_pass(void *in, int size, void *out, uint8_t *key);
-void mg_encrypt_pass(void *in, int size, void *out, uint8_t *key);
+/* size must be a multiple of 8, this function is thread-safe */
+void mg_decrypt_fw(void *in, int size, void *out, uint8_t key[8]);
+
+/* for simplicity, these function use some global variables, this could be
+ * change if necessary in the future */
+
+/* DES: sizes must be a multiple of 8 */
+void des_ecb_dec_set_key(const uint8_t key[8]);
+void des_ecb_dec(void *in, int size, void *out);
+void des_ecb_enc_set_key(const uint8_t key[8]);
+void des_ecb_enc(void *in, int size, void *out);
+
+/* AES: size must be a multiple of 16 */
+void aes_ecb_dec_set_key(const uint8_t key[16]);
+void aes_ecb_dec(void *in, int size, void *out);
+void aes_ecb_enc_set_key(const uint8_t key[16]);
+void aes_ecb_enc(void *in, int size, void *out);
+void aes_cbc_dec_set_key_iv(const uint8_t key[16], const uint8_t iv[16]);
+void aes_cbc_dec(void *in, int size, void *out);
+void aes_cbc_enc_set_key_iv(const uint8_t key[16], const uint8_t iv[16]);
+void aes_cbc_enc(void *in, int size, void *out);
#ifdef __cplusplus
}
#endif