mirror of
https://github.com/shchmue/Lockpick_RCM.git
synced 2024-11-30 13:04:15 +01:00
Use size abbreviations
This commit is contained in:
parent
e4661f035b
commit
54ed439cce
@ -61,7 +61,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
#define VERSION_RMAP 0x10000
|
||||
#define VERSION_IVFC 0x20000
|
||||
|
||||
#define SAVE_BLOCK_SIZE_DEFAULT 0x4000
|
||||
#define SAVE_BLOCK_SIZE_DEFAULT SZ_16K
|
||||
|
||||
#define SAVE_NUM_HEADERS 2
|
||||
|
||||
@ -232,6 +232,6 @@ typedef struct {
|
||||
};
|
||||
} save_header_t;
|
||||
|
||||
static_assert(sizeof(save_header_t) == 0x4000, "Save header size is wrong!");
|
||||
static_assert(sizeof(save_header_t) == SZ_16K, "Save header size is wrong!");
|
||||
|
||||
#endif
|
||||
|
@ -41,7 +41,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
#include <stdint.h>
|
||||
|
||||
#define RMAP_ALIGN_SMALL 0x200
|
||||
#define RMAP_ALIGN_LARGE 0x4000
|
||||
#define RMAP_ALIGN_LARGE SZ_16K
|
||||
|
||||
typedef struct {
|
||||
uint32_t magic; /* RMAP */
|
||||
|
@ -250,7 +250,7 @@ uint32_t save_fs_list_allocate_entry(save_filesystem_list_ctx_t *ctx) {
|
||||
if (capacity == 0 || length >= capacity) {
|
||||
uint64_t current_size, new_size;
|
||||
save_allocation_table_storage_get_size(&ctx->storage, ¤t_size);
|
||||
if (!save_allocation_table_storage_set_size(&ctx->storage, current_size + 0x4000))
|
||||
if (!save_allocation_table_storage_set_size(&ctx->storage, current_size + SZ_16K))
|
||||
return 0;
|
||||
save_allocation_table_storage_get_size(&ctx->storage, &new_size);
|
||||
if (!save_fs_list_set_capacity(ctx, (uint32_t)(new_size / sizeof(save_fs_list_entry_t))))
|
||||
|
@ -140,8 +140,8 @@ static void _derive_keyblob_keys(key_derivation_ctx_t *keys) {
|
||||
bool have_keyblobs = true;
|
||||
|
||||
if (FUSE(FUSE_PRIVATE_KEY0) == 0xFFFFFFFF) {
|
||||
u8 *aes_keys = (u8 *)calloc(0x1000, 1);
|
||||
se_get_aes_keys(aes_keys + 0x800, aes_keys, AES_128_KEY_SIZE);
|
||||
u8 *aes_keys = (u8 *)calloc(SZ_4K, 1);
|
||||
se_get_aes_keys(aes_keys + SZ_2K, aes_keys, AES_128_KEY_SIZE);
|
||||
memcpy(keys->sbk, aes_keys + 14 * AES_128_KEY_SIZE, AES_128_KEY_SIZE);
|
||||
free(aes_keys);
|
||||
} else {
|
||||
@ -424,7 +424,7 @@ static bool _derive_sd_seed(key_derivation_ctx_t *keys) {
|
||||
}
|
||||
|
||||
u8 read_buf[0x20] __attribute__((aligned(4))) = {0};
|
||||
for (u32 i = 0x8000; i < f_size(&fp); i += 0x4000) {
|
||||
for (u32 i = SZ_32K; i < f_size(&fp); i += SZ_16K) {
|
||||
if (f_lseek(&fp, i) || f_read(&fp, read_buf, 0x20, &read_bytes) || read_bytes != 0x20)
|
||||
break;
|
||||
if (!memcmp(keys->temp_key, read_buf, sizeof(keys->temp_key))) {
|
||||
@ -493,7 +493,7 @@ static bool _derive_titlekeys(key_derivation_ctx_t *keys, titlekey_buffer_t *tit
|
||||
|
||||
se_rsa_key_set(0, rsa_keypair.modulus, sizeof(rsa_keypair.modulus), rsa_keypair.private_exponent, sizeof(rsa_keypair.private_exponent));
|
||||
|
||||
const u32 buf_size = 0x4000;
|
||||
const u32 buf_size = SZ_16K;
|
||||
_get_titlekeys_from_save(buf_size, keys->save_mac_key, titlekey_buffer, NULL);
|
||||
_get_titlekeys_from_save(buf_size, keys->save_mac_key, titlekey_buffer, &rsa_keypair);
|
||||
|
||||
@ -639,7 +639,7 @@ static void _save_keys_to_sd(key_derivation_ctx_t *keys, titlekey_buffer_t *titl
|
||||
return;
|
||||
}
|
||||
|
||||
u32 text_buffer_size = MAX(_titlekey_count * sizeof(titlekey_text_buffer_t) + 1, 0x4000);
|
||||
u32 text_buffer_size = MAX(_titlekey_count * sizeof(titlekey_text_buffer_t) + 1, SZ_16K);
|
||||
text_buffer = (char *)calloc(1, text_buffer_size);
|
||||
|
||||
SAVE_KEY(aes_kek_generation_source);
|
||||
@ -816,8 +816,8 @@ static void _derive_keys() {
|
||||
return;
|
||||
}
|
||||
|
||||
u8 *aes_keys = (u8 *)calloc(0x1000, 1);
|
||||
se_get_aes_keys(aes_keys + 0x800, aes_keys, AES_128_KEY_SIZE);
|
||||
u8 *aes_keys = (u8 *)calloc(SZ_4K, 1);
|
||||
se_get_aes_keys(aes_keys + SZ_2K, aes_keys, AES_128_KEY_SIZE);
|
||||
memcpy(&dev_keys.tsec_root_key, aes_keys + 11 * AES_128_KEY_SIZE, AES_128_KEY_SIZE);
|
||||
memcpy(keys->tsec_key, aes_keys + 12 * AES_128_KEY_SIZE, AES_128_KEY_SIZE);
|
||||
memcpy(&prod_keys.tsec_root_key, aes_keys + 13 * AES_128_KEY_SIZE, AES_128_KEY_SIZE);
|
||||
|
@ -58,9 +58,9 @@ typedef struct {
|
||||
} ticket_record_t;
|
||||
|
||||
typedef struct {
|
||||
u8 read_buffer[0x40000];
|
||||
u8 rights_ids[0x40000 / 0x10][0x10];
|
||||
u8 titlekeys[0x40000 / 0x10][0x10];
|
||||
u8 read_buffer[SZ_256K];
|
||||
u8 rights_ids[SZ_256K / 0x10][0x10];
|
||||
u8 titlekeys[SZ_256K / 0x10][0x10];
|
||||
} titlekey_buffer_t;
|
||||
|
||||
typedef struct {
|
||||
|
Loading…
Reference in New Issue
Block a user