diff options
Diffstat (limited to '')
| -rw-r--r-- | src/core/crypto/aes_util.cpp | 6 | ||||
| -rw-r--r-- | src/core/crypto/aes_util.h | 8 |
2 files changed, 5 insertions, 9 deletions
diff --git a/src/core/crypto/aes_util.cpp b/src/core/crypto/aes_util.cpp index cb7506241..85a666de9 100644 --- a/src/core/crypto/aes_util.cpp +++ b/src/core/crypto/aes_util.cpp | |||
| @@ -119,9 +119,9 @@ void AESCipher<Key, KeySize>::XTSTranscode(const u8* src, std::size_t size, u8* | |||
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | template <typename Key, std::size_t KeySize> | 121 | template <typename Key, std::size_t KeySize> |
| 122 | void AESCipher<Key, KeySize>::SetIVImpl(const u8* data, std::size_t size) { | 122 | void AESCipher<Key, KeySize>::SetIV(std::span<const u8> data) { |
| 123 | ASSERT_MSG((mbedtls_cipher_set_iv(&ctx->encryption_context, data, size) || | 123 | ASSERT_MSG((mbedtls_cipher_set_iv(&ctx->encryption_context, data.data(), data.size()) || |
| 124 | mbedtls_cipher_set_iv(&ctx->decryption_context, data, size)) == 0, | 124 | mbedtls_cipher_set_iv(&ctx->decryption_context, data.data(), data.size())) == 0, |
| 125 | "Failed to set IV on mbedtls ciphers."); | 125 | "Failed to set IV on mbedtls ciphers."); |
| 126 | } | 126 | } |
| 127 | 127 | ||
diff --git a/src/core/crypto/aes_util.h b/src/core/crypto/aes_util.h index e2a304186..230451b8f 100644 --- a/src/core/crypto/aes_util.h +++ b/src/core/crypto/aes_util.h | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <memory> | 7 | #include <memory> |
| 8 | #include <span> | ||
| 8 | #include <type_traits> | 9 | #include <type_traits> |
| 9 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 10 | #include "core/file_sys/vfs.h" | 11 | #include "core/file_sys/vfs.h" |
| @@ -33,10 +34,7 @@ public: | |||
| 33 | AESCipher(Key key, Mode mode); | 34 | AESCipher(Key key, Mode mode); |
| 34 | ~AESCipher(); | 35 | ~AESCipher(); |
| 35 | 36 | ||
| 36 | template <typename ContiguousContainer> | 37 | void SetIV(std::span<const u8> data); |
| 37 | void SetIV(const ContiguousContainer& container) { | ||
| 38 | SetIVImpl(std::data(container), std::size(container)); | ||
| 39 | } | ||
| 40 | 38 | ||
| 41 | template <typename Source, typename Dest> | 39 | template <typename Source, typename Dest> |
| 42 | void Transcode(const Source* src, std::size_t size, Dest* dest, Op op) const { | 40 | void Transcode(const Source* src, std::size_t size, Dest* dest, Op op) const { |
| @@ -60,8 +58,6 @@ public: | |||
| 60 | std::size_t sector_size, Op op); | 58 | std::size_t sector_size, Op op); |
| 61 | 59 | ||
| 62 | private: | 60 | private: |
| 63 | void SetIVImpl(const u8* data, std::size_t size); | ||
| 64 | |||
| 65 | std::unique_ptr<CipherContext> ctx; | 61 | std::unique_ptr<CipherContext> ctx; |
| 66 | }; | 62 | }; |
| 67 | } // namespace Core::Crypto | 63 | } // namespace Core::Crypto |