1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-11-18 01:46:47 +00:00

Fix async expMod output + smcUnwrapAesWrappedTitlekey

This commit is contained in:
Michael Scire 2018-03-08 19:48:35 -08:00
parent 7e780301de
commit 1ffa239b5a
4 changed files with 18 additions and 13 deletions

View file

@ -311,8 +311,8 @@ void se_exp_mod(unsigned int keyslot, void *buf, size_t size, unsigned int (*cal
} }
/* Endian swap the input. */ /* Endian swap the input. */
for (size_t i = size; i > 0; i--) { for (size_t i = 0; i < size; i++) {
stack_buf[i] = *((uint8_t *)buf + size - i); stack_buf[i] = *((uint8_t *)buf + size - i - 1);
} }

View file

@ -1,4 +1,5 @@
#include <stdint.h> #include <stdint.h>
#include <string.h>
#include "utils.h" #include "utils.h"
#include "sealedkeys.h" #include "sealedkeys.h"

View file

@ -150,8 +150,6 @@ void clear_priv_smc_in_progress(void) {
uint32_t (*g_smc_callback)(void *, uint64_t) = NULL; uint32_t (*g_smc_callback)(void *, uint64_t) = NULL;
uint64_t g_smc_callback_key = 0; uint64_t g_smc_callback_key = 0;
static _Atomic(int) g_num_smcs_called = 0;
uint64_t try_set_smc_callback(uint32_t (*callback)(void *, uint64_t)) { uint64_t try_set_smc_callback(uint32_t (*callback)(void *, uint64_t)) {
uint64_t key; uint64_t key;
if (g_smc_callback_key) { if (g_smc_callback_key) {
@ -201,15 +199,17 @@ void call_smc_handler(uint32_t handler_id, smc_args_t *args) {
generic_panic(); generic_panic();
} }
int num_called = atomic_fetch_add(&g_num_smcs_called, 1);
/* DEBUG: use num_called to determine panic behavior. */
if (num_called == 0x21A) {
panic(COLOR_F);
}
/* Call function. */ /* Call function. */
args->X[0] = smc_handler(args); args->X[0] = smc_handler(args);
if (args->X[0])
{
MAKE_REG32(get_iram_address_for_debug() + 0x4FF0) = handler_id;
MAKE_REG32(get_iram_address_for_debug() + 0x4FF4) = smc_id;
MAKE_REG32(get_iram_address_for_debug() + 0x4FF8) = get_core_id();
*(volatile smc_args_t *)(get_iram_address_for_debug() + 0x4F00) = *args;
panic(PANIC_REBOOT);
}
(void)result; /* FIXME: result unused */ (void)result; /* FIXME: result unused */
} }

View file

@ -557,8 +557,10 @@ uint32_t user_unwrap_rsa_oaep_wrapped_titlekey(smc_args_t *args) {
void *user_modulus = (void *)args->X[2]; void *user_modulus = (void *)args->X[2];
unsigned int master_key_rev = (unsigned int)args->X[7]; unsigned int master_key_rev = (unsigned int)args->X[7];
if (master_key_rev >= MASTERKEY_REVISION_MAX) { if (mkey_get_revision() > 0 && master_key_rev >= MASTERKEY_REVISION_MAX) {
return 2; return 2;
} else {
master_key_rev = 0;
} }
/* Copy user data into secure memory. */ /* Copy user data into secure memory. */
@ -615,8 +617,10 @@ uint32_t user_unwrap_aes_wrapped_titlekey(smc_args_t *args) {
unsigned int master_key_rev = (unsigned int)args->X[3]; unsigned int master_key_rev = (unsigned int)args->X[3];
if (master_key_rev >= MASTERKEY_REVISION_MAX) { if (mkey_get_revision() > 0 && master_key_rev >= MASTERKEY_REVISION_MAX) {
return 2; return 2;
} else {
master_key_rev = 0;
} }
tkey_set_master_key_rev(master_key_rev); tkey_set_master_key_rev(master_key_rev);