summaryrefslogtreecommitdiffstats
path: root/utils/imxtools/sbtools
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2013-06-17 13:58:59 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2013-06-17 13:58:59 +0200
commit505f37e1b89402c76cc18bc2d13dc63707a0bff5 (patch)
tree7ac0fb1e95797bb97792d817f0c1c0ddbe431660 /utils/imxtools/sbtools
parentc1eafa1b656e698d6894559ba70c1dd27c4b459c (diff)
downloadrockbox-505f37e1b89402c76cc18bc2d13dc63707a0bff5.tar.gz
rockbox-505f37e1b89402c76cc18bc2d13dc63707a0bff5.tar.bz2
rockbox-505f37e1b89402c76cc18bc2d13dc63707a0bff5.zip
sbtools: various little fixes, mostly cosmetics
Change-Id: Ic53ef0283bdaee8d3272f648b71eff567b25059b
Diffstat (limited to 'utils/imxtools/sbtools')
-rw-r--r--utils/imxtools/sbtools/sb1.c8
-rw-r--r--utils/imxtools/sbtools/sb1.h5
-rw-r--r--utils/imxtools/sbtools/sbtoelf.c30
3 files changed, 23 insertions, 20 deletions
diff --git a/utils/imxtools/sbtools/sb1.c b/utils/imxtools/sbtools/sb1.c
index bb9b3d5035..cbd3185103 100644
--- a/utils/imxtools/sbtools/sb1.c
+++ b/utils/imxtools/sbtools/sb1.c
@@ -252,10 +252,12 @@ static const char *sb1_datatype_name(int cmd)
}
}
-bool sb1_is_key_valid_fast(void *buffer, size_t size, union xorcrypt_key_t _key[2])
+/* Quick and dirty way to check a key is valid.
+ * We don't do any form of format checking because we are trying to bruteforce
+ * the key anyway. Assume buffer is of size SECTOR_SIZE */
+bool sb1_is_key_valid_fast(void *buffer, union xorcrypt_key_t _key[2])
{
struct sb1_header_t *header = (struct sb1_header_t *)buffer;
-
union xorcrypt_key_t key[2];
uint8_t sector[SECTOR_SIZE];
@@ -312,7 +314,7 @@ bool sb1_brute_force(const char *filename, void *u, sb1_color_printf cprintf,
for(int j = 0; j < 32; j++)
printf(YELLOW, " %08x", key->u.xor_key[j / 16].k[j % 16]);
}
- if(sb1_is_key_valid_fast(sector, SECTOR_SIZE, key->u.xor_key))
+ if(sb1_is_key_valid_fast(sector, key->u.xor_key))
{
if(g_debug)
printf(RED, " Ok\n");
diff --git a/utils/imxtools/sbtools/sb1.h b/utils/imxtools/sbtools/sb1.h
index 83ff0e7431..d5ab042c95 100644
--- a/utils/imxtools/sbtools/sb1.h
+++ b/utils/imxtools/sbtools/sb1.h
@@ -154,8 +154,9 @@ struct sb1_file_t *sb1_read_file_ex(const char *filename, size_t offset, size_t
struct sb1_file_t *sb1_read_memory(void *buffer, size_t size, void *u,
sb1_color_printf printf, enum sb1_error_t *err);
-/* do as little checks as possible, make sure the image is valid (advance use only) */
-bool sb1_is_key_valid_fast(void *buffer, size_t size, union xorcrypt_key_t key[2]);
+/* do as little checks as possible, make sure the image is valid (advance use only).
+ * Buffer should be of size SECTOR_SIZE at least. */
+bool sb1_is_key_valid_fast(void *buffer, union xorcrypt_key_t key[2]);
bool sb1_brute_force(const char *filename, void *u, sb1_color_printf printf,
enum sb1_error_t *err, struct crypto_key_t *key);
diff --git a/utils/imxtools/sbtools/sbtoelf.c b/utils/imxtools/sbtools/sbtoelf.c
index 75dc58e4bd..69ab59e44d 100644
--- a/utils/imxtools/sbtools/sbtoelf.c
+++ b/utils/imxtools/sbtools/sbtoelf.c
@@ -217,21 +217,21 @@ static void usage(void)
{
printf("Usage: sbtoelf [options] sb-file\n");
printf("Options:\n");
- printf(" -?/--help\tDisplay this message\n");
- printf(" -o <prefix>\tEnable output and set prefix\n");
- printf(" -d/--debug\tEnable debug output*\n");
- printf(" -k <file>\tAdd key file\n");
- printf(" -z\t\tAdd zero key\n");
- printf(" -r\t\tUse raw command mode\n");
- printf(" -a/--add-key <key>\tAdd single key (hex or usbotp)\n");
- printf(" -n/--no-color\tDisable output colors\n");
- printf(" -l/--loopback <file>\tProduce sb file out of extracted description*\n");
- printf(" -f/--force\tForce reading even without a key*\n");
- printf(" -1/--v1\tForce to read file as a version 1 file\n");
- printf(" -2/--v2\tForce to read file as a version 2 file\n");
- printf(" -s/--no-simpl\tPrevent elf files from being simplified*\n");
- printf(" -x\t\tUse default sb1 key\n");
- printf(" -b\tBrute force key\n");
+ printf(" -?/--help Display this message\n");
+ printf(" -o <prefix> Enable output and set prefix\n");
+ printf(" -d/--debug Enable debug output*\n");
+ printf(" -k <file> Add key file\n");
+ printf(" -z Add zero key\n");
+ printf(" -r Use raw command mode\n");
+ printf(" -a/--add-key <key> Add single key (hex or usbotp)\n");
+ printf(" -n/--no-color Disable output colors\n");
+ printf(" -l/--loopback <file> Produce sb file out of extracted description*\n");
+ printf(" -f/--force Force reading even without a key*\n");
+ printf(" -1/--v1 Force to read file as a version 1 file\n");
+ printf(" -2/--v2 Force to read file as a version 2 file\n");
+ printf(" -s/--no-simpl Prevent elf files from being simplified*\n");
+ printf(" -x Use default sb1 key\n");
+ printf(" -b Brute force key\n");
printf("Options marked with a * are for debug purpose only\n");
exit(1);
}