summaryrefslogtreecommitdiffstats
path: root/utils/imxtools/sbtools/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'utils/imxtools/sbtools/misc.c')
-rw-r--r--utils/imxtools/sbtools/misc.c19
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)
while(isspace(*str))
str++;
/* CRYPTO_KEY: 32 hex characters
- * CRYPTO_USBOTP: usbotp(vid:pid) where vid and pid are hex numbers */
- if(isxdigit(str[0]))
+ * CRYPTO_USBOTP: usbotp(vid:pid) where vid and pid are hex numbers
+ * CRYPTO_XOR_KEY: 256 hex characters */
+ if(isxdigit(str[0]) && strlen(str) >= 256 && isxdigit(str[32]))
+ {
+ for(int j = 0; j < 128; j++)
+ {
+ byte a, b;
+ if(convxdigit(str[2 * j], &a) || convxdigit(str[2 * j + 1], &b))
+ return false;
+ key->u.xor_key[j / 64].key[j % 64] = (a << 4) | b;
+ }
+ /* skip key */
+ *pstr = str + 256;
+ key->method = CRYPTO_XOR_KEY;
+ return true;
+ }
+ else if(isxdigit(str[0]))
{
if(strlen(str) < 32)
return false;