forked from len0rd/rockbox
imxtools/sbtools: rework cryptography
It was a mess, a mix of crypto_* and cbc_mac calls. I made everything call crypto functions, and also separate key setup from cryptographic operations, this will be useful to speed up the code in the upcoming commits. Drop support for "usbotp" key, since the crypto code for that was never mainlined and we can always get the keys from a device as long as we have code execution (using the DCP debug registers). Change-Id: I7aa24d12207ffb744225d1b9cc7cb1dc7281dd22
This commit is contained in:
parent
cb8a98e365
commit
2b20026dd7
10 changed files with 172 additions and 319 deletions
|
@ -118,7 +118,6 @@ 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
|
||||
* CRYPTO_XOR_KEY: 256 hex characters */
|
||||
if(isxdigit(str[0]) && strlen(str) >= 256 && isxdigit(str[32]))
|
||||
{
|
||||
|
@ -151,30 +150,7 @@ bool parse_key(char **pstr, struct crypto_key_t *key)
|
|||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *prefix = "usbotp(";
|
||||
if(strlen(str) < strlen(prefix))
|
||||
return false;
|
||||
if(strncmp(str, prefix, strlen(prefix)) != 0)
|
||||
return false;
|
||||
str += strlen(prefix);
|
||||
/* vid */
|
||||
long vid = strtol(str, &str, 16);
|
||||
if(vid < 0 || vid > 0xffff)
|
||||
return false;
|
||||
if(*str++ != ':')
|
||||
return false;
|
||||
/* pid */
|
||||
long pid = strtol(str, &str, 16);
|
||||
if(pid < 0 || pid > 0xffff)
|
||||
return false;
|
||||
if(*str++ != ')')
|
||||
return false;
|
||||
*pstr = str;
|
||||
key->method = CRYPTO_USBOTP;
|
||||
key->u.vid_pid = vid << 16 | pid;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void add_keys(key_array_t ka, int kac)
|
||||
|
@ -278,9 +254,6 @@ void print_key(void *user, misc_printf_t printf, struct crypto_key_t *key, bool
|
|||
case CRYPTO_KEY:
|
||||
print_hex(user, printf, key->u.key, 16, false);
|
||||
break;
|
||||
case CRYPTO_USBOTP:
|
||||
printf(user, "USB-OTP(%04x:%04x)", key->u.vid_pid >> 16, key->u.vid_pid & 0xffff);
|
||||
break;
|
||||
case CRYPTO_NONE:
|
||||
printf(user, "none");
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue