diff options
| author | SketchMaster2001 <batmanpistilli2006@gmail.com> | 2022-09-18 23:09:20 -0400 |
|---|---|---|
| committer | Admiral H. Curtiss <pikachu025@gmail.com> | 2022-10-16 04:19:36 +0200 |
| commit | e413d7f5ece44fd22b9deb7a192cdfcfdef8a0dd (patch) | |
| tree | fe2f183fb1ecfe1be22d9f741b08837f3db38281 /Source/Core/Common | |
| parent | 487a11fd2c43bcdd6c24c4da2009a750a32fdf59 (diff) | |
Add initial WiiConnect24 support
Diffstat (limited to 'Source/Core/Common')
| -rw-r--r-- | Source/Core/Common/Crypto/AES.cpp | 17 | ||||
| -rw-r--r-- | Source/Core/Common/Crypto/AES.h | 3 |
2 files changed, 20 insertions, 0 deletions
diff --git a/Source/Core/Common/Crypto/AES.cpp b/Source/Core/Common/Crypto/AES.cpp index fe8f4ec728..82f7d1a9c2 100644 --- a/Source/Core/Common/Crypto/AES.cpp +++ b/Source/Core/Common/Crypto/AES.cpp @@ -408,4 +408,21 @@ std::unique_ptr<Context> CreateContextDecrypt(const u8* key) return CreateContext<Mode::Decrypt>(key); } +// OFB encryption and decryption are the exact same. We don't encrypt though. +void CryptOFB(const u8* key, const u8* iv, u8* iv_out, const u8* buf_in, u8* buf_out, size_t size) +{ + mbedtls_aes_context aes_ctx; + size_t iv_offset = 0; + + std::array<u8, 16> iv_tmp{}; + if (iv) + std::memcpy(&iv_tmp[0], iv, 16); + + ASSERT(!mbedtls_aes_setkey_enc(&aes_ctx, key, 128)); + mbedtls_aes_crypt_ofb(&aes_ctx, size, &iv_offset, &iv_tmp[0], buf_in, buf_out); + + if (iv_out) + std::memcpy(iv_out, &iv_tmp[0], 16); +} + } // namespace Common::AES diff --git a/Source/Core/Common/Crypto/AES.h b/Source/Core/Common/Crypto/AES.h index 338b71bc85..a2f9f5e393 100644 --- a/Source/Core/Common/Crypto/AES.h +++ b/Source/Core/Common/Crypto/AES.h @@ -46,4 +46,7 @@ public: std::unique_ptr<Context> CreateContextEncrypt(const u8* key); std::unique_ptr<Context> CreateContextDecrypt(const u8* key); +// OFB decryption for WiiConnect24 +void CryptOFB(const u8* key, const u8* iv, u8* iv_out, const u8* buf_in, u8* buf_out, size_t size); + } // namespace Common::AES |
