1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-12-18 00:12:03 +00:00

Fix Modulus Exponentiation in SE driver

This commit is contained in:
Michael Scire 2018-03-01 02:00:39 -08:00
parent 4025781f1c
commit b67ce08f84

View file

@ -154,12 +154,12 @@ void set_rsa_keyslot(unsigned int keyslot, const void *modulus, size_t modulus_
for (size_t i = 0; i < (modulus_size >> 2); i++) { for (size_t i = 0; i < (modulus_size >> 2); i++) {
SECURITY_ENGINE->RSA_KEYTABLE_ADDR = (keyslot << 7) | 0x40 | i; SECURITY_ENGINE->RSA_KEYTABLE_ADDR = (keyslot << 7) | 0x40 | i;
SECURITY_ENGINE->RSA_KEYTABLE_DATA = read32be(modulus, 4 * i); SECURITY_ENGINE->RSA_KEYTABLE_DATA = read32be(modulus, (4 * (modulus_size >> 2)) - (4 * i) - 4);
} }
for (size_t i = 0; i < (exp_size >> 2); i++) { for (size_t i = 0; i < (exp_size >> 2); i++) {
SECURITY_ENGINE->RSA_KEYTABLE_ADDR = (keyslot << 7) | i; SECURITY_ENGINE->RSA_KEYTABLE_ADDR = (keyslot << 7) | i;
SECURITY_ENGINE->RSA_KEYTABLE_DATA = read32be(exponent, 4 * i); SECURITY_ENGINE->RSA_KEYTABLE_DATA = read32be(exponent, (4 * (exp_size >> 2)) - (4 * i) - 4);
} }
g_se_modulus_sizes[keyslot] = modulus_size; g_se_modulus_sizes[keyslot] = modulus_size;
@ -307,8 +307,8 @@ void se_synchronous_exp_mod(unsigned int keyslot, void *dst, size_t dst_size, co
} }
/* Endian swap the input. */ /* Endian swap the input. */
for (size_t i = src_size; i > 0; i--) { for (size_t i = 0; i < src_size; i++) {
stack_buf[i] = *((uint8_t *)src + src_size - i); stack_buf[i] = *((uint8_t *)src + src_size - i - 1);
} }
SECURITY_ENGINE->CONFIG_REG = (ALG_RSA | DST_RSAREG); SECURITY_ENGINE->CONFIG_REG = (ALG_RSA | DST_RSAREG);