mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-09-06 21:29:20 +02:00
Merge pull request #6231 from lioncash/aes
aes_util: Make use of std::span
This commit is contained in:
commit
51c787bfc1
@ -119,9 +119,9 @@ void AESCipher<Key, KeySize>::XTSTranscode(const u8* src, std::size_t size, u8*
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Key, std::size_t KeySize>
|
template <typename Key, std::size_t KeySize>
|
||||||
void AESCipher<Key, KeySize>::SetIVImpl(const u8* data, std::size_t size) {
|
void AESCipher<Key, KeySize>::SetIV(std::span<const u8> data) {
|
||||||
ASSERT_MSG((mbedtls_cipher_set_iv(&ctx->encryption_context, data, size) ||
|
ASSERT_MSG((mbedtls_cipher_set_iv(&ctx->encryption_context, data.data(), data.size()) ||
|
||||||
mbedtls_cipher_set_iv(&ctx->decryption_context, data, size)) == 0,
|
mbedtls_cipher_set_iv(&ctx->decryption_context, data.data(), data.size())) == 0,
|
||||||
"Failed to set IV on mbedtls ciphers.");
|
"Failed to set IV on mbedtls ciphers.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <span>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "core/file_sys/vfs.h"
|
#include "core/file_sys/vfs.h"
|
||||||
@ -33,10 +34,7 @@ public:
|
|||||||
AESCipher(Key key, Mode mode);
|
AESCipher(Key key, Mode mode);
|
||||||
~AESCipher();
|
~AESCipher();
|
||||||
|
|
||||||
template <typename ContiguousContainer>
|
void SetIV(std::span<const u8> data);
|
||||||
void SetIV(const ContiguousContainer& container) {
|
|
||||||
SetIVImpl(std::data(container), std::size(container));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Source, typename Dest>
|
template <typename Source, typename Dest>
|
||||||
void Transcode(const Source* src, std::size_t size, Dest* dest, Op op) const {
|
void Transcode(const Source* src, std::size_t size, Dest* dest, Op op) const {
|
||||||
@ -60,8 +58,6 @@ public:
|
|||||||
std::size_t sector_size, Op op);
|
std::size_t sector_size, Op op);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SetIVImpl(const u8* data, std::size_t size);
|
|
||||||
|
|
||||||
std::unique_ptr<CipherContext> ctx;
|
std::unique_ptr<CipherContext> ctx;
|
||||||
};
|
};
|
||||||
} // namespace Core::Crypto
|
} // namespace Core::Crypto
|
||||||
|
Loading…
Reference in New Issue
Block a user