Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void __fastcall update_eeprom_with_key_0x30(int in_eeprom_wr_offset, unsigned __int8 *in_key_seed, int in_tweak_val, unsigned int in_num_blocks, unsigned __int8 *in_data_buf)
- {
- int _14; // ST14_4
- unsigned __int8 *_18; // ST18_4
- int eeprom_block_offset10; // r6
- unsigned int counter0; // r5
- int in_block_calc_offset; // r0
- signed int v10; // r1
- unsigned int in_interations; // r6
- int tweak_val; // r6
- unsigned int counter1; // r5
- int offset; // [sp+4h] [bp-4h]
- int in_tweak; // [sp+1Ch] [bp+14h]
- unsigned int num_blocks; // [sp+20h] [bp+18h]
- _14 = in_eeprom_wr_offset;
- _18 = in_key_seed;
- in_tweak = in_tweak_val;
- num_blocks = in_num_blocks;
- eeprom_block_offset10 = in_eeprom_wr_offset;
- counter0 = 0;
- in_block_calc_offset = 0x10 * in_tweak_val;
- if ( eeprom_block_offset10 == 0xFF )
- {
- v10 = 0x2560;
- }
- else if ( eeprom_block_offset10 == 0x81 )
- {
- v10 = 0x2800;
- }
- else
- {
- if ( eeprom_block_offset10 != 0x82 )
- {
- offset = (eeprom_block_offset10 << 0xA) + in_block_calc_offset + 0x560;
- memcpy(&key_seed_data, in_key_seed + 0x150, 0x10);
- if ( !get_key_from_secure_vault(0x30, &skey_0x30, 0x10) )
- {
- aes_ebc_encrypt_init_wrapper((unsigned __int8 *)&skey_0x30, &aes_ctx_30);
- in_interations = eeprom_block_offset10 + 1;
- while ( counter0 < in_interations )
- {
- aes_ecb_encrypt_wrapper((unsigned __int8 *)&key_seed_data, &aes_ctx_30);
- ++counter0;
- }
- aes_ebc_encrypt_init_wrapper((unsigned __int8 *)&key_seed_data, &aes_ctx_30);
- tweak_val = in_tweak;
- counter1 = 0;
- while ( counter1 < num_blocks )
- {
- *(_DWORD *)&in_data_buf[0x10 * counter1] ^= tweak_val;
- aes_ecb_encrypt_wrapper(&in_data_buf[0x10 * counter1++], &aes_ctx_30);
- ++tweak_val;
- }
- write_eprom2(offset, in_data_buf, 0x10 * num_blocks);
- }
- LABEL_16:
- memset_func(&skey_0x30, 0, 0x10);
- memset_func(&key_seed_data, 0, 0x10);
- memset_func(&aes_ctx_30, 0, 0xC0);
- JUMPOUT(loc_D5A);
- }
- v10 = 0x7400;
- }
- write_eprom2(in_block_calc_offset + v10, in_data_buf, 0x10 * in_num_blocks);
- goto LABEL_16;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement