firmware-utils/buffalo-enc: add support for decrypting data with an offset
Signed-off-by: Felix Fietkau <nbd@openwrt.org> SVN-Revision: 47185
This commit is contained in:
parent
d57bba8560
commit
772e2c0a77
1 changed files with 8 additions and 3 deletions
|
@ -34,6 +34,7 @@ static unsigned char seed = 'O';
|
||||||
static char *product;
|
static char *product;
|
||||||
static char *version;
|
static char *version;
|
||||||
static int do_decrypt;
|
static int do_decrypt;
|
||||||
|
static int offset;
|
||||||
|
|
||||||
void usage(int status)
|
void usage(int status)
|
||||||
{
|
{
|
||||||
|
@ -52,6 +53,7 @@ void usage(int status)
|
||||||
" -p <product> set product name to <product>\n"
|
" -p <product> set product name to <product>\n"
|
||||||
" -v <version> set version to <version>\n"
|
" -v <version> set version to <version>\n"
|
||||||
" -h show this screen\n"
|
" -h show this screen\n"
|
||||||
|
" -O Offset of encrypted data in file (decryption)\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
exit(status);
|
exit(status);
|
||||||
|
@ -87,7 +89,7 @@ static int decrypt_file(void)
|
||||||
ep.key = (unsigned char *) crypt_key;
|
ep.key = (unsigned char *) crypt_key;
|
||||||
ep.longstate = longstate;
|
ep.longstate = longstate;
|
||||||
|
|
||||||
err = decrypt_buf(&ep, buf, src_len);
|
err = decrypt_buf(&ep, buf + offset, src_len - offset);
|
||||||
if (err) {
|
if (err) {
|
||||||
ERR("unable to decrypt '%s'", ifname);
|
ERR("unable to decrypt '%s'", ifname);
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -100,7 +102,7 @@ static int decrypt_file(void)
|
||||||
printf("Data len\t: %u\n", ep.datalen);
|
printf("Data len\t: %u\n", ep.datalen);
|
||||||
printf("Checksum\t: 0x%08x\n", ep.csum);
|
printf("Checksum\t: 0x%08x\n", ep.csum);
|
||||||
|
|
||||||
err = write_buf_to_file(ofname, buf, ep.datalen);
|
err = write_buf_to_file(ofname, buf + offset, ep.datalen);
|
||||||
if (err) {
|
if (err) {
|
||||||
ERR("unable to write to file '%s'", ofname);
|
ERR("unable to write to file '%s'", ofname);
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -239,7 +241,7 @@ int main(int argc, char *argv[])
|
||||||
while ( 1 ) {
|
while ( 1 ) {
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
c = getopt(argc, argv, "adi:m:o:hlp:v:k:r:s:");
|
c = getopt(argc, argv, "adi:m:o:hlp:v:k:O:r:s:");
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -271,6 +273,9 @@ int main(int argc, char *argv[])
|
||||||
case 's':
|
case 's':
|
||||||
seed = strtoul(optarg, NULL, 16);
|
seed = strtoul(optarg, NULL, 16);
|
||||||
break;
|
break;
|
||||||
|
case 'O':
|
||||||
|
offset = strtoul(optarg, NULL, 0);
|
||||||
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
usage(EXIT_SUCCESS);
|
usage(EXIT_SUCCESS);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue