summaryrefslogtreecommitdiff
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
parentc1eafa1b656e698d6894559ba70c1dd27c4b459c (diff)
downloadrockbox-505f37e1b89402c76cc18bc2d13dc63707a0bff5.tar.gz
rockbox-505f37e1b89402c76cc18bc2d13dc63707a0bff5.zip
sbtools: various little fixes, mostly cosmetics
Change-Id: Ic53ef0283bdaee8d3272f648b71eff567b25059b
-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)
252 } 252 }
253} 253}
254 254
255bool sb1_is_key_valid_fast(void *buffer, size_t size, union xorcrypt_key_t _key[2]) 255/* Quick and dirty way to check a key is valid.
256 * We don't do any form of format checking because we are trying to bruteforce
257 * the key anyway. Assume buffer is of size SECTOR_SIZE */
258bool sb1_is_key_valid_fast(void *buffer, union xorcrypt_key_t _key[2])
256{ 259{
257 struct sb1_header_t *header = (struct sb1_header_t *)buffer; 260 struct sb1_header_t *header = (struct sb1_header_t *)buffer;
258
259 union xorcrypt_key_t key[2]; 261 union xorcrypt_key_t key[2];
260 262
261 uint8_t sector[SECTOR_SIZE]; 263 uint8_t sector[SECTOR_SIZE];
@@ -312,7 +314,7 @@ bool sb1_brute_force(const char *filename, void *u, sb1_color_printf cprintf,
312 for(int j = 0; j < 32; j++) 314 for(int j = 0; j < 32; j++)
313 printf(YELLOW, " %08x", key->u.xor_key[j / 16].k[j % 16]); 315 printf(YELLOW, " %08x", key->u.xor_key[j / 16].k[j % 16]);
314 } 316 }
315 if(sb1_is_key_valid_fast(sector, SECTOR_SIZE, key->u.xor_key)) 317 if(sb1_is_key_valid_fast(sector, key->u.xor_key))
316 { 318 {
317 if(g_debug) 319 if(g_debug)
318 printf(RED, " Ok\n"); 320 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
154struct sb1_file_t *sb1_read_memory(void *buffer, size_t size, void *u, 154struct sb1_file_t *sb1_read_memory(void *buffer, size_t size, void *u,
155 sb1_color_printf printf, enum sb1_error_t *err); 155 sb1_color_printf printf, enum sb1_error_t *err);
156 156
157/* do as little checks as possible, make sure the image is valid (advance use only) */ 157/* do as little checks as possible, make sure the image is valid (advance use only).
158bool sb1_is_key_valid_fast(void *buffer, size_t size, union xorcrypt_key_t key[2]); 158 * Buffer should be of size SECTOR_SIZE at least. */
159bool sb1_is_key_valid_fast(void *buffer, union xorcrypt_key_t key[2]);
159bool sb1_brute_force(const char *filename, void *u, sb1_color_printf printf, 160bool sb1_brute_force(const char *filename, void *u, sb1_color_printf printf,
160 enum sb1_error_t *err, struct crypto_key_t *key); 161 enum sb1_error_t *err, struct crypto_key_t *key);
161 162
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)
217{ 217{
218 printf("Usage: sbtoelf [options] sb-file\n"); 218 printf("Usage: sbtoelf [options] sb-file\n");
219 printf("Options:\n"); 219 printf("Options:\n");
220 printf(" -?/--help\tDisplay this message\n"); 220 printf(" -?/--help Display this message\n");
221 printf(" -o <prefix>\tEnable output and set prefix\n"); 221 printf(" -o <prefix> Enable output and set prefix\n");
222 printf(" -d/--debug\tEnable debug output*\n"); 222 printf(" -d/--debug Enable debug output*\n");
223 printf(" -k <file>\tAdd key file\n"); 223 printf(" -k <file> Add key file\n");
224 printf(" -z\t\tAdd zero key\n"); 224 printf(" -z Add zero key\n");
225 printf(" -r\t\tUse raw command mode\n"); 225 printf(" -r Use raw command mode\n");
226 printf(" -a/--add-key <key>\tAdd single key (hex or usbotp)\n"); 226 printf(" -a/--add-key <key> Add single key (hex or usbotp)\n");
227 printf(" -n/--no-color\tDisable output colors\n"); 227 printf(" -n/--no-color Disable output colors\n");
228 printf(" -l/--loopback <file>\tProduce sb file out of extracted description*\n"); 228 printf(" -l/--loopback <file> Produce sb file out of extracted description*\n");
229 printf(" -f/--force\tForce reading even without a key*\n"); 229 printf(" -f/--force Force reading even without a key*\n");
230 printf(" -1/--v1\tForce to read file as a version 1 file\n"); 230 printf(" -1/--v1 Force to read file as a version 1 file\n");
231 printf(" -2/--v2\tForce to read file as a version 2 file\n"); 231 printf(" -2/--v2 Force to read file as a version 2 file\n");
232 printf(" -s/--no-simpl\tPrevent elf files from being simplified*\n"); 232 printf(" -s/--no-simpl Prevent elf files from being simplified*\n");
233 printf(" -x\t\tUse default sb1 key\n"); 233 printf(" -x Use default sb1 key\n");
234 printf(" -b\tBrute force key\n"); 234 printf(" -b Brute force key\n");
235 printf("Options marked with a * are for debug purpose only\n"); 235 printf("Options marked with a * are for debug purpose only\n");
236 exit(1); 236 exit(1);
237} 237}