diff options
author | Felix Fietkau <nbd@openwrt.org> | 2015-10-12 13:11:03 +0000 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2015-10-12 13:11:03 +0000 |
commit | 772e2c0a77b5ef3748f40028ca76df6134d5ee49 (patch) | |
tree | 352e7d77ced8305bdfca43f1ed03b8df7b0ebe11 /tools/firmware-utils | |
parent | d57bba8560a320571607215ada556a1ab3eadea9 (diff) | |
download | mtk-20170518-772e2c0a77b5ef3748f40028ca76df6134d5ee49.zip mtk-20170518-772e2c0a77b5ef3748f40028ca76df6134d5ee49.tar.gz mtk-20170518-772e2c0a77b5ef3748f40028ca76df6134d5ee49.tar.bz2 |
firmware-utils/buffalo-enc: add support for decrypting data with an offset
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
SVN-Revision: 47185
Diffstat (limited to 'tools/firmware-utils')
-rw-r--r-- | tools/firmware-utils/src/buffalo-enc.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/tools/firmware-utils/src/buffalo-enc.c b/tools/firmware-utils/src/buffalo-enc.c index 59b66ab..794659e 100644 --- a/tools/firmware-utils/src/buffalo-enc.c +++ b/tools/firmware-utils/src/buffalo-enc.c @@ -34,6 +34,7 @@ static unsigned char seed = 'O'; static char *product; static char *version; static int do_decrypt; +static int offset; void usage(int status) { @@ -52,6 +53,7 @@ void usage(int status) " -p <product> set product name to <product>\n" " -v <version> set version to <version>\n" " -h show this screen\n" +" -O Offset of encrypted data in file (decryption)\n" ); exit(status); @@ -87,7 +89,7 @@ static int decrypt_file(void) ep.key = (unsigned char *) crypt_key; ep.longstate = longstate; - err = decrypt_buf(&ep, buf, src_len); + err = decrypt_buf(&ep, buf + offset, src_len - offset); if (err) { ERR("unable to decrypt '%s'", ifname); goto out; @@ -100,7 +102,7 @@ static int decrypt_file(void) printf("Data len\t: %u\n", ep.datalen); 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) { ERR("unable to write to file '%s'", ofname); goto out; @@ -239,7 +241,7 @@ int main(int argc, char *argv[]) while ( 1 ) { 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) break; @@ -271,6 +273,9 @@ int main(int argc, char *argv[]) case 's': seed = strtoul(optarg, NULL, 16); break; + case 'O': + offset = strtoul(optarg, NULL, 0); + break; case 'h': usage(EXIT_SUCCESS); break; |