From ec8f27f1be1278f5d97d082a9768081f4b7391eb Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Thu, 8 Mar 2018 03:16:50 -0800 Subject: [PATCH] Fix AES ECB encryption not encrypting --- exosphere/src/se.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/exosphere/src/se.c b/exosphere/src/se.c index e7b7401b5..e279d3d21 100644 --- a/exosphere/src/se.c +++ b/exosphere/src/se.c @@ -540,8 +540,10 @@ void se_aes_ecb_encrypt_block(unsigned int keyslot, void *dst, size_t dst_size, /* Set configuration high (256-bit vs 128-bit) based on parameter. */ SECURITY_ENGINE->CONFIG_REG = (ALG_AES_ENC | DST_MEMORY) | (config_high << 16); - SECURITY_ENGINE->CRYPTO_REG = keyslot << 24; + SECURITY_ENGINE->CRYPTO_REG = keyslot << 24 | 0x100; + flush_dcache_range((uint8_t *)src, (uint8_t *)src + 0x10); se_perform_aes_block_operation(dst, 0x10, src, 0x10); + flush_dcache_range((uint8_t *)dst, (uint8_t *)dst + 0x10); } @@ -561,7 +563,9 @@ void se_aes_ecb_decrypt_block(unsigned int keyslot, void *dst, size_t dst_size, SECURITY_ENGINE->CONFIG_REG = (ALG_AES_DEC | DST_MEMORY); SECURITY_ENGINE->CRYPTO_REG = keyslot << 24; + flush_dcache_range((uint8_t *)src, (uint8_t *)src + 0x10); se_perform_aes_block_operation(dst, 0x10, src, 0x10); + flush_dcache_range((uint8_t *)dst, (uint8_t *)dst + 0x10); } void shift_left_xor_rb(uint8_t *key) {