diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2013-06-15 22:19:52 +0200 |
---|---|---|
committer | Amaury Pouly <amaury.pouly@gmail.com> | 2013-06-15 22:27:34 +0200 |
commit | 7c7fa369186536adaf9ff35ec356525b5c5a8379 (patch) | |
tree | bc70e26ffcc48a7d0a0a40e7c33e0cd48bd265fa /utils | |
parent | 58e27b9fa1e9ea058eb5161f140e0909c4821c92 (diff) |
sbtools,mkximboot: fix whitespace
Change-Id: I8d8adb783707172d1aaef302366c240310350ed8
Diffstat (limited to 'utils')
-rw-r--r-- | utils/imxtools/sbtools/crypto.c | 8 | ||||
-rw-r--r-- | utils/imxtools/sbtools/dbparser.c | 2 | ||||
-rw-r--r-- | utils/imxtools/sbtools/elf.c | 20 | ||||
-rw-r--r-- | utils/imxtools/sbtools/elftosb.c | 14 | ||||
-rw-r--r-- | utils/imxtools/sbtools/elftosb1.c | 6 | ||||
-rw-r--r-- | utils/imxtools/sbtools/rsrc.c | 10 | ||||
-rw-r--r-- | utils/imxtools/sbtools/rsrc.h | 2 | ||||
-rw-r--r-- | utils/imxtools/sbtools/rsrctool.c | 2 | ||||
-rw-r--r-- | utils/imxtools/sbtools/sb.c | 74 | ||||
-rw-r--r-- | utils/imxtools/sbtools/sb.h | 4 | ||||
-rw-r--r-- | utils/imxtools/sbtools/sb1.c | 6 | ||||
-rw-r--r-- | utils/imxtools/sbtools/sb1.h | 2 | ||||
-rw-r--r-- | utils/imxtools/sbtools/sbloader.c | 2 | ||||
-rw-r--r-- | utils/imxtools/sbtools/sbtoelf.c | 10 | ||||
-rw-r--r-- | utils/imxtools/sbtools/sha1.c | 4 |
15 files changed, 83 insertions, 83 deletions
diff --git a/utils/imxtools/sbtools/crypto.c b/utils/imxtools/sbtools/crypto.c index d4afc6c816..4f7b799dd9 100644 --- a/utils/imxtools/sbtools/crypto.c +++ b/utils/imxtools/sbtools/crypto.c @@ -68,7 +68,7 @@ int crypto_apply( { if(out_cbc_mac && !encrypt) memcpy(*out_cbc_mac, in_data + 16 * (nr_blocks - 1), 16); - + libusb_device_handle *handle = NULL; libusb_context *ctx; /* init library */ @@ -97,7 +97,7 @@ int crypto_apply( printf("usbotp: configuration: %d\n", config_id); printf("usbotp: interfaces: %d\n", config->bNumInterfaces); } - + const struct libusb_endpoint_descriptor *endp = NULL; int intf, intf_alt; for(intf = 0; intf < config->bNumInterfaces; intf++) @@ -147,7 +147,7 @@ int crypto_apply( buffer_size, &recv_size, 1000); libusb_release_interface(handle, intf); libusb_close(handle); - + if(ret < 0) { if(g_debug) @@ -166,7 +166,7 @@ int crypto_apply( memcpy(out_data, buffer + 16, 16 * nr_blocks); if(out_cbc_mac && encrypt) memcpy(*out_cbc_mac, buffer + buffer_size - 16, 16); - + return CRYPTO_ERROR_SUCCESS; } #endif diff --git a/utils/imxtools/sbtools/dbparser.c b/utils/imxtools/sbtools/dbparser.c index 89a63b3767..37f812d585 100644 --- a/utils/imxtools/sbtools/dbparser.c +++ b/utils/imxtools/sbtools/dbparser.c @@ -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->addr = parse_intexpr(&lctx, cmd_file->constant_list); } - + if(lexem.type == LEX_LPAREN) { next(true); diff --git a/utils/imxtools/sbtools/elf.c b/utils/imxtools/sbtools/elf.c index c41fc27fdd..5626c0f58c 100644 --- a/utils/imxtools/sbtools/elf.c +++ b/utils/imxtools/sbtools/elf.c @@ -208,9 +208,9 @@ void elf_add_fill_section(struct elf_params_t *params, printf("oops, non-zero filling, ignore fill section\n"); return; } - + struct elf_section_t *sec = elf_add_section(params); - + sec->type = EST_FILL; sec->addr = fill_addr; sec->size = size; @@ -239,7 +239,7 @@ void elf_simplify(struct elf_params_t *params) nr_sections++; cur_sec = cur_sec->next; } - + /* put all sections in an array and free list */ struct elf_section_t *sections = malloc(sizeof(struct elf_section_t) * nr_sections); 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) { (void) printf; - + Elf32_Ehdr ehdr; uint32_t phnum = 0; 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; } - + phnum++; 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" */ char *strtbl_content = malloc(1 + strlen(".shstrtab") + 1 + phnum * (strlen(".textXXXX") + 1)); - + strtbl_content[0] = '\0'; strcpy(&strtbl_content[1], ".shstrtab"); 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) { sec->offset += data_offset; - + phdr.p_type = PT_LOAD; if(sec->type == EST_LOAD) 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) { #define error_printf(...) ({printf(user, true, __VA_ARGS__); return false;}) - + /* read header */ Elf32_Ehdr 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) printf(user, false, "filter out %s\n", &strtab[shdr.sh_name], shdr.sh_type); } - + } free(strtab); /* 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", seg->vaddr, seg->vsize, seg->paddr, seg->psize); } - + return true; } diff --git a/utils/imxtools/sbtools/elftosb.c b/utils/imxtools/sbtools/elftosb.c index 22a5b58753..fd44693a94 100644 --- a/utils/imxtools/sbtools/elftosb.c +++ b/utils/imxtools/sbtools/elftosb.c @@ -18,7 +18,7 @@ * KIND, either express or implied. * ****************************************************************************/ - + #define _ISOC99_SOURCE #define _POSIX_C_SOURCE 200809L /* for strdup */ #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->component_ver); - + if(g_debug) printf("Applying command file...\n"); /* count sections */ @@ -246,7 +246,7 @@ static struct sb_file_t *apply_cmd_file(struct cmd_file_t *cmd_file) } else bug("die\n"); - + cinst = cinst->next; } @@ -308,7 +308,7 @@ static struct sb_file_t *apply_cmd_file(struct cmd_file_t *cmd_file) } else bug("die\n"); - + cinst = cinst->next; } } @@ -347,7 +347,7 @@ int main(int argc, char **argv) struct crypto_key_t crypto_iv; real_key.method = CRYPTO_NONE; crypto_iv.method = CRYPTO_NONE; - + while(1) { 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->flags = 0; sb_file->minor_version = 1; - + sb_write_file(sb_file, output_filename); sb_free(sb_file); clear_keys(); - + return 0; } diff --git a/utils/imxtools/sbtools/elftosb1.c b/utils/imxtools/sbtools/elftosb1.c index 1f33058eca..be9201c396 100644 --- a/utils/imxtools/sbtools/elftosb1.c +++ b/utils/imxtools/sbtools/elftosb1.c @@ -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 @@ -586,7 +586,7 @@ static void usage(void) printf(" -N/-nonstrict\t\t\tClear strict flag\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"); - + exit(1); } @@ -623,4 +623,4 @@ int main(int argc, char **argv) return ret; } - + diff --git a/utils/imxtools/sbtools/rsrc.c b/utils/imxtools/sbtools/rsrc.c index 8967c0ed15..a3bc150fa1 100644 --- a/utils/imxtools/sbtools/rsrc.c +++ b/utils/imxtools/sbtools/rsrc.c @@ -161,12 +161,12 @@ static bool read_entries(struct rsrc_file_t *f, void *u, printf(RED, "%c", isprint(p[i]) ? p[i] : '.'); } printf(OFF, "\n"); - + if(RSRC_TABLE_ENTRY_TYPE(te) == RSRC_TYPE_NESTED) { char *p = prefix + strlen(prefix); sprintf(p, "%s| ", RED); - + bool ok = read_entries(f, u, cprintf, err, RSRC_TABLE_ENTRY_OFFSET(te), index, level - 1, prefix); @@ -175,7 +175,7 @@ static bool read_entries(struct rsrc_file_t *f, void *u, *p = 0; } } - + return true; #undef printf #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); if(!ok) fatal(*err, "Error while parsing rsrc table\n"); - + return rsrc_file; #undef printf #undef fatal @@ -253,4 +253,4 @@ void rsrc_dump(struct rsrc_file_t *file, void *u, rsrc_color_printf cprintf) #undef printf #undef print_hex } - + diff --git a/utils/imxtools/sbtools/rsrc.h b/utils/imxtools/sbtools/rsrc.h index 3e03d97d73..c3e0bdfb37 100644 --- a/utils/imxtools/sbtools/rsrc.h +++ b/utils/imxtools/sbtools/rsrc.h @@ -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); #endif /* __RSRC_H__ */ - + diff --git a/utils/imxtools/sbtools/rsrctool.c b/utils/imxtools/sbtools/rsrctool.c index 53235365ae..f95542fc49 100644 --- a/utils/imxtools/sbtools/rsrctool.c +++ b/utils/imxtools/sbtools/rsrctool.c @@ -199,4 +199,4 @@ int main(int argc, char **argv) return 0; } - + diff --git a/utils/imxtools/sbtools/sb.c b/utils/imxtools/sbtools/sb.c index 2625d770c2..f64da8ff84 100644 --- a/utils/imxtools/sbtools/sb.c +++ b/utils/imxtools/sbtools/sb.c @@ -63,7 +63,7 @@ static void compute_sb_offsets(struct sb_file_t *sb) if((i + 1) < sb->nr_sections) alignment = sb->sections[i + 1].alignment; alignment /= BLOCK_SIZE; /* alignment in block sizes */ - + struct sb_section_t *sec = &sb->sections[i]; sec->sec_size = 0; @@ -75,7 +75,7 @@ static void compute_sb_offsets(struct sb_file_t *sb) printf(" (cleartext)"); printf("\n"); } - + sec->file_offset = sb->image_size; 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) { struct sha_1_params_t sha_1_params; - + sb_hdr->signature[0] = 'S'; sb_hdr->signature[1] = 'T'; 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' */ if(sb->minor_version >= 1) memcpy(&sb_hdr->rand_pad0[2], "sgtl", 4); - + sb_hdr->timestamp = generate_timestamp(); sb_hdr->product_ver = sb->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_p = buf; #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)); write(&sb_hdr, sizeof(sb_hdr)); - + memcpy(crypto_iv, &sb_hdr, 16); /* update CBC-MACs */ for(int i = 0; i < g_nr_keys; i++) crypto_cbc((byte *)&sb_hdr, NULL, sizeof(sb_hdr) / BLOCK_SIZE, &g_key_array[i], cbc_macs[i], &cbc_macs[i], 1); - + /* produce and write section headers */ 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); crypto_cbc(real_key.u.key, entry.key, 1, &g_key_array[i], crypto_iv, NULL, 1); - + write(&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 !"); return SB_ERROR; } - + FILE *fd = fopen(filename, "wb"); if(fd == NULL) 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); \ free(sec); \ return NULL; } while(0) - + struct sb_section_t *sec = xmalloc(sizeof(struct sb_section_t)); memset(sec, 0, sizeof(struct sb_section_t)); sec->identifier = id; sec->is_data = data_sec; sec->sec_size = ROUND_UP(size, BLOCK_SIZE) / BLOCK_SIZE; - + if(data_sec) { 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]; inst.inst = hdr->opcode; - + printf(OFF, "%s", indent); uint8_t checksum = instruction_checksum(hdr); 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.addr = load->addr; inst.data = memdup(load + 1, load->len); - + printf(RED, "LOAD"); printf(OFF, " | "); 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.size = fill->len; inst.addr = fill->addr; - + printf(RED, "FILL"); printf(OFF, " | "); 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]; inst.addr = call->addr; inst.argument = call->arg; - + if(is_call) printf(RED, "CALL"); 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; inst.argument = mode->mode; - + printf(RED, "MODE"); printf(OFF, " | "); printf(BLUE, "mod=0x%08x\n", mode->mode); - + pos += sizeof(struct sb_instruction_mode_t); } 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; uint8_t *buf = _buf; - + #define printf(c, ...) cprintf(u, false, c, __VA_ARGS__) #define fatal(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) #define print_hex(c, p, len, nl) \ do { printf(c, ""); print_hex(p, len, nl); } while(0) - + struct sha_1_params_t sha_1_params; sb_file = xmalloc(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(GREEN, " Total file size : "); printf(YELLOW, "%ld\n", filesize); - + /* Sizes and offsets */ printf(BLUE, "Sizes and offsets:\n"); 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); printf(GREEN, " Random 2: "); print_hex(YELLOW, sb_header->rand_pad1, sizeof(sb_header->rand_pad1), true); - + uint64_t micros = sb_header->timestamp; time_t seconds = (micros / (uint64_t)1000000L); 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(GREEN, " Component version = "); printf(YELLOW, "%X.%X.%X\n", component_ver.major, component_ver.minor, component_ver.revision); - + printf(GREEN, " Drive tag = "); printf(YELLOW, "%x\n", sb_header->drive_tag); 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 */ byte real_key[16]; bool valid_key = false; /* false until a matching key was found */ - + if(sb_header->nr_keys > 0) { 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); struct sb_section_header_t *sec_hdr = (struct sb_section_header_t *)&buf[ofs]; - + char name[5]; sb_fill_section_name(name, sec_hdr->identifier); int pos = sec_hdr->offset * BLOCK_SIZE; int size = sec_hdr->size * BLOCK_SIZE; int data_sec = !(sec_hdr->flags & SECTION_BOOTABLE); int encrypted = !(sec_hdr->flags & SECTION_CLEARTEXT) && sb_header->nr_keys > 0; - + printf(GREEN, " Section "); printf(YELLOW, "'%s'\n", name); 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"); continue; } - + /* save it */ byte *sec = xmalloc(size); if(encrypted) @@ -954,7 +954,7 @@ struct sb_file_t *sb_read_memory(void *_buf, size_t filesize, bool raw_mode, voi } else fatal(*err, "Error reading section\n"); - + 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); if(checksum != hdr->checksum) printf(GREY, "[Bad checksum']"); - + if(hdr->opcode == SB_INST_NOP) { 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 data_sec = !(tag->flags & SECTION_BOOTABLE); int encrypted = !(tag->flags & SECTION_CLEARTEXT) && sb_header->nr_keys > 0; - + printf(GREEN, "%sSection ", indent); printf(YELLOW, "'%s'\n", name); 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); else memcpy(sec, buf + pos, size); - + struct sb_section_t *s = read_section(data_sec, tag->identifier, sec, size, " ", u, cprintf, err); 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"); } - + /* final signature */ printf(BLUE, "Final signature:\n"); 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"); fatal(SB_CHECKSUM_ERROR, "File SHA-1 error\n"); } - + return sb_file; #undef printf #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 print_hex(c, p, len, nl) \ do { printf(c, ""); print_hex(p, len, nl); } while(0) - + #define TREE RED #define HEADER GREEN #define TEXT YELLOW #define TEXT2 BLUE #define SEP OFF - + printf(BLUE, "SB File\n"); printf(TREE, "+-"); printf(HEADER, "Version: "); @@ -1153,7 +1153,7 @@ void sb_dump(struct sb_file_t *file, void *u, sb_color_printf cprintf) char name[5]; sb_fill_section_name(name, file->first_boot_sec_id); printf(TEXT, "%08x (%s)\n", file->first_boot_sec_id, name); - + if(file->override_real_key) { 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(TEXT, "%X.%X.%X\n", file->component_ver.major, file->component_ver.minor, file->component_ver.revision); - + for(int i = 0; i < file->nr_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 print_hex } diff --git a/utils/imxtools/sbtools/sb.h b/utils/imxtools/sbtools/sb.h index 74d86f303a..4873195a61 100644 --- a/utils/imxtools/sbtools/sb.h +++ b/utils/imxtools/sbtools/sb.h @@ -180,7 +180,7 @@ struct sb_section_t bool is_data; bool is_cleartext; 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; struct sb_inst_t *insts; /* for production use */ @@ -196,7 +196,7 @@ struct sb_file_t /* override crypto IV, use with caution ! Use NULL to generate it */ bool override_crypto_iv; uint8_t crypto_iv[16]; - + int nr_sections; uint16_t drive_tag; uint32_t first_boot_sec_id; diff --git a/utils/imxtools/sbtools/sb1.c b/utils/imxtools/sbtools/sb1.c index deb09a51e1..bb9b3d5035 100644 --- a/utils/imxtools/sbtools/sb1.c +++ b/utils/imxtools/sbtools/sb1.c @@ -184,7 +184,7 @@ enum sb1_error_t sb1_write_file(struct sb1_file_t *sb, const char *filename) if(sb->userdata) fwrite(sb->userdata, sb->userdata_size, 1, fd); fclose(fd); - + 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; union xorcrypt_key_t key[2]; - + uint8_t sector[SECTOR_SIZE]; /* copy key and data because it's modified by the crypto code */ 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(GREEN, " Component version: "); printf(YELLOW, "%X.%X.%X\n", component_ver.major, component_ver.minor, component_ver.revision); - + printf(GREEN, " Drive tag: "); printf(YELLOW, "%x\n", header->drive_tag); diff --git a/utils/imxtools/sbtools/sb1.h b/utils/imxtools/sbtools/sb1.h index 2adfc6a26c..83ff0e7431 100644 --- a/utils/imxtools/sbtools/sb1.h +++ b/utils/imxtools/sbtools/sb1.h @@ -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); #endif /* __SB1_H__ */ - + diff --git a/utils/imxtools/sbtools/sbloader.c b/utils/imxtools/sbtools/sbloader.c index 657ef5d578..01b9fe6c01 100644 --- a/utils/imxtools/sbtools/sbloader.c +++ b/utils/imxtools/sbtools/sbloader.c @@ -340,7 +340,7 @@ static int probe_hid_xfer_size(libusb_device_handle *dev) size -= item.total_size; } return xfer_size / 8; - + Lerr: printf("Cannot probe transfer size, please specify it on command line.\n"); exit(11); diff --git a/utils/imxtools/sbtools/sbtoelf.c b/utils/imxtools/sbtools/sbtoelf.c index e68f5e6e06..75dc58e4bd 100644 --- a/utils/imxtools/sbtools/sbtoelf.c +++ b/utils/imxtools/sbtools/sbtoelf.c @@ -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); if(g_debug) printf("Write boot section %s to %s\n", name, filename); - + FILE *fd = fopen(filename, "wb"); free(filename); - + if(fd == NULL) return; if(g_elf_simplify) @@ -112,7 +112,7 @@ static void extract_sb_section(struct sb_section_t *sec) if(g_debug) printf("Write data section %s to %s\n", sec_name, filename); free(filename); - + for(int j = 0; j < sec->nr_insts; j++) { assert(sec->insts[j].inst == SB_INST_DATA); @@ -494,7 +494,7 @@ int main(int argc, char **argv) } if(loopback) sb1_write_file(file, loopback); - + sb1_free(file); } else @@ -504,6 +504,6 @@ int main(int argc, char **argv) return 1; } clear_keys(); - + return 0; } diff --git a/utils/imxtools/sbtools/sha1.c b/utils/imxtools/sbtools/sha1.c index 0ad05bb5cd..cb34059166 100644 --- a/utils/imxtools/sbtools/sha1.c +++ b/utils/imxtools/sbtools/sha1.c @@ -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); for(int i = 0; i < 16; i++) byte_swap32(&w[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); @@ -141,7 +141,7 @@ void sha_1_block(struct sha_1_params_t *params, uint32_t cur_hash[5], byte *data a = temp; } #undef w - + cur_hash[0] += a; cur_hash[1] += b; cur_hash[2] += c; |