mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-01-31 12:13:47 +01:00
Fix bug in user_generate_specific_aes_key, add other read/write le/be funcs
This commit is contained in:
parent
71f01aaa43
commit
4f0e8b8467
@ -326,8 +326,8 @@ uint32_t user_generate_specific_aes_key(smc_args_t *args) {
|
||||
}
|
||||
|
||||
|
||||
args->X[1] = key[0];
|
||||
args->X[2] = key[1];
|
||||
args->X[1] = read64le(key, 0);
|
||||
args->X[2] = read64le(key, 8);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ void calculate_mgf1_and_xor(void *masked, size_t masked_size, const void *seed,
|
||||
size_t hash_buf_size = seed_size + 4;
|
||||
memcpy(hash_buf, seed, seed_size);
|
||||
|
||||
uint32_t round = 0;
|
||||
uint32_t round_num = 0;
|
||||
|
||||
uint8_t *p_out = (uint8_t *)masked;
|
||||
|
||||
@ -46,11 +46,7 @@ void calculate_mgf1_and_xor(void *masked, size_t masked_size, const void *seed,
|
||||
cur_size = 0x20;
|
||||
}
|
||||
|
||||
hash_buf[seed_size + 0] = (uint8_t)((round >> 24) & 0xFF);
|
||||
hash_buf[seed_size + 1] = (uint8_t)((round >> 16) & 0xFF);
|
||||
hash_buf[seed_size + 2] = (uint8_t)((round >> 8) & 0xFF);
|
||||
hash_buf[seed_size + 3] = (uint8_t)((round >> 0) & 0xFF);
|
||||
round++;
|
||||
write32be(hash_buf, seed_size, round_num++);
|
||||
|
||||
flush_dcache_range(hash_buf, hash_buf + hash_buf_size);
|
||||
se_calculate_sha256(cur_hash, hash_buf, hash_buf_size);
|
||||
|
@ -78,6 +78,26 @@ static inline uint64_t read64le(const volatile void *qword, size_t offset) {
|
||||
return *(uint64_t *)((uintptr_t)qword + offset);
|
||||
}
|
||||
|
||||
static inline uint32_t read64be(const volatile void *qword, size_t offset) {
|
||||
return __builtin_bswap64(read64le(qword, offset));
|
||||
}
|
||||
|
||||
static inline void write32le(volatile void *dword, size_t offset, uint32_t value) {
|
||||
*(uint32_t *)((uintptr_t)dword + offset) = value;
|
||||
}
|
||||
|
||||
static inline void write32be(volatile void *dword, size_t offset, uint32_t value) {
|
||||
write32le(dword, offset, __builtin_bswap32(value));
|
||||
}
|
||||
|
||||
static inline void write64le(volatile void *qword, size_t offset, uint64_t value) {
|
||||
*(uint64_t *)((uintptr_t)qword + offset) = value;
|
||||
}
|
||||
|
||||
static inline void write64be(volatile void *qword, size_t offset, uint64_t value) {
|
||||
write64le(qword, offset, __builtin_bswap64(value));
|
||||
}
|
||||
|
||||
static inline unsigned int get_core_id(void) {
|
||||
uint64_t core_id;
|
||||
__asm__ __volatile__ ("mrs %0, mpidr_el1" : "=r"(core_id));
|
||||
|
Loading…
x
Reference in New Issue
Block a user