diff options
| author | Amaury Pouly <amaury.pouly@gmail.com> | 2016-10-27 23:06:16 +0200 |
|---|---|---|
| committer | Amaury Pouly <amaury.pouly@gmail.com> | 2016-10-27 23:06:16 +0200 |
| commit | 37f95f67fec2b2460903ffa5255b1beeba1731fd (patch) | |
| tree | 6a932718139104406ab576ba89065c53f8dd20e7 /utils/nwztools/upgtools/mg.cpp | |
| parent | 794104dd17a28a2db09ca1ed44ba7dfb18a1f0ca (diff) | |
| download | rockbox-37f95f67fec2b2460903ffa5255b1beeba1731fd.zip rockbox-37f95f67fec2b2460903ffa5255b1beeba1731fd.tar.gz rockbox-37f95f67fec2b2460903ffa5255b1beeba1731fd.tar.bz2 rockbox-37f95f67fec2b2460903ffa5255b1beeba1731fd.tar.xz | |
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.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/utils/nwztools/upgtools/mg.cpp b/utils/nwztools/upgtools/mg.cpp index 21659ff..f02b673 100644 --- a/utils/nwztools/upgtools/mg.cpp +++ b/utils/nwztools/upgtools/mg.cpp @@ -28,24 +28,23 @@ using namespace CryptoPP; namespace { - ECB_Mode< DES >::Decryption g_dec; - ECB_Mode< DES >::Encryption g_enc; - inline int dec_des_ecb(void *in, int size, void *out, uint8_t *key) { + ECB_Mode< DES >::Decryption dec; if(size % 8) return 42; - g_dec.SetKey(key, 8); - g_dec.ProcessData((byte*)out, (byte*)in, size); + dec.SetKey(key, 8); + dec.ProcessData((byte*)out, (byte*)in, size); return 0; } inline int enc_des_ecb(void *in, int size, void *out, uint8_t *key) { + ECB_Mode< DES >::Encryption enc; if(size % 8) return 42; - g_enc.SetKey(key, 8); - g_enc.ProcessData((byte*)out, (byte*)in, size); + enc.SetKey(key, 8); + enc.ProcessData((byte*)out, (byte*)in, size); return 0; } } |