summaryrefslogtreecommitdiff
path: root/utils/imxtools/sbtools/sb1.c
diff options
context:
space:
mode:
Diffstat (limited to 'utils/imxtools/sbtools/sb1.c')
-rw-r--r--utils/imxtools/sbtools/sb1.c8
1 files changed, 5 insertions, 3 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");