From 0d04ee97dc0096f8b417fcbc2f3380fc580a136d Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 4 Aug 2018 16:56:26 -0400 Subject: aes_util: Add static assertion to Transcode() and XTSTranscode() to ensure well-defined behavior These functions should only be given trivially-copyable types. --- src/core/crypto/aes_util.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/core/crypto') 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: template void Transcode(const Source* src, size_t size, Dest* dest, Op op) const { + static_assert(std::is_trivially_copyable_v && std::is_trivially_copyable_v, + "Transcode source and destination types must be trivially copyable."); Transcode(reinterpret_cast(src), size, reinterpret_cast(dest), op); } @@ -47,6 +49,8 @@ public: template void XTSTranscode(const Source* src, size_t size, Dest* dest, size_t sector_id, size_t sector_size, Op op) { + static_assert(std::is_trivially_copyable_v && std::is_trivially_copyable_v, + "XTSTranscode source and destination types must be trivially copyable."); XTSTranscode(reinterpret_cast(src), size, reinterpret_cast(dest), sector_id, sector_size, op); } -- cgit v1.2.3