diff --git a/include/arm9/crypto.h b/include/arm9/crypto.h index 161a17e..7318f78 100644 --- a/include/arm9/crypto.h +++ b/include/arm9/crypto.h @@ -67,6 +67,11 @@ void AES_init(void); /** + * @brief Deinits AES to workaround a K9L bug. + */ +void AES_deinit(void); + +/** * @brief Sets a AES key in the specified keyslot. * * @param[in] keyslot The keyslot this key will be set for. diff --git a/source/arm9/crypto.c b/source/arm9/crypto.c index bb1a1af..7f5533b 100644 --- a/source/arm9/crypto.c +++ b/source/arm9/crypto.c @@ -156,6 +156,11 @@ setupKeys(); } +void AES_deinit(void) +{ + REG_AESCNT = AES_MAC_SIZE(4) | AES_FLUSH_WRITE_FIFO | AES_FLUSH_READ_FIFO; +} + void AES_setKey(u8 keyslot, AesKeyType type, u8 orderEndianess, bool twlScrambler, const u32 key[4]) { assert(keyslot < 0x40); diff --git a/source/arm9/hardware.c b/source/arm9/hardware.c index 1388e7f..4ab323a 100644 --- a/source/arm9/hardware.c +++ b/source/arm9/hardware.c @@ -20,5 +20,5 @@ { // New 3DS K9L doesn't like FIFO counts >4 and hangs. // Thx Nintendo - AES_init(); + AES_deinit(); }