summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Lioncash2018-08-04 16:56:26 -0400
committerGravatar Lioncash2018-08-04 17:30:52 -0400
commit0d04ee97dc0096f8b417fcbc2f3380fc580a136d (patch)
tree2bdd5a1d3aaf28d73c444ad2560fc38cf79bd6be /src
parentaes_util: Make CalculateNintendoTweak() an internally linked function (diff)
downloadyuzu-0d04ee97dc0096f8b417fcbc2f3380fc580a136d.tar.gz
yuzu-0d04ee97dc0096f8b417fcbc2f3380fc580a136d.tar.xz
yuzu-0d04ee97dc0096f8b417fcbc2f3380fc580a136d.zip
aes_util: Add static assertion to Transcode() and XTSTranscode() to ensure well-defined behavior
These functions should only be given trivially-copyable types.
Diffstat (limited to 'src')
-rw-r--r--src/core/crypto/aes_util.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/core/crypto/aes_util.h b/src/core/crypto/aes_util.h
index ce4947a04..8ce9d6612 100644
--- a/src/core/crypto/aes_util.h
+++ b/src/core/crypto/aes_util.h
@@ -39,6 +39,8 @@ public:
39 39
40 template <typename Source, typename Dest> 40 template <typename Source, typename Dest>
41 void Transcode(const Source* src, size_t size, Dest* dest, Op op) const { 41 void Transcode(const Source* src, size_t size, Dest* dest, Op op) const {
42 static_assert(std::is_trivially_copyable_v<Source> && std::is_trivially_copyable_v<Dest>,
43 "Transcode source and destination types must be trivially copyable.");
42 Transcode(reinterpret_cast<const u8*>(src), size, reinterpret_cast<u8*>(dest), op); 44 Transcode(reinterpret_cast<const u8*>(src), size, reinterpret_cast<u8*>(dest), op);
43 } 45 }
44 46
@@ -47,6 +49,8 @@ public:
47 template <typename Source, typename Dest> 49 template <typename Source, typename Dest>
48 void XTSTranscode(const Source* src, size_t size, Dest* dest, size_t sector_id, 50 void XTSTranscode(const Source* src, size_t size, Dest* dest, size_t sector_id,
49 size_t sector_size, Op op) { 51 size_t sector_size, Op op) {
52 static_assert(std::is_trivially_copyable_v<Source> && std::is_trivially_copyable_v<Dest>,
53 "XTSTranscode source and destination types must be trivially copyable.");
50 XTSTranscode(reinterpret_cast<const u8*>(src), size, reinterpret_cast<u8*>(dest), sector_id, 54 XTSTranscode(reinterpret_cast<const u8*>(src), size, reinterpret_cast<u8*>(dest), sector_id,
51 sector_size, op); 55 sector_size, op);
52 } 56 }