forked from len0rd/rockbox
sbtools,mkximboot: fix whitespace
Change-Id: I8d8adb783707172d1aaef302366c240310350ed8
This commit is contained in:
parent
58e27b9fa1
commit
7c7fa36918
16 changed files with 84 additions and 84 deletions
|
|
@ -145,7 +145,7 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
printf("Invalid variant '%s'\n", optarg);
|
printf("Invalid variant '%s'\n", optarg);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
Lok:
|
Lok:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ int crypto_apply(
|
||||||
{
|
{
|
||||||
if(out_cbc_mac && !encrypt)
|
if(out_cbc_mac && !encrypt)
|
||||||
memcpy(*out_cbc_mac, in_data + 16 * (nr_blocks - 1), 16);
|
memcpy(*out_cbc_mac, in_data + 16 * (nr_blocks - 1), 16);
|
||||||
|
|
||||||
libusb_device_handle *handle = NULL;
|
libusb_device_handle *handle = NULL;
|
||||||
libusb_context *ctx;
|
libusb_context *ctx;
|
||||||
/* init library */
|
/* init library */
|
||||||
|
|
@ -97,7 +97,7 @@ int crypto_apply(
|
||||||
printf("usbotp: configuration: %d\n", config_id);
|
printf("usbotp: configuration: %d\n", config_id);
|
||||||
printf("usbotp: interfaces: %d\n", config->bNumInterfaces);
|
printf("usbotp: interfaces: %d\n", config->bNumInterfaces);
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct libusb_endpoint_descriptor *endp = NULL;
|
const struct libusb_endpoint_descriptor *endp = NULL;
|
||||||
int intf, intf_alt;
|
int intf, intf_alt;
|
||||||
for(intf = 0; intf < config->bNumInterfaces; intf++)
|
for(intf = 0; intf < config->bNumInterfaces; intf++)
|
||||||
|
|
@ -147,7 +147,7 @@ int crypto_apply(
|
||||||
buffer_size, &recv_size, 1000);
|
buffer_size, &recv_size, 1000);
|
||||||
libusb_release_interface(handle, intf);
|
libusb_release_interface(handle, intf);
|
||||||
libusb_close(handle);
|
libusb_close(handle);
|
||||||
|
|
||||||
if(ret < 0)
|
if(ret < 0)
|
||||||
{
|
{
|
||||||
if(g_debug)
|
if(g_debug)
|
||||||
|
|
@ -166,7 +166,7 @@ int crypto_apply(
|
||||||
memcpy(out_data, buffer + 16, 16 * nr_blocks);
|
memcpy(out_data, buffer + 16, 16 * nr_blocks);
|
||||||
if(out_cbc_mac && encrypt)
|
if(out_cbc_mac && encrypt)
|
||||||
memcpy(*out_cbc_mac, buffer + buffer_size - 16, 16);
|
memcpy(*out_cbc_mac, buffer + buffer_size - 16, 16);
|
||||||
|
|
||||||
return CRYPTO_ERROR_SUCCESS;
|
return CRYPTO_ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -733,7 +733,7 @@ struct cmd_file_t *db_parse_file(const char *file)
|
||||||
inst->type = (inst->type == CMD_CALL) ? CMD_CALL_AT : CMD_JUMP_AT;
|
inst->type = (inst->type == CMD_CALL) ? CMD_CALL_AT : CMD_JUMP_AT;
|
||||||
inst->addr = parse_intexpr(&lctx, cmd_file->constant_list);
|
inst->addr = parse_intexpr(&lctx, cmd_file->constant_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(lexem.type == LEX_LPAREN)
|
if(lexem.type == LEX_LPAREN)
|
||||||
{
|
{
|
||||||
next(true);
|
next(true);
|
||||||
|
|
|
||||||
|
|
@ -208,9 +208,9 @@ void elf_add_fill_section(struct elf_params_t *params,
|
||||||
printf("oops, non-zero filling, ignore fill section\n");
|
printf("oops, non-zero filling, ignore fill section\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct elf_section_t *sec = elf_add_section(params);
|
struct elf_section_t *sec = elf_add_section(params);
|
||||||
|
|
||||||
sec->type = EST_FILL;
|
sec->type = EST_FILL;
|
||||||
sec->addr = fill_addr;
|
sec->addr = fill_addr;
|
||||||
sec->size = size;
|
sec->size = size;
|
||||||
|
|
@ -239,7 +239,7 @@ void elf_simplify(struct elf_params_t *params)
|
||||||
nr_sections++;
|
nr_sections++;
|
||||||
cur_sec = cur_sec->next;
|
cur_sec = cur_sec->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* put all sections in an array and free list */
|
/* put all sections in an array and free list */
|
||||||
struct elf_section_t *sections = malloc(sizeof(struct elf_section_t) * nr_sections);
|
struct elf_section_t *sections = malloc(sizeof(struct elf_section_t) * nr_sections);
|
||||||
cur_sec = params->first_section;
|
cur_sec = params->first_section;
|
||||||
|
|
@ -371,7 +371,7 @@ void elf_write_file(struct elf_params_t *params, elf_write_fn_t write,
|
||||||
elf_printf_fn_t printf, void *user)
|
elf_printf_fn_t printf, void *user)
|
||||||
{
|
{
|
||||||
(void) printf;
|
(void) printf;
|
||||||
|
|
||||||
Elf32_Ehdr ehdr;
|
Elf32_Ehdr ehdr;
|
||||||
uint32_t phnum = 0;
|
uint32_t phnum = 0;
|
||||||
struct elf_section_t *sec = params->first_section;
|
struct elf_section_t *sec = params->first_section;
|
||||||
|
|
@ -391,7 +391,7 @@ void elf_write_file(struct elf_params_t *params, elf_write_fn_t write,
|
||||||
{
|
{
|
||||||
sec->offset = 0;
|
sec->offset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
phnum++;
|
phnum++;
|
||||||
sec = sec->next;
|
sec = sec->next;
|
||||||
}
|
}
|
||||||
|
|
@ -431,7 +431,7 @@ void elf_write_file(struct elf_params_t *params, elf_write_fn_t write,
|
||||||
* - one name ".shstrtab\0" */
|
* - one name ".shstrtab\0" */
|
||||||
char *strtbl_content = malloc(1 + strlen(".shstrtab") + 1 +
|
char *strtbl_content = malloc(1 + strlen(".shstrtab") + 1 +
|
||||||
phnum * (strlen(".textXXXX") + 1));
|
phnum * (strlen(".textXXXX") + 1));
|
||||||
|
|
||||||
strtbl_content[0] = '\0';
|
strtbl_content[0] = '\0';
|
||||||
strcpy(&strtbl_content[1], ".shstrtab");
|
strcpy(&strtbl_content[1], ".shstrtab");
|
||||||
uint32_t strtbl_index = 1 + strlen(".shstrtab") + 1;
|
uint32_t strtbl_index = 1 + strlen(".shstrtab") + 1;
|
||||||
|
|
@ -444,7 +444,7 @@ void elf_write_file(struct elf_params_t *params, elf_write_fn_t write,
|
||||||
while(sec)
|
while(sec)
|
||||||
{
|
{
|
||||||
sec->offset += data_offset;
|
sec->offset += data_offset;
|
||||||
|
|
||||||
phdr.p_type = PT_LOAD;
|
phdr.p_type = PT_LOAD;
|
||||||
if(sec->type == EST_LOAD)
|
if(sec->type == EST_LOAD)
|
||||||
phdr.p_offset = sec->offset;
|
phdr.p_offset = sec->offset;
|
||||||
|
|
@ -549,7 +549,7 @@ bool elf_read_file(struct elf_params_t *params, elf_read_fn_t read,
|
||||||
elf_printf_fn_t printf, void *user)
|
elf_printf_fn_t printf, void *user)
|
||||||
{
|
{
|
||||||
#define error_printf(...) ({printf(user, true, __VA_ARGS__); return false;})
|
#define error_printf(...) ({printf(user, true, __VA_ARGS__); return false;})
|
||||||
|
|
||||||
/* read header */
|
/* read header */
|
||||||
Elf32_Ehdr ehdr;
|
Elf32_Ehdr ehdr;
|
||||||
if(!read(user, 0, &ehdr, sizeof(ehdr)))
|
if(!read(user, 0, &ehdr, sizeof(ehdr)))
|
||||||
|
|
@ -626,7 +626,7 @@ bool elf_read_file(struct elf_params_t *params, elf_read_fn_t read,
|
||||||
if(strtab)
|
if(strtab)
|
||||||
printf(user, false, "filter out %s\n", &strtab[shdr.sh_name], shdr.sh_type);
|
printf(user, false, "filter out %s\n", &strtab[shdr.sh_name], shdr.sh_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
free(strtab);
|
free(strtab);
|
||||||
/* run through segments */
|
/* run through segments */
|
||||||
|
|
@ -647,7 +647,7 @@ bool elf_read_file(struct elf_params_t *params, elf_read_fn_t read,
|
||||||
printf(user, false, "create segment [%#x,+%#x[ -> [%#x,+%#x[\n",
|
printf(user, false, "create segment [%#x,+%#x[ -> [%#x,+%#x[\n",
|
||||||
seg->vaddr, seg->vsize, seg->paddr, seg->psize);
|
seg->vaddr, seg->vsize, seg->paddr, seg->psize);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
* KIND, either express or implied.
|
* KIND, either express or implied.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#define _ISOC99_SOURCE
|
#define _ISOC99_SOURCE
|
||||||
#define _POSIX_C_SOURCE 200809L /* for strdup */
|
#define _POSIX_C_SOURCE 200809L /* for strdup */
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
@ -144,7 +144,7 @@ static struct sb_file_t *apply_cmd_file(struct cmd_file_t *cmd_file)
|
||||||
|
|
||||||
db_generate_default_sb_version(&sb->product_ver);
|
db_generate_default_sb_version(&sb->product_ver);
|
||||||
db_generate_default_sb_version(&sb->component_ver);
|
db_generate_default_sb_version(&sb->component_ver);
|
||||||
|
|
||||||
if(g_debug)
|
if(g_debug)
|
||||||
printf("Applying command file...\n");
|
printf("Applying command file...\n");
|
||||||
/* count sections */
|
/* count sections */
|
||||||
|
|
@ -246,7 +246,7 @@ static struct sb_file_t *apply_cmd_file(struct cmd_file_t *cmd_file)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
bug("die\n");
|
bug("die\n");
|
||||||
|
|
||||||
cinst = cinst->next;
|
cinst = cinst->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -308,7 +308,7 @@ static struct sb_file_t *apply_cmd_file(struct cmd_file_t *cmd_file)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
bug("die\n");
|
bug("die\n");
|
||||||
|
|
||||||
cinst = cinst->next;
|
cinst = cinst->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -347,7 +347,7 @@ int main(int argc, char **argv)
|
||||||
struct crypto_key_t crypto_iv;
|
struct crypto_key_t crypto_iv;
|
||||||
real_key.method = CRYPTO_NONE;
|
real_key.method = CRYPTO_NONE;
|
||||||
crypto_iv.method = CRYPTO_NONE;
|
crypto_iv.method = CRYPTO_NONE;
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
static struct option long_options[] =
|
static struct option long_options[] =
|
||||||
|
|
@ -452,10 +452,10 @@ int main(int argc, char **argv)
|
||||||
sb_file->first_boot_sec_id = sb_file->sections[0].identifier;
|
sb_file->first_boot_sec_id = sb_file->sections[0].identifier;
|
||||||
sb_file->flags = 0;
|
sb_file->flags = 0;
|
||||||
sb_file->minor_version = 1;
|
sb_file->minor_version = 1;
|
||||||
|
|
||||||
sb_write_file(sb_file, output_filename);
|
sb_write_file(sb_file, output_filename);
|
||||||
sb_free(sb_file);
|
sb_free(sb_file);
|
||||||
clear_keys();
|
clear_keys();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -265,7 +265,7 @@ static bool parse_sb_version(struct sb1_version_t *ver, char *str)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command line parsing
|
* Command line parsing
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define MAX_NR_ARGS 2
|
#define MAX_NR_ARGS 2
|
||||||
|
|
@ -586,7 +586,7 @@ static void usage(void)
|
||||||
printf(" -N/-nonstrict\t\t\tClear strict flag\n");
|
printf(" -N/-nonstrict\t\t\tClear strict flag\n");
|
||||||
printf(" -call <addr>\t\t\tCall code at a specified address\n");
|
printf(" -call <addr>\t\t\tCall code at a specified address\n");
|
||||||
printf(" -jump <addr>\t\t\tJump to code at a specified address\n");
|
printf(" -jump <addr>\t\t\tJump to code at a specified address\n");
|
||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -623,4 +623,4 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -161,12 +161,12 @@ static bool read_entries(struct rsrc_file_t *f, void *u,
|
||||||
printf(RED, "%c", isprint(p[i]) ? p[i] : '.');
|
printf(RED, "%c", isprint(p[i]) ? p[i] : '.');
|
||||||
}
|
}
|
||||||
printf(OFF, "\n");
|
printf(OFF, "\n");
|
||||||
|
|
||||||
if(RSRC_TABLE_ENTRY_TYPE(te) == RSRC_TYPE_NESTED)
|
if(RSRC_TABLE_ENTRY_TYPE(te) == RSRC_TYPE_NESTED)
|
||||||
{
|
{
|
||||||
char *p = prefix + strlen(prefix);
|
char *p = prefix + strlen(prefix);
|
||||||
sprintf(p, "%s| ", RED);
|
sprintf(p, "%s| ", RED);
|
||||||
|
|
||||||
bool ok = read_entries(f, u, cprintf, err,
|
bool ok = read_entries(f, u, cprintf, err,
|
||||||
RSRC_TABLE_ENTRY_OFFSET(te), index,
|
RSRC_TABLE_ENTRY_OFFSET(te), index,
|
||||||
level - 1, prefix);
|
level - 1, prefix);
|
||||||
|
|
@ -175,7 +175,7 @@ static bool read_entries(struct rsrc_file_t *f, void *u,
|
||||||
*p = 0;
|
*p = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
#undef printf
|
#undef printf
|
||||||
#undef fatal
|
#undef fatal
|
||||||
|
|
@ -220,7 +220,7 @@ struct rsrc_file_t *rsrc_read_memory(void *_buf, size_t filesize, void *u,
|
||||||
bool ok = read_entries(rsrc_file, u, cprintf, err, RSRC_SECTOR_SIZE, 0, 3, prefix);
|
bool ok = read_entries(rsrc_file, u, cprintf, err, RSRC_SECTOR_SIZE, 0, 3, prefix);
|
||||||
if(!ok)
|
if(!ok)
|
||||||
fatal(*err, "Error while parsing rsrc table\n");
|
fatal(*err, "Error while parsing rsrc table\n");
|
||||||
|
|
||||||
return rsrc_file;
|
return rsrc_file;
|
||||||
#undef printf
|
#undef printf
|
||||||
#undef fatal
|
#undef fatal
|
||||||
|
|
@ -253,4 +253,4 @@ void rsrc_dump(struct rsrc_file_t *file, void *u, rsrc_color_printf cprintf)
|
||||||
#undef printf
|
#undef printf
|
||||||
#undef print_hex
|
#undef print_hex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -92,4 +92,4 @@ void rsrc_dump(struct rsrc_file_t *file, void *u, rsrc_color_printf printf);
|
||||||
void rsrc_free(struct rsrc_file_t *file);
|
void rsrc_free(struct rsrc_file_t *file);
|
||||||
|
|
||||||
#endif /* __RSRC_H__ */
|
#endif /* __RSRC_H__ */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -199,4 +199,4 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ static void compute_sb_offsets(struct sb_file_t *sb)
|
||||||
if((i + 1) < sb->nr_sections)
|
if((i + 1) < sb->nr_sections)
|
||||||
alignment = sb->sections[i + 1].alignment;
|
alignment = sb->sections[i + 1].alignment;
|
||||||
alignment /= BLOCK_SIZE; /* alignment in block sizes */
|
alignment /= BLOCK_SIZE; /* alignment in block sizes */
|
||||||
|
|
||||||
struct sb_section_t *sec = &sb->sections[i];
|
struct sb_section_t *sec = &sb->sections[i];
|
||||||
sec->sec_size = 0;
|
sec->sec_size = 0;
|
||||||
|
|
||||||
|
|
@ -75,7 +75,7 @@ static void compute_sb_offsets(struct sb_file_t *sb)
|
||||||
printf(" (cleartext)");
|
printf(" (cleartext)");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
sec->file_offset = sb->image_size;
|
sec->file_offset = sb->image_size;
|
||||||
for(int j = 0; j < sec->nr_insts; j++)
|
for(int j = 0; j < sec->nr_insts; j++)
|
||||||
{
|
{
|
||||||
|
|
@ -203,7 +203,7 @@ static void fix_version(struct sb_version_t *ver)
|
||||||
static void produce_sb_header(struct sb_file_t *sb, struct sb_header_t *sb_hdr)
|
static void produce_sb_header(struct sb_file_t *sb, struct sb_header_t *sb_hdr)
|
||||||
{
|
{
|
||||||
struct sha_1_params_t sha_1_params;
|
struct sha_1_params_t sha_1_params;
|
||||||
|
|
||||||
sb_hdr->signature[0] = 'S';
|
sb_hdr->signature[0] = 'S';
|
||||||
sb_hdr->signature[1] = 'T';
|
sb_hdr->signature[1] = 'T';
|
||||||
sb_hdr->signature[2] = 'M';
|
sb_hdr->signature[2] = 'M';
|
||||||
|
|
@ -227,7 +227,7 @@ static void produce_sb_header(struct sb_file_t *sb, struct sb_header_t *sb_hdr)
|
||||||
* Version 1.1 requires the last 4 bytes to be 'sgtl' */
|
* Version 1.1 requires the last 4 bytes to be 'sgtl' */
|
||||||
if(sb->minor_version >= 1)
|
if(sb->minor_version >= 1)
|
||||||
memcpy(&sb_hdr->rand_pad0[2], "sgtl", 4);
|
memcpy(&sb_hdr->rand_pad0[2], "sgtl", 4);
|
||||||
|
|
||||||
sb_hdr->timestamp = generate_timestamp();
|
sb_hdr->timestamp = generate_timestamp();
|
||||||
sb_hdr->product_ver = sb->product_ver;
|
sb_hdr->product_ver = sb->product_ver;
|
||||||
fix_version(&sb_hdr->product_ver);
|
fix_version(&sb_hdr->product_ver);
|
||||||
|
|
@ -333,17 +333,17 @@ enum sb_error_t sb_write_file(struct sb_file_t *sb, const char *filename)
|
||||||
byte *buf = xmalloc(sb_hdr.image_size * BLOCK_SIZE);
|
byte *buf = xmalloc(sb_hdr.image_size * BLOCK_SIZE);
|
||||||
byte *buf_p = buf;
|
byte *buf_p = buf;
|
||||||
#define write(p, sz) do { memcpy(buf_p, p, sz); buf_p += sz; } while(0)
|
#define write(p, sz) do { memcpy(buf_p, p, sz); buf_p += sz; } while(0)
|
||||||
|
|
||||||
sha_1_update(&file_sha1, (byte *)&sb_hdr, sizeof(sb_hdr));
|
sha_1_update(&file_sha1, (byte *)&sb_hdr, sizeof(sb_hdr));
|
||||||
write(&sb_hdr, sizeof(sb_hdr));
|
write(&sb_hdr, sizeof(sb_hdr));
|
||||||
|
|
||||||
memcpy(crypto_iv, &sb_hdr, 16);
|
memcpy(crypto_iv, &sb_hdr, 16);
|
||||||
|
|
||||||
/* update CBC-MACs */
|
/* update CBC-MACs */
|
||||||
for(int i = 0; i < g_nr_keys; i++)
|
for(int i = 0; i < g_nr_keys; i++)
|
||||||
crypto_cbc((byte *)&sb_hdr, NULL, sizeof(sb_hdr) / BLOCK_SIZE, &g_key_array[i],
|
crypto_cbc((byte *)&sb_hdr, NULL, sizeof(sb_hdr) / BLOCK_SIZE, &g_key_array[i],
|
||||||
cbc_macs[i], &cbc_macs[i], 1);
|
cbc_macs[i], &cbc_macs[i], 1);
|
||||||
|
|
||||||
/* produce and write section headers */
|
/* produce and write section headers */
|
||||||
for(int i = 0; i < sb_hdr.nr_sections; i++)
|
for(int i = 0; i < sb_hdr.nr_sections; i++)
|
||||||
{
|
{
|
||||||
|
|
@ -363,7 +363,7 @@ enum sb_error_t sb_write_file(struct sb_file_t *sb, const char *filename)
|
||||||
memcpy(entry.hdr_cbc_mac, cbc_macs[i], 16);
|
memcpy(entry.hdr_cbc_mac, cbc_macs[i], 16);
|
||||||
crypto_cbc(real_key.u.key, entry.key, 1, &g_key_array[i],
|
crypto_cbc(real_key.u.key, entry.key, 1, &g_key_array[i],
|
||||||
crypto_iv, NULL, 1);
|
crypto_iv, NULL, 1);
|
||||||
|
|
||||||
write(&entry, sizeof(entry));
|
write(&entry, sizeof(entry));
|
||||||
sha_1_update(&file_sha1, (byte *)&entry, sizeof(entry));
|
sha_1_update(&file_sha1, (byte *)&entry, sizeof(entry));
|
||||||
}
|
}
|
||||||
|
|
@ -447,7 +447,7 @@ enum sb_error_t sb_write_file(struct sb_file_t *sb, const char *filename)
|
||||||
printf("SB image buffer was not entirely filled !");
|
printf("SB image buffer was not entirely filled !");
|
||||||
return SB_ERROR;
|
return SB_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *fd = fopen(filename, "wb");
|
FILE *fd = fopen(filename, "wb");
|
||||||
if(fd == NULL)
|
if(fd == NULL)
|
||||||
return SB_OPEN_ERROR;
|
return SB_OPEN_ERROR;
|
||||||
|
|
@ -472,13 +472,13 @@ static struct sb_section_t *read_section(bool data_sec, uint32_t id, byte *buf,
|
||||||
sb_free_section(*sec); \
|
sb_free_section(*sec); \
|
||||||
free(sec); \
|
free(sec); \
|
||||||
return NULL; } while(0)
|
return NULL; } while(0)
|
||||||
|
|
||||||
struct sb_section_t *sec = xmalloc(sizeof(struct sb_section_t));
|
struct sb_section_t *sec = xmalloc(sizeof(struct sb_section_t));
|
||||||
memset(sec, 0, sizeof(struct sb_section_t));
|
memset(sec, 0, sizeof(struct sb_section_t));
|
||||||
sec->identifier = id;
|
sec->identifier = id;
|
||||||
sec->is_data = data_sec;
|
sec->is_data = data_sec;
|
||||||
sec->sec_size = ROUND_UP(size, BLOCK_SIZE) / BLOCK_SIZE;
|
sec->sec_size = ROUND_UP(size, BLOCK_SIZE) / BLOCK_SIZE;
|
||||||
|
|
||||||
if(data_sec)
|
if(data_sec)
|
||||||
{
|
{
|
||||||
sec->nr_insts = 1;
|
sec->nr_insts = 1;
|
||||||
|
|
@ -499,7 +499,7 @@ static struct sb_section_t *read_section(bool data_sec, uint32_t id, byte *buf,
|
||||||
|
|
||||||
struct sb_instruction_header_t *hdr = (struct sb_instruction_header_t *)&buf[pos];
|
struct sb_instruction_header_t *hdr = (struct sb_instruction_header_t *)&buf[pos];
|
||||||
inst.inst = hdr->opcode;
|
inst.inst = hdr->opcode;
|
||||||
|
|
||||||
printf(OFF, "%s", indent);
|
printf(OFF, "%s", indent);
|
||||||
uint8_t checksum = instruction_checksum(hdr);
|
uint8_t checksum = instruction_checksum(hdr);
|
||||||
if(checksum != hdr->checksum)
|
if(checksum != hdr->checksum)
|
||||||
|
|
@ -516,7 +516,7 @@ static struct sb_section_t *read_section(bool data_sec, uint32_t id, byte *buf,
|
||||||
inst.size = load->len;
|
inst.size = load->len;
|
||||||
inst.addr = load->addr;
|
inst.addr = load->addr;
|
||||||
inst.data = memdup(load + 1, load->len);
|
inst.data = memdup(load + 1, load->len);
|
||||||
|
|
||||||
printf(RED, "LOAD");
|
printf(RED, "LOAD");
|
||||||
printf(OFF, " | ");
|
printf(OFF, " | ");
|
||||||
printf(BLUE, "addr=0x%08x", load->addr);
|
printf(BLUE, "addr=0x%08x", load->addr);
|
||||||
|
|
@ -543,7 +543,7 @@ static struct sb_section_t *read_section(bool data_sec, uint32_t id, byte *buf,
|
||||||
inst.pattern = fill->pattern;
|
inst.pattern = fill->pattern;
|
||||||
inst.size = fill->len;
|
inst.size = fill->len;
|
||||||
inst.addr = fill->addr;
|
inst.addr = fill->addr;
|
||||||
|
|
||||||
printf(RED, "FILL");
|
printf(RED, "FILL");
|
||||||
printf(OFF, " | ");
|
printf(OFF, " | ");
|
||||||
printf(BLUE, "addr=0x%08x", fill->addr);
|
printf(BLUE, "addr=0x%08x", fill->addr);
|
||||||
|
|
@ -561,7 +561,7 @@ static struct sb_section_t *read_section(bool data_sec, uint32_t id, byte *buf,
|
||||||
struct sb_instruction_call_t *call = (struct sb_instruction_call_t *)&buf[pos];
|
struct sb_instruction_call_t *call = (struct sb_instruction_call_t *)&buf[pos];
|
||||||
inst.addr = call->addr;
|
inst.addr = call->addr;
|
||||||
inst.argument = call->arg;
|
inst.argument = call->arg;
|
||||||
|
|
||||||
if(is_call)
|
if(is_call)
|
||||||
printf(RED, "CALL");
|
printf(RED, "CALL");
|
||||||
else
|
else
|
||||||
|
|
@ -577,11 +577,11 @@ static struct sb_section_t *read_section(bool data_sec, uint32_t id, byte *buf,
|
||||||
{
|
{
|
||||||
struct sb_instruction_mode_t *mode = (struct sb_instruction_mode_t *)hdr;
|
struct sb_instruction_mode_t *mode = (struct sb_instruction_mode_t *)hdr;
|
||||||
inst.argument = mode->mode;
|
inst.argument = mode->mode;
|
||||||
|
|
||||||
printf(RED, "MODE");
|
printf(RED, "MODE");
|
||||||
printf(OFF, " | ");
|
printf(OFF, " | ");
|
||||||
printf(BLUE, "mod=0x%08x\n", mode->mode);
|
printf(BLUE, "mod=0x%08x\n", mode->mode);
|
||||||
|
|
||||||
pos += sizeof(struct sb_instruction_mode_t);
|
pos += sizeof(struct sb_instruction_mode_t);
|
||||||
}
|
}
|
||||||
else if(hdr->opcode == SB_INST_NOP)
|
else if(hdr->opcode == SB_INST_NOP)
|
||||||
|
|
@ -671,7 +671,7 @@ struct sb_file_t *sb_read_memory(void *_buf, size_t filesize, bool raw_mode, voi
|
||||||
{
|
{
|
||||||
struct sb_file_t *sb_file = NULL;
|
struct sb_file_t *sb_file = NULL;
|
||||||
uint8_t *buf = _buf;
|
uint8_t *buf = _buf;
|
||||||
|
|
||||||
#define printf(c, ...) cprintf(u, false, c, __VA_ARGS__)
|
#define printf(c, ...) cprintf(u, false, c, __VA_ARGS__)
|
||||||
#define fatal(e, ...) \
|
#define fatal(e, ...) \
|
||||||
do { if(err) *err = e; \
|
do { if(err) *err = e; \
|
||||||
|
|
@ -680,7 +680,7 @@ struct sb_file_t *sb_read_memory(void *_buf, size_t filesize, bool raw_mode, voi
|
||||||
return NULL; } while(0)
|
return NULL; } while(0)
|
||||||
#define print_hex(c, p, len, nl) \
|
#define print_hex(c, p, len, nl) \
|
||||||
do { printf(c, ""); print_hex(p, len, nl); } while(0)
|
do { printf(c, ""); print_hex(p, len, nl); } while(0)
|
||||||
|
|
||||||
struct sha_1_params_t sha_1_params;
|
struct sha_1_params_t sha_1_params;
|
||||||
sb_file = xmalloc(sizeof(struct sb_file_t));
|
sb_file = xmalloc(sizeof(struct sb_file_t));
|
||||||
memset(sb_file, 0, sizeof(struct sb_file_t));
|
memset(sb_file, 0, sizeof(struct sb_file_t));
|
||||||
|
|
@ -730,7 +730,7 @@ struct sb_file_t *sb_read_memory(void *_buf, size_t filesize, bool raw_mode, voi
|
||||||
printf(YELLOW, "%x\n", sb_header->flags);
|
printf(YELLOW, "%x\n", sb_header->flags);
|
||||||
printf(GREEN, " Total file size : ");
|
printf(GREEN, " Total file size : ");
|
||||||
printf(YELLOW, "%ld\n", filesize);
|
printf(YELLOW, "%ld\n", filesize);
|
||||||
|
|
||||||
/* Sizes and offsets */
|
/* Sizes and offsets */
|
||||||
printf(BLUE, "Sizes and offsets:\n");
|
printf(BLUE, "Sizes and offsets:\n");
|
||||||
printf(GREEN, " # of encryption keys = ");
|
printf(GREEN, " # of encryption keys = ");
|
||||||
|
|
@ -745,7 +745,7 @@ struct sb_file_t *sb_read_memory(void *_buf, size_t filesize, bool raw_mode, voi
|
||||||
print_hex(YELLOW, sb_header->rand_pad0, sizeof(sb_header->rand_pad0), true);
|
print_hex(YELLOW, sb_header->rand_pad0, sizeof(sb_header->rand_pad0), true);
|
||||||
printf(GREEN, " Random 2: ");
|
printf(GREEN, " Random 2: ");
|
||||||
print_hex(YELLOW, sb_header->rand_pad1, sizeof(sb_header->rand_pad1), true);
|
print_hex(YELLOW, sb_header->rand_pad1, sizeof(sb_header->rand_pad1), true);
|
||||||
|
|
||||||
uint64_t micros = sb_header->timestamp;
|
uint64_t micros = sb_header->timestamp;
|
||||||
time_t seconds = (micros / (uint64_t)1000000L);
|
time_t seconds = (micros / (uint64_t)1000000L);
|
||||||
struct tm tm_base;
|
struct tm tm_base;
|
||||||
|
|
@ -770,7 +770,7 @@ struct sb_file_t *sb_read_memory(void *_buf, size_t filesize, bool raw_mode, voi
|
||||||
printf(YELLOW, "%X.%X.%X\n", product_ver.major, product_ver.minor, product_ver.revision);
|
printf(YELLOW, "%X.%X.%X\n", product_ver.major, product_ver.minor, product_ver.revision);
|
||||||
printf(GREEN, " Component version = ");
|
printf(GREEN, " Component version = ");
|
||||||
printf(YELLOW, "%X.%X.%X\n", component_ver.major, component_ver.minor, component_ver.revision);
|
printf(YELLOW, "%X.%X.%X\n", component_ver.major, component_ver.minor, component_ver.revision);
|
||||||
|
|
||||||
printf(GREEN, " Drive tag = ");
|
printf(GREEN, " Drive tag = ");
|
||||||
printf(YELLOW, "%x\n", sb_header->drive_tag);
|
printf(YELLOW, "%x\n", sb_header->drive_tag);
|
||||||
printf(GREEN, " First boot tag offset = ");
|
printf(GREEN, " First boot tag offset = ");
|
||||||
|
|
@ -781,7 +781,7 @@ struct sb_file_t *sb_read_memory(void *_buf, size_t filesize, bool raw_mode, voi
|
||||||
/* encryption cbc-mac */
|
/* encryption cbc-mac */
|
||||||
byte real_key[16];
|
byte real_key[16];
|
||||||
bool valid_key = false; /* false until a matching key was found */
|
bool valid_key = false; /* false until a matching key was found */
|
||||||
|
|
||||||
if(sb_header->nr_keys > 0)
|
if(sb_header->nr_keys > 0)
|
||||||
{
|
{
|
||||||
byte (*cbcmacs)[16] = xmalloc(16 * g_nr_keys);
|
byte (*cbcmacs)[16] = xmalloc(16 * g_nr_keys);
|
||||||
|
|
@ -905,14 +905,14 @@ struct sb_file_t *sb_read_memory(void *_buf, size_t filesize, bool raw_mode, voi
|
||||||
{
|
{
|
||||||
uint32_t ofs = sb_header->header_size * BLOCK_SIZE + i * sizeof(struct sb_section_header_t);
|
uint32_t ofs = sb_header->header_size * BLOCK_SIZE + i * sizeof(struct sb_section_header_t);
|
||||||
struct sb_section_header_t *sec_hdr = (struct sb_section_header_t *)&buf[ofs];
|
struct sb_section_header_t *sec_hdr = (struct sb_section_header_t *)&buf[ofs];
|
||||||
|
|
||||||
char name[5];
|
char name[5];
|
||||||
sb_fill_section_name(name, sec_hdr->identifier);
|
sb_fill_section_name(name, sec_hdr->identifier);
|
||||||
int pos = sec_hdr->offset * BLOCK_SIZE;
|
int pos = sec_hdr->offset * BLOCK_SIZE;
|
||||||
int size = sec_hdr->size * BLOCK_SIZE;
|
int size = sec_hdr->size * BLOCK_SIZE;
|
||||||
int data_sec = !(sec_hdr->flags & SECTION_BOOTABLE);
|
int data_sec = !(sec_hdr->flags & SECTION_BOOTABLE);
|
||||||
int encrypted = !(sec_hdr->flags & SECTION_CLEARTEXT) && sb_header->nr_keys > 0;
|
int encrypted = !(sec_hdr->flags & SECTION_CLEARTEXT) && sb_header->nr_keys > 0;
|
||||||
|
|
||||||
printf(GREEN, " Section ");
|
printf(GREEN, " Section ");
|
||||||
printf(YELLOW, "'%s'\n", name);
|
printf(YELLOW, "'%s'\n", name);
|
||||||
printf(GREEN, " pos = ");
|
printf(GREEN, " pos = ");
|
||||||
|
|
@ -935,7 +935,7 @@ struct sb_file_t *sb_read_memory(void *_buf, size_t filesize, bool raw_mode, voi
|
||||||
printf(GREY, " Skipping section content (no valid key)\n");
|
printf(GREY, " Skipping section content (no valid key)\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* save it */
|
/* save it */
|
||||||
byte *sec = xmalloc(size);
|
byte *sec = xmalloc(size);
|
||||||
if(encrypted)
|
if(encrypted)
|
||||||
|
|
@ -954,7 +954,7 @@ struct sb_file_t *sb_read_memory(void *_buf, size_t filesize, bool raw_mode, voi
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fatal(*err, "Error reading section\n");
|
fatal(*err, "Error reading section\n");
|
||||||
|
|
||||||
free(sec);
|
free(sec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -979,7 +979,7 @@ struct sb_file_t *sb_read_memory(void *_buf, size_t filesize, bool raw_mode, voi
|
||||||
uint8_t checksum = instruction_checksum(hdr);
|
uint8_t checksum = instruction_checksum(hdr);
|
||||||
if(checksum != hdr->checksum)
|
if(checksum != hdr->checksum)
|
||||||
printf(GREY, "[Bad checksum']");
|
printf(GREY, "[Bad checksum']");
|
||||||
|
|
||||||
if(hdr->opcode == SB_INST_NOP)
|
if(hdr->opcode == SB_INST_NOP)
|
||||||
{
|
{
|
||||||
printf(RED, "NOOP\n");
|
printf(RED, "NOOP\n");
|
||||||
|
|
@ -1009,7 +1009,7 @@ struct sb_file_t *sb_read_memory(void *_buf, size_t filesize, bool raw_mode, voi
|
||||||
int size = tag->len * BLOCK_SIZE;
|
int size = tag->len * BLOCK_SIZE;
|
||||||
int data_sec = !(tag->flags & SECTION_BOOTABLE);
|
int data_sec = !(tag->flags & SECTION_BOOTABLE);
|
||||||
int encrypted = !(tag->flags & SECTION_CLEARTEXT) && sb_header->nr_keys > 0;
|
int encrypted = !(tag->flags & SECTION_CLEARTEXT) && sb_header->nr_keys > 0;
|
||||||
|
|
||||||
printf(GREEN, "%sSection ", indent);
|
printf(GREEN, "%sSection ", indent);
|
||||||
printf(YELLOW, "'%s'\n", name);
|
printf(YELLOW, "'%s'\n", name);
|
||||||
printf(GREEN, "%s pos = ", indent);
|
printf(GREEN, "%s pos = ", indent);
|
||||||
|
|
@ -1032,7 +1032,7 @@ struct sb_file_t *sb_read_memory(void *_buf, size_t filesize, bool raw_mode, voi
|
||||||
cbc_mac(buf + pos, sec, size / BLOCK_SIZE, real_key, buf, NULL, 0);
|
cbc_mac(buf + pos, sec, size / BLOCK_SIZE, real_key, buf, NULL, 0);
|
||||||
else
|
else
|
||||||
memcpy(sec, buf + pos, size);
|
memcpy(sec, buf + pos, size);
|
||||||
|
|
||||||
struct sb_section_t *s = read_section(data_sec, tag->identifier,
|
struct sb_section_t *s = read_section(data_sec, tag->identifier,
|
||||||
sec, size, " ", u, cprintf, err);
|
sec, size, " ", u, cprintf, err);
|
||||||
if(s)
|
if(s)
|
||||||
|
|
@ -1064,7 +1064,7 @@ struct sb_file_t *sb_read_memory(void *_buf, size_t filesize, bool raw_mode, voi
|
||||||
{
|
{
|
||||||
printf(GREY, "Cannot read content in raw mode without a valid key\n");
|
printf(GREY, "Cannot read content in raw mode without a valid key\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* final signature */
|
/* final signature */
|
||||||
printf(BLUE, "Final signature:\n");
|
printf(BLUE, "Final signature:\n");
|
||||||
byte decrypted_block[32];
|
byte decrypted_block[32];
|
||||||
|
|
@ -1095,7 +1095,7 @@ struct sb_file_t *sb_read_memory(void *_buf, size_t filesize, bool raw_mode, voi
|
||||||
printf(RED, " Failed\n");
|
printf(RED, " Failed\n");
|
||||||
fatal(SB_CHECKSUM_ERROR, "File SHA-1 error\n");
|
fatal(SB_CHECKSUM_ERROR, "File SHA-1 error\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return sb_file;
|
return sb_file;
|
||||||
#undef printf
|
#undef printf
|
||||||
#undef fatal
|
#undef fatal
|
||||||
|
|
@ -1131,13 +1131,13 @@ void sb_dump(struct sb_file_t *file, void *u, sb_color_printf cprintf)
|
||||||
#define printf(c, ...) cprintf(u, false, c, __VA_ARGS__)
|
#define printf(c, ...) cprintf(u, false, c, __VA_ARGS__)
|
||||||
#define print_hex(c, p, len, nl) \
|
#define print_hex(c, p, len, nl) \
|
||||||
do { printf(c, ""); print_hex(p, len, nl); } while(0)
|
do { printf(c, ""); print_hex(p, len, nl); } while(0)
|
||||||
|
|
||||||
#define TREE RED
|
#define TREE RED
|
||||||
#define HEADER GREEN
|
#define HEADER GREEN
|
||||||
#define TEXT YELLOW
|
#define TEXT YELLOW
|
||||||
#define TEXT2 BLUE
|
#define TEXT2 BLUE
|
||||||
#define SEP OFF
|
#define SEP OFF
|
||||||
|
|
||||||
printf(BLUE, "SB File\n");
|
printf(BLUE, "SB File\n");
|
||||||
printf(TREE, "+-");
|
printf(TREE, "+-");
|
||||||
printf(HEADER, "Version: ");
|
printf(HEADER, "Version: ");
|
||||||
|
|
@ -1153,7 +1153,7 @@ void sb_dump(struct sb_file_t *file, void *u, sb_color_printf cprintf)
|
||||||
char name[5];
|
char name[5];
|
||||||
sb_fill_section_name(name, file->first_boot_sec_id);
|
sb_fill_section_name(name, file->first_boot_sec_id);
|
||||||
printf(TEXT, "%08x (%s)\n", file->first_boot_sec_id, name);
|
printf(TEXT, "%08x (%s)\n", file->first_boot_sec_id, name);
|
||||||
|
|
||||||
if(file->override_real_key)
|
if(file->override_real_key)
|
||||||
{
|
{
|
||||||
printf(TREE, "+-");
|
printf(TREE, "+-");
|
||||||
|
|
@ -1174,7 +1174,7 @@ void sb_dump(struct sb_file_t *file, void *u, sb_color_printf cprintf)
|
||||||
printf(HEADER, "Component Version: ");
|
printf(HEADER, "Component Version: ");
|
||||||
printf(TEXT, "%X.%X.%X\n", file->component_ver.major, file->component_ver.minor,
|
printf(TEXT, "%X.%X.%X\n", file->component_ver.major, file->component_ver.minor,
|
||||||
file->component_ver.revision);
|
file->component_ver.revision);
|
||||||
|
|
||||||
for(int i = 0; i < file->nr_sections; i++)
|
for(int i = 0; i < file->nr_sections; i++)
|
||||||
{
|
{
|
||||||
struct sb_section_t *sec = &file->sections[i];
|
struct sb_section_t *sec = &file->sections[i];
|
||||||
|
|
@ -1241,7 +1241,7 @@ void sb_dump(struct sb_file_t *file, void *u, sb_color_printf cprintf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef printf
|
#undef printf
|
||||||
#undef print_hex
|
#undef print_hex
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -180,7 +180,7 @@ struct sb_section_t
|
||||||
bool is_data;
|
bool is_data;
|
||||||
bool is_cleartext;
|
bool is_cleartext;
|
||||||
uint32_t alignment;
|
uint32_t alignment;
|
||||||
// data sections are handled as one or more SB_INST_DATA virtual instruction
|
// data sections are handled as one or more SB_INST_DATA virtual instruction
|
||||||
int nr_insts;
|
int nr_insts;
|
||||||
struct sb_inst_t *insts;
|
struct sb_inst_t *insts;
|
||||||
/* for production use */
|
/* for production use */
|
||||||
|
|
@ -196,7 +196,7 @@ struct sb_file_t
|
||||||
/* override crypto IV, use with caution ! Use NULL to generate it */
|
/* override crypto IV, use with caution ! Use NULL to generate it */
|
||||||
bool override_crypto_iv;
|
bool override_crypto_iv;
|
||||||
uint8_t crypto_iv[16];
|
uint8_t crypto_iv[16];
|
||||||
|
|
||||||
int nr_sections;
|
int nr_sections;
|
||||||
uint16_t drive_tag;
|
uint16_t drive_tag;
|
||||||
uint32_t first_boot_sec_id;
|
uint32_t first_boot_sec_id;
|
||||||
|
|
|
||||||
|
|
@ -184,7 +184,7 @@ enum sb1_error_t sb1_write_file(struct sb1_file_t *sb, const char *filename)
|
||||||
if(sb->userdata)
|
if(sb->userdata)
|
||||||
fwrite(sb->userdata, sb->userdata_size, 1, fd);
|
fwrite(sb->userdata, sb->userdata_size, 1, fd);
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
|
|
||||||
return SB1_SUCCESS;
|
return SB1_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -257,7 +257,7 @@ bool sb1_is_key_valid_fast(void *buffer, size_t size, union xorcrypt_key_t _key[
|
||||||
struct sb1_header_t *header = (struct sb1_header_t *)buffer;
|
struct sb1_header_t *header = (struct sb1_header_t *)buffer;
|
||||||
|
|
||||||
union xorcrypt_key_t key[2];
|
union xorcrypt_key_t key[2];
|
||||||
|
|
||||||
uint8_t sector[SECTOR_SIZE];
|
uint8_t sector[SECTOR_SIZE];
|
||||||
/* copy key and data because it's modified by the crypto code */
|
/* copy key and data because it's modified by the crypto code */
|
||||||
memcpy(key, _key, sizeof(key));
|
memcpy(key, _key, sizeof(key));
|
||||||
|
|
@ -399,7 +399,7 @@ struct sb1_file_t *sb1_read_memory(void *_buf, size_t filesize, void *u,
|
||||||
printf(YELLOW, "%X.%X.%X\n", product_ver.major, product_ver.minor, product_ver.revision);
|
printf(YELLOW, "%X.%X.%X\n", product_ver.major, product_ver.minor, product_ver.revision);
|
||||||
printf(GREEN, " Component version: ");
|
printf(GREEN, " Component version: ");
|
||||||
printf(YELLOW, "%X.%X.%X\n", component_ver.major, component_ver.minor, component_ver.revision);
|
printf(YELLOW, "%X.%X.%X\n", component_ver.major, component_ver.minor, component_ver.revision);
|
||||||
|
|
||||||
printf(GREEN, " Drive tag: ");
|
printf(GREEN, " Drive tag: ");
|
||||||
printf(YELLOW, "%x\n", header->drive_tag);
|
printf(YELLOW, "%x\n", header->drive_tag);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -165,4 +165,4 @@ void sb1_dump(struct sb1_file_t *file, void *u, sb1_color_printf printf);
|
||||||
void sb1_free(struct sb1_file_t *file);
|
void sb1_free(struct sb1_file_t *file);
|
||||||
|
|
||||||
#endif /* __SB1_H__ */
|
#endif /* __SB1_H__ */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -340,7 +340,7 @@ static int probe_hid_xfer_size(libusb_device_handle *dev)
|
||||||
size -= item.total_size;
|
size -= item.total_size;
|
||||||
}
|
}
|
||||||
return xfer_size / 8;
|
return xfer_size / 8;
|
||||||
|
|
||||||
Lerr:
|
Lerr:
|
||||||
printf("Cannot probe transfer size, please specify it on command line.\n");
|
printf("Cannot probe transfer size, please specify it on command line.\n");
|
||||||
exit(11);
|
exit(11);
|
||||||
|
|
|
||||||
|
|
@ -86,10 +86,10 @@ static void extract_elf_section(struct elf_params_t *elf, int count, uint32_t id
|
||||||
sprintf(filename, "%s%s.%d.elf", g_out_prefix, name, count);
|
sprintf(filename, "%s%s.%d.elf", g_out_prefix, name, count);
|
||||||
if(g_debug)
|
if(g_debug)
|
||||||
printf("Write boot section %s to %s\n", name, filename);
|
printf("Write boot section %s to %s\n", name, filename);
|
||||||
|
|
||||||
FILE *fd = fopen(filename, "wb");
|
FILE *fd = fopen(filename, "wb");
|
||||||
free(filename);
|
free(filename);
|
||||||
|
|
||||||
if(fd == NULL)
|
if(fd == NULL)
|
||||||
return;
|
return;
|
||||||
if(g_elf_simplify)
|
if(g_elf_simplify)
|
||||||
|
|
@ -112,7 +112,7 @@ static void extract_sb_section(struct sb_section_t *sec)
|
||||||
if(g_debug)
|
if(g_debug)
|
||||||
printf("Write data section %s to %s\n", sec_name, filename);
|
printf("Write data section %s to %s\n", sec_name, filename);
|
||||||
free(filename);
|
free(filename);
|
||||||
|
|
||||||
for(int j = 0; j < sec->nr_insts; j++)
|
for(int j = 0; j < sec->nr_insts; j++)
|
||||||
{
|
{
|
||||||
assert(sec->insts[j].inst == SB_INST_DATA);
|
assert(sec->insts[j].inst == SB_INST_DATA);
|
||||||
|
|
@ -494,7 +494,7 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
if(loopback)
|
if(loopback)
|
||||||
sb1_write_file(file, loopback);
|
sb1_write_file(file, loopback);
|
||||||
|
|
||||||
sb1_free(file);
|
sb1_free(file);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -504,6 +504,6 @@ int main(int argc, char **argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
clear_keys();
|
clear_keys();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ void sha_1_block(struct sha_1_params_t *params, uint32_t cur_hash[5], byte *data
|
||||||
memmove(w, data, 64);
|
memmove(w, data, 64);
|
||||||
for(int i = 0; i < 16; i++)
|
for(int i = 0; i < 16; i++)
|
||||||
byte_swap32(&w[i]);
|
byte_swap32(&w[i]);
|
||||||
|
|
||||||
for(int i = 16; i <= 79; i++)
|
for(int i = 16; i <= 79; i++)
|
||||||
w[i] = rot_left(w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16], 1);
|
w[i] = rot_left(w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16], 1);
|
||||||
|
|
||||||
|
|
@ -141,7 +141,7 @@ void sha_1_block(struct sha_1_params_t *params, uint32_t cur_hash[5], byte *data
|
||||||
a = temp;
|
a = temp;
|
||||||
}
|
}
|
||||||
#undef w
|
#undef w
|
||||||
|
|
||||||
cur_hash[0] += a;
|
cur_hash[0] += a;
|
||||||
cur_hash[1] += b;
|
cur_hash[1] += b;
|
||||||
cur_hash[2] += c;
|
cur_hash[2] += c;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue