diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2013-02-16 20:47:07 +0100 |
---|---|---|
committer | Amaury Pouly <amaury.pouly@gmail.com> | 2013-02-16 20:49:07 +0100 |
commit | b05b762ed45c6c8967fce098c598ec1a6ed7a533 (patch) | |
tree | ca704d48a3ac5acd8097d8485208f2f328766650 /utils/imxtools/sbtools/misc.c | |
parent | 4db4985f21bd8f36533f8e71db916e6d3d5d2249 (diff) | |
download | rockbox-b05b762ed45c6c8967fce098c598ec1a6ed7a533.tar.gz rockbox-b05b762ed45c6c8967fce098c598ec1a6ed7a533.zip |
sbtools: add brute force option for sb1 in sbtoelf
After some reverse engineering, it appears that the keys of the
sb1 format are very weak: the 128 bytes are generated from the
laserfuse words 4,5 and 6 but in a weird manner: 4 and 5 are
simply ORed and 6 is only half used (somehow), making it "only" a
48 bit word to find.
Change-Id: I40702e19d0924ef51c01894efce3cb65bd664456
Diffstat (limited to 'utils/imxtools/sbtools/misc.c')
-rw-r--r-- | utils/imxtools/sbtools/misc.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/utils/imxtools/sbtools/misc.c b/utils/imxtools/sbtools/misc.c index dae4f92121..b9f5d21f7e 100644 --- a/utils/imxtools/sbtools/misc.c +++ b/utils/imxtools/sbtools/misc.c | |||
@@ -117,8 +117,23 @@ bool parse_key(char **pstr, struct crypto_key_t *key) | |||
117 | while(isspace(*str)) | 117 | while(isspace(*str)) |
118 | str++; | 118 | str++; |
119 | /* CRYPTO_KEY: 32 hex characters | 119 | /* CRYPTO_KEY: 32 hex characters |
120 | * CRYPTO_USBOTP: usbotp(vid:pid) where vid and pid are hex numbers */ | 120 | * CRYPTO_USBOTP: usbotp(vid:pid) where vid and pid are hex numbers |
121 | if(isxdigit(str[0])) | 121 | * CRYPTO_XOR_KEY: 256 hex characters */ |
122 | if(isxdigit(str[0]) && strlen(str) >= 256 && isxdigit(str[32])) | ||
123 | { | ||
124 | for(int j = 0; j < 128; j++) | ||
125 | { | ||
126 | byte a, b; | ||
127 | if(convxdigit(str[2 * j], &a) || convxdigit(str[2 * j + 1], &b)) | ||
128 | return false; | ||
129 | key->u.xor_key[j / 64].key[j % 64] = (a << 4) | b; | ||
130 | } | ||
131 | /* skip key */ | ||
132 | *pstr = str + 256; | ||
133 | key->method = CRYPTO_XOR_KEY; | ||
134 | return true; | ||
135 | } | ||
136 | else if(isxdigit(str[0])) | ||
122 | { | 137 | { |
123 | if(strlen(str) < 32) | 138 | if(strlen(str) < 32) |
124 | return false; | 139 | return false; |