summaryrefslogtreecommitdiff
path: root/utils/nwztools/upgtools/mg.cpp
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2016-10-27 23:06:16 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2016-10-27 23:06:16 +0200
commit37f95f67fec2b2460903ffa5255b1beeba1731fd (patch)
tree6a932718139104406ab576ba89065c53f8dd20e7 /utils/nwztools/upgtools/mg.cpp
parent794104dd17a28a2db09ca1ed44ba7dfb18a1f0ca (diff)
downloadrockbox-37f95f67fec2b2460903ffa5255b1beeba1731fd.tar.gz
rockbox-37f95f67fec2b2460903ffa5255b1beeba1731fd.zip
nwztools/upgtools: rewrite keysig brute force search
The new search has two new features: - it takes advantage of the fact that DES keys are only 56-bit long (and not 64) - it is now multithreaded As a proof of concept, I ran it on the A10 series firmware upgrade and was able to find the key in a few seconds using 4 threads. The search is still limited to ascii hex passwords (seems to work on all devices I have tried thus far). Change-Id: Ied080286d2bbdc493a6ceaecaaadba802b429666
Diffstat (limited to 'utils/nwztools/upgtools/mg.cpp')
-rw-r--r--utils/nwztools/upgtools/mg.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/utils/nwztools/upgtools/mg.cpp b/utils/nwztools/upgtools/mg.cpp
index 21659ff3cf..f02b67375a 100644
--- a/utils/nwztools/upgtools/mg.cpp
+++ b/utils/nwztools/upgtools/mg.cpp
@@ -28,24 +28,23 @@
28using namespace CryptoPP; 28using namespace CryptoPP;
29namespace 29namespace
30{ 30{
31 ECB_Mode< DES >::Decryption g_dec;
32 ECB_Mode< DES >::Encryption g_enc;
33
34 inline int dec_des_ecb(void *in, int size, void *out, uint8_t *key) 31 inline int dec_des_ecb(void *in, int size, void *out, uint8_t *key)
35 { 32 {
33 ECB_Mode< DES >::Decryption dec;
36 if(size % 8) 34 if(size % 8)
37 return 42; 35 return 42;
38 g_dec.SetKey(key, 8); 36 dec.SetKey(key, 8);
39 g_dec.ProcessData((byte*)out, (byte*)in, size); 37 dec.ProcessData((byte*)out, (byte*)in, size);
40 return 0; 38 return 0;
41 } 39 }
42 40
43 inline int enc_des_ecb(void *in, int size, void *out, uint8_t *key) 41 inline int enc_des_ecb(void *in, int size, void *out, uint8_t *key)
44 { 42 {
43 ECB_Mode< DES >::Encryption enc;
45 if(size % 8) 44 if(size % 8)
46 return 42; 45 return 42;
47 g_enc.SetKey(key, 8); 46 enc.SetKey(key, 8);
48 g_enc.ProcessData((byte*)out, (byte*)in, size); 47 enc.ProcessData((byte*)out, (byte*)in, size);
49 return 0; 48 return 0;
50 } 49 }
51} 50}