Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

imxtools: Replace use of "byte" with its underlying uint8_t.

libtomcrypt uses a macro "byte" which conflicts with this type. Since
the underlying type is uint8_t and there's no real benefit from using a
custom type use the actual underlying type.

Change-Id: I982c9b8bdcb657b99fa645a5235303af7afda25b

+69 -70
+1 -1
rbutil/mkimxboot/mkimxboot.c
··· 655 655 } 656 656 for(int j = 0; j < 16; j++) 657 657 { 658 - byte a, b; 658 + uint8_t a, b; 659 659 if(convxdigit(imx_sums[i].md5sum[2 * j], &a) || convxdigit(imx_sums[i].md5sum[2 * j + 1], &b)) 660 660 { 661 661 printf("[ERR][INTERNAL] Bad checksum format: %s\n", imx_sums[i].md5sum);
+2 -2
utils/imxtools/sbtools/crc.c
··· 68 68 0x0B8757BDA, 0x0B5365D03, 0x0B1F740B4 69 69 }; 70 70 71 - uint32_t crc(byte *data, int size) 71 + uint32_t crc(uint8_t *data, int size) 72 72 { 73 73 return crc_continue(0xffffffff, data, size); 74 74 } 75 75 76 - uint32_t crc_continue(uint32_t previous_crc, byte *data, int size) 76 + uint32_t crc_continue(uint32_t previous_crc, uint8_t *data, int size) 77 77 { 78 78 uint32_t c = previous_crc; 79 79 /* normal CRC */
+14 -14
utils/imxtools/sbtools/crypto.cpp
··· 30 30 { 31 31 32 32 enum crypto_method_t g_cur_method = CRYPTO_NONE; 33 - byte g_key[16]; 33 + uint8_t g_key[16]; 34 34 CBC_Mode<AES>::Encryption g_aes_enc; 35 35 CBC_Mode<AES>::Decryption g_aes_dec; 36 36 bool g_aes_enc_key_dirty; /* true of g_aes_enc key needs to be updated */ 37 37 bool g_aes_dec_key_dirty; /* same for g_aes_dec */ 38 38 39 39 int cbc_mac2( 40 - const byte *in_data, /* Input data */ 41 - byte *out_data, /* Output data (or NULL) */ 40 + const uint8_t *in_data, /* Input data */ 41 + uint8_t *out_data, /* Output data (or NULL) */ 42 42 int nr_blocks, /* Number of blocks to encrypt/decrypt (one block=16 bytes) */ 43 - byte key[16], /* Key */ 44 - byte iv[16], /* Initialisation Vector */ 45 - byte (*out_cbc_mac)[16], /* CBC-MAC of the result (or NULL) */ 43 + uint8_t key[16], /* Key */ 44 + uint8_t iv[16], /* Initialisation Vector */ 45 + uint8_t (*out_cbc_mac)[16], /* CBC-MAC of the result (or NULL) */ 46 46 bool encrypt /* 1 to encrypt, 0 to decrypt */ 47 47 ) 48 48 { ··· 58 58 g_aes_enc_key_dirty = false; 59 59 } 60 60 g_aes_enc.Resynchronize(iv, 16); 61 - byte tmp[16]; 61 + uint8_t tmp[16]; 62 62 /* we need some output buffer, either a temporary one if we are CBC-MACing 63 63 * only, or use output buffer if available */ 64 - byte *out_ptr = (out_data == NULL) ? tmp : out_data; 64 + uint8_t *out_ptr = (out_data == NULL) ? tmp : out_data; 65 65 while(nr_blocks-- > 0) 66 66 { 67 67 g_aes_enc.ProcessData(out_ptr, in_data, 16); ··· 113 113 } 114 114 115 115 int crypto_apply( 116 - byte *in_data, /* Input data */ 117 - byte *out_data, /* Output data (or NULL) */ 116 + uint8_t *in_data, /* Input data */ 117 + uint8_t *out_data, /* Output data (or NULL) */ 118 118 int nr_blocks, /* Number of blocks (one block=16 bytes) */ 119 - byte iv[16], /* Key */ 120 - byte (*out_cbc_mac)[16], /* CBC-MAC of the result (or NULL) */ 119 + uint8_t iv[16], /* Key */ 120 + uint8_t (*out_cbc_mac)[16], /* CBC-MAC of the result (or NULL) */ 121 121 bool encrypt) 122 122 { 123 123 if(g_cur_method == CRYPTO_KEY) ··· 131 131 params->object = new SHA1; 132 132 } 133 133 134 - void sha_1_update(struct sha_1_params_t *params, byte *buffer, int size) 134 + void sha_1_update(struct sha_1_params_t *params, uint8_t *buffer, int size) 135 135 { 136 136 reinterpret_cast<SHA1 *>(params->object)->Update(buffer, size); 137 137 } ··· 143 143 delete obj; 144 144 } 145 145 146 - void sha_1_output(struct sha_1_params_t *params, byte *out) 146 + void sha_1_output(struct sha_1_params_t *params, uint8_t *out) 147 147 { 148 148 memcpy(out, params->hash, 20); 149 149 }
+10 -12
utils/imxtools/sbtools/crypto.h
··· 30 30 extern "C" { 31 31 #endif 32 32 33 - typedef uint8_t byte; 34 - 35 33 /* crypto.cpp */ 36 34 enum crypto_method_t 37 35 { ··· 52 50 enum crypto_method_t method; 53 51 union 54 52 { 55 - byte key[16]; 53 + uint8_t key[16]; 56 54 union xorcrypt_key_t xor_key[2]; 57 55 }u; 58 56 }; ··· 68 66 69 67 /* return 0 on success, <0 on error */ 70 68 int crypto_apply( 71 - byte *in_data, /* Input data */ 72 - byte *out_data, /* Output data (or NULL) */ 69 + uint8_t *in_data, /* Input data */ 70 + uint8_t *out_data, /* Output data (or NULL) */ 73 71 int nr_blocks, /* Number of blocks (one block=16 bytes) */ 74 - byte iv[16], /* IV */ 75 - byte (*out_cbc_mac)[16], /* CBC-MAC of the result (or NULL) */ 72 + uint8_t iv[16], /* IV */ 73 + uint8_t (*out_cbc_mac)[16], /* CBC-MAC of the result (or NULL) */ 76 74 bool encrypt); 77 75 78 76 /* crc.c */ 79 - uint32_t crc(byte *data, int size); 80 - uint32_t crc_continue(uint32_t previous_crc, byte *data, int size); 77 + uint32_t crc(uint8_t *data, int size); 78 + uint32_t crc_continue(uint32_t previous_crc, uint8_t *data, int size); 81 79 82 80 /* sha1.c */ 83 81 struct sha_1_params_t 84 82 { 85 - byte hash[20]; /* final hash */ 83 + uint8_t hash[20]; /* final hash */ 86 84 void *object; /* pointer to CryptoPP::SHA1 object */ 87 85 }; 88 86 89 87 void sha_1_init(struct sha_1_params_t *params); 90 - void sha_1_update(struct sha_1_params_t *params, byte *buffer, int size); 88 + void sha_1_update(struct sha_1_params_t *params, uint8_t *buffer, int size); 91 89 void sha_1_finish(struct sha_1_params_t *params); 92 - void sha_1_output(struct sha_1_params_t *params, byte *out); 90 + void sha_1_output(struct sha_1_params_t *params, uint8_t *out); 93 91 94 92 /* xorcrypt.c */ 95 93
+1 -1
utils/imxtools/sbtools/dbparser.c
··· 207 207 { 208 208 if(base == 10 && !isdigit(cur_char(ctx))) 209 209 break; 210 - byte v; 210 + uint8_t v; 211 211 if(convxdigit(cur_char(ctx), &v)) 212 212 break; 213 213 lexem->num = base * lexem->num + v;
+4 -4
utils/imxtools/sbtools/misc.c
··· 58 58 return r; 59 59 } 60 60 61 - int convxdigit(char digit, byte *val) 61 + int convxdigit(char digit, uint8_t *val) 62 62 { 63 63 if(digit >= '0' && digit <= '9') 64 64 { ··· 127 127 { 128 128 for(int j = 0; j < 128; j++) 129 129 { 130 - byte a, b; 130 + uint8_t a, b; 131 131 if(convxdigit(str[2 * j], &a) || convxdigit(str[2 * j + 1], &b)) 132 132 return false; 133 133 key->u.xor_key[j / 64].key[j % 64] = (a << 4) | b; ··· 143 143 return false; 144 144 for(int j = 0; j < 16; j++) 145 145 { 146 - byte a, b; 146 + uint8_t a, b; 147 147 if(convxdigit(str[2 * j], &a) || convxdigit(str[2 * j + 1], &b)) 148 148 return false; 149 149 key->u.key[j] = (a << 4) | b; ··· 243 243 return true; 244 244 } 245 245 246 - void print_hex(void *user, misc_printf_t printf, byte *data, int len, bool newline) 246 + void print_hex(void *user, misc_printf_t printf, uint8_t *data, int len, bool newline) 247 247 { 248 248 for(int i = 0; i < len; i++) 249 249 printf(user, "%02X ", data[i]);
+3 -2
utils/imxtools/sbtools/misc.h
··· 22 22 #define __MISC_H__ 23 23 24 24 #include <stdbool.h> 25 + #include <stdint.h> 25 26 #include "crypto.h" 26 27 27 28 #define _STR(a) #a ··· 53 54 void *aug, int aug_cnt); 54 55 void generate_random_data(void *buf, size_t sz); 55 56 void *xmalloc(size_t s); 56 - int convxdigit(char digit, byte *val); 57 - void print_hex(void *user, misc_printf_t printf, byte *data, int len, bool newline); 57 + int convxdigit(char digit, uint8_t *val); 58 + void print_hex(void *user, misc_printf_t printf, uint8_t *data, int len, bool newline); 58 59 void add_keys(key_array_t ka, int kac); 59 60 bool parse_key(char **str, struct crypto_key_t *key); 60 61 bool add_keys_from_file(const char *key_file);
+34 -34
utils/imxtools/sbtools/sb.c
··· 223 223 static uint8_t instruction_checksum(struct sb_instruction_header_t *hdr) 224 224 { 225 225 uint8_t sum = 90; 226 - byte *ptr = (byte *)hdr; 226 + uint8_t *ptr = (uint8_t *)hdr; 227 227 for(int i = 1; i < 16; i++) 228 228 sum += ptr[i]; 229 229 return sum; ··· 287 287 #define printf(c, ...) cprintf(u, false, c, __VA_ARGS__) 288 288 struct crypto_key_t real_key; 289 289 real_key.method = CRYPTO_KEY; 290 - byte crypto_iv[16]; 291 - byte (*cbc_macs)[16] = xmalloc(16 * g_nr_keys); 290 + uint8_t crypto_iv[16]; 291 + uint8_t (*cbc_macs)[16] = xmalloc(16 * g_nr_keys); 292 292 /* init CBC-MACs */ 293 293 for(int i = 0; i < g_nr_keys; i++) 294 294 memset(cbc_macs[i], 0, 16); ··· 319 319 struct sb_header_t sb_hdr; 320 320 produce_sb_header(sb, &sb_hdr); 321 321 /* allocate image */ 322 - byte *buf = xmalloc(sb_hdr.image_size * BLOCK_SIZE); 323 - byte *buf_p = buf; 322 + uint8_t *buf = xmalloc(sb_hdr.image_size * BLOCK_SIZE); 323 + uint8_t *buf_p = buf; 324 324 #define write(p, sz) do { memcpy(buf_p, p, sz); buf_p += sz; } while(0) 325 325 #define check_crypto(expr) \ 326 326 do { int err = expr; \ ··· 329 329 cprintf(u, true, GREY, "Crypto error: %d\n", err); \ 330 330 return SB_CRYPTO_ERROR; } } while(0) 331 331 332 - sha_1_update(&file_sha1, (byte *)&sb_hdr, sizeof(sb_hdr)); 332 + sha_1_update(&file_sha1, (uint8_t *)&sb_hdr, sizeof(sb_hdr)); 333 333 write(&sb_hdr, sizeof(sb_hdr)); 334 334 335 335 memcpy(crypto_iv, &sb_hdr, 16); ··· 338 338 for(int i = 0; i < g_nr_keys; i++) 339 339 { 340 340 check_crypto(crypto_setup(&g_key_array[i])); 341 - check_crypto(crypto_apply((byte *)&sb_hdr, NULL, sizeof(sb_hdr) / BLOCK_SIZE, 341 + check_crypto(crypto_apply((uint8_t *)&sb_hdr, NULL, sizeof(sb_hdr) / BLOCK_SIZE, 342 342 cbc_macs[i], &cbc_macs[i], true)); 343 343 } 344 344 ··· 347 347 { 348 348 struct sb_section_header_t sb_sec_hdr; 349 349 produce_sb_section_header(&sb->sections[i], &sb_sec_hdr); 350 - sha_1_update(&file_sha1, (byte *)&sb_sec_hdr, sizeof(sb_sec_hdr)); 350 + sha_1_update(&file_sha1, (uint8_t *)&sb_sec_hdr, sizeof(sb_sec_hdr)); 351 351 write(&sb_sec_hdr, sizeof(sb_sec_hdr)); 352 352 /* update CBC-MACs */ 353 353 for(int j = 0; j < g_nr_keys; j++) 354 354 { 355 355 check_crypto(crypto_setup(&g_key_array[j])); 356 - check_crypto(crypto_apply((byte *)&sb_sec_hdr, NULL, 356 + check_crypto(crypto_apply((uint8_t *)&sb_sec_hdr, NULL, 357 357 sizeof(sb_sec_hdr) / BLOCK_SIZE, cbc_macs[j], &cbc_macs[j], true)); 358 358 } 359 359 } ··· 365 365 check_crypto(crypto_setup(&g_key_array[i])); 366 366 check_crypto(crypto_apply(real_key.u.key, entry.key, 1, crypto_iv, NULL, true)); 367 367 write(&entry, sizeof(entry)); 368 - sha_1_update(&file_sha1, (byte *)&entry, sizeof(entry)); 368 + sha_1_update(&file_sha1, (uint8_t *)&entry, sizeof(entry)); 369 369 } 370 370 371 371 /* HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK */ ··· 391 391 unsigned init_gap = (sb->sections[0].file_offset - 1) * BLOCK_SIZE - (buf_p - buf); 392 392 if(init_gap > 0) 393 393 { 394 - byte *data = xmalloc(init_gap); 394 + uint8_t *data = xmalloc(init_gap); 395 395 generate_random_data(data, init_gap); 396 396 sha_1_update(&file_sha1, data, init_gap); 397 397 write(data, init_gap); ··· 407 407 produce_section_tag_cmd(&sb->sections[i], &tag_cmd, (i + 1) == sb_hdr.nr_sections); 408 408 if(g_nr_keys > 0) 409 409 { 410 - check_crypto(crypto_apply((byte *)&tag_cmd, (byte *)&tag_cmd, 410 + check_crypto(crypto_apply((uint8_t *)&tag_cmd, (uint8_t *)&tag_cmd, 411 411 sizeof(tag_cmd) / BLOCK_SIZE, crypto_iv, NULL, true)); 412 412 } 413 - sha_1_update(&file_sha1, (byte *)&tag_cmd, sizeof(tag_cmd)); 413 + sha_1_update(&file_sha1, (uint8_t *)&tag_cmd, sizeof(tag_cmd)); 414 414 write(&tag_cmd, sizeof(tag_cmd)); 415 415 /* produce other commands */ 416 - byte cur_cbc_mac[16]; 416 + uint8_t cur_cbc_mac[16]; 417 417 memcpy(cur_cbc_mac, crypto_iv, 16); 418 418 for(int j = 0; j < sb->sections[i].nr_insts; j++) 419 419 { ··· 425 425 produce_sb_instruction(inst, &cmd, u, cprintf); 426 426 if(g_nr_keys > 0 && !sb->sections[i].is_cleartext) 427 427 { 428 - check_crypto(crypto_apply((byte *)&cmd, (byte *)&cmd, 428 + check_crypto(crypto_apply((uint8_t *)&cmd, (uint8_t *)&cmd, 429 429 sizeof(cmd) / BLOCK_SIZE, cur_cbc_mac, &cur_cbc_mac, true)); 430 430 } 431 - sha_1_update(&file_sha1, (byte *)&cmd, sizeof(cmd)); 431 + sha_1_update(&file_sha1, (uint8_t *)&cmd, sizeof(cmd)); 432 432 write(&cmd, sizeof(cmd)); 433 433 } 434 434 /* data */ 435 435 if(inst->inst == SB_INST_LOAD || inst->inst == SB_INST_DATA) 436 436 { 437 437 uint32_t sz = inst->size + inst->padding_size; 438 - byte *data = xmalloc(sz); 438 + uint8_t *data = xmalloc(sz); 439 439 memcpy(data, inst->data, inst->size); 440 440 memcpy(data + inst->size, inst->padding, inst->padding_size); 441 441 if(g_nr_keys > 0 && !sb->sections[i].is_cleartext) ··· 452 452 uint32_t pad_size = sb->sections[i].pad_size; 453 453 if(sb->sections[i].is_data) 454 454 { 455 - byte *data = xmalloc(pad_size * BLOCK_SIZE); 455 + uint8_t *data = xmalloc(pad_size * BLOCK_SIZE); 456 456 generate_random_data(data, pad_size * BLOCK_SIZE); 457 457 sha_1_update(&file_sha1, data, pad_size * BLOCK_SIZE); 458 458 write(data, pad_size * BLOCK_SIZE); ··· 468 468 cmd.hdr.checksum = instruction_checksum(&cmd.hdr); 469 469 if(g_nr_keys > 0 && !sb->sections[i].is_cleartext) 470 470 { 471 - check_crypto(crypto_apply((byte *)&cmd, (byte *)&cmd, 471 + check_crypto(crypto_apply((uint8_t *)&cmd, (uint8_t *)&cmd, 472 472 sizeof(cmd) / BLOCK_SIZE, cur_cbc_mac, &cur_cbc_mac, true)); 473 473 } 474 - sha_1_update(&file_sha1, (byte *)&cmd, sizeof(cmd)); 474 + sha_1_update(&file_sha1, (uint8_t *)&cmd, sizeof(cmd)); 475 475 write(&cmd, sizeof(cmd)); 476 476 } 477 477 } 478 478 } 479 479 /* write file SHA-1 */ 480 - byte final_sig[32]; 480 + uint8_t final_sig[32]; 481 481 sha_1_finish(&file_sha1); 482 482 sha_1_output(&file_sha1, final_sig); 483 483 generate_random_data(final_sig + 20, 12); ··· 513 513 #undef printf 514 514 } 515 515 516 - static struct sb_section_t *read_section(bool data_sec, uint32_t id, byte *buf, 516 + static struct sb_section_t *read_section(bool data_sec, uint32_t id, uint8_t *buf, 517 517 int size, const char *indent, void *u, generic_printf_t cprintf, enum sb_error_t *err) 518 518 { 519 519 #define printf(c, ...) cprintf(u, false, c, __VA_ARGS__) ··· 758 758 fatal(SB_CRYPTO_ERROR, "Crypto error: %d\n", err); } while(0) 759 759 760 760 struct sha_1_params_t sha_1_params; 761 - byte (*cbcmacs)[16] = xmalloc(16 * g_nr_keys); 761 + uint8_t (*cbcmacs)[16] = xmalloc(16 * g_nr_keys); 762 762 sb_file = xmalloc(sizeof(struct sb_file_t)); 763 763 memset(sb_file, 0, sizeof(struct sb_file_t)); 764 764 struct sb_header_t *sb_header = (struct sb_header_t *)buf; ··· 790 790 printf(GREEN, " SB version: "); 791 791 printf(YELLOW, "%d.%d\n", sb_header->major_ver, sb_header->minor_ver); 792 792 printf(GREEN, " Header SHA-1: "); 793 - byte *hdr_sha1 = sb_header->sha1_header; 793 + uint8_t *hdr_sha1 = sb_header->sha1_header; 794 794 print_hex(YELLOW, hdr_sha1, 20, false); 795 795 /* Check SHA1 sum */ 796 - byte computed_sha1[20]; 796 + uint8_t computed_sha1[20]; 797 797 sha_1_init(&sha_1_params); 798 798 sha_1_update(&sha_1_params, &sb_header->signature[0], 799 799 sizeof(struct sb_header_t) - sizeof(sb_header->sha1_header)); ··· 876 876 print_key(&printer, sb_printer, &g_key_array[i], true); 877 877 printf(GREEN, " CBC-MAC: "); 878 878 /* check it */ 879 - byte zero[16]; 879 + uint8_t zero[16]; 880 880 memset(zero, 0, 16); 881 881 check_crypto(crypto_setup(&g_key_array[i])); 882 882 check_crypto(crypto_apply(buf, NULL, sb_header->header_size + ··· 906 906 { 907 907 printf(RED, " Match\n"); 908 908 /* decrypt */ 909 - byte decrypted_key[16]; 910 - byte iv[16]; 909 + uint8_t decrypted_key[16]; 910 + uint8_t iv[16]; 911 911 memcpy(iv, buf, 16); /* uses the first 16-bytes of SHA-1 sig as IV */ 912 912 check_crypto(crypto_setup(&g_key_array[idx])); 913 913 check_crypto(crypto_apply(dict_entry->key, decrypted_key, 1, iv, NULL, false)); ··· 1008 1008 } 1009 1009 1010 1010 /* save it */ 1011 - byte *sec = xmalloc(size); 1011 + uint8_t *sec = xmalloc(size); 1012 1012 if(encrypted) 1013 1013 check_crypto(crypto_apply(buf + pos, sec, size / BLOCK_SIZE, buf, NULL, false)); 1014 1014 else ··· 1034 1034 /* advanced raw mode */ 1035 1035 printf(BLUE, "Commands\n"); 1036 1036 uint32_t offset = sb_header->first_boot_tag_off * BLOCK_SIZE; 1037 - byte iv[16]; 1037 + uint8_t iv[16]; 1038 1038 const char *indent = " "; 1039 1039 while(true) 1040 1040 { 1041 1041 /* restart with IV */ 1042 1042 memcpy(iv, buf, 16); 1043 - byte cmd[BLOCK_SIZE]; 1043 + uint8_t cmd[BLOCK_SIZE]; 1044 1044 if(sb_header->nr_keys > 0) 1045 1045 check_crypto(crypto_apply(buf + offset, cmd, 1, iv, &iv, false)); 1046 1046 else ··· 1106 1106 } 1107 1107 1108 1108 /* save it */ 1109 - byte *sec = xmalloc(size); 1109 + uint8_t *sec = xmalloc(size); 1110 1110 if(encrypted) 1111 1111 check_crypto(crypto_apply(buf + pos, sec, size / BLOCK_SIZE, buf, NULL, false)); 1112 1112 else ··· 1147 1147 1148 1148 /* final signature */ 1149 1149 printf(BLUE, "Final signature:\n"); 1150 - byte decrypted_block[32]; 1150 + uint8_t decrypted_block[32]; 1151 1151 if(sb_header->nr_keys > 0) 1152 1152 { 1153 1153 printf(GREEN, " Encrypted SHA-1:\n"); 1154 - byte *encrypted_block = &buf[filesize - 32]; 1154 + uint8_t *encrypted_block = &buf[filesize - 32]; 1155 1155 printf(OFF, " "); 1156 1156 print_hex(YELLOW, encrypted_block, 16, true); 1157 1157 printf(OFF, " ");