diff options
Diffstat (limited to 'aesxx')
| -rw-r--r-- | aesxx/include/aesxx/aes.hpp | 15 | ||||
| -rw-r--r-- | aesxx/include/aesxx/api.hpp | 10 |
2 files changed, 9 insertions, 16 deletions
diff --git a/aesxx/include/aesxx/aes.hpp b/aesxx/include/aesxx/aes.hpp index 241e051..1b5aefa 100644 --- a/aesxx/include/aesxx/aes.hpp +++ b/aesxx/include/aesxx/aes.hpp @@ -33,11 +33,6 @@ struct Types<AES_AES128> { }; template <> -inline std::size_t get_number_of_rounds<AES_AES128>() { - return 11; -} - -template <> inline void from_string<AES_AES128>(aes128::Block& dest, std::string_view src) { aes_AES128_parse_block(&dest, src.data(), ErrorDetailsThrowsInDestructor{}); } @@ -108,11 +103,6 @@ struct Types<AES_AES192> { }; template <> -inline std::size_t get_number_of_rounds<AES_AES192>() { - return 13; -} - -template <> inline void from_string<AES_AES192>(aes192::Block& dest, std::string_view src) { aes_AES192_parse_block(&dest, src.data(), ErrorDetailsThrowsInDestructor{}); } @@ -183,11 +173,6 @@ struct Types<AES_AES256> { }; template <> -inline std::size_t get_number_of_rounds<AES_AES256>() { - return 15; -} - -template <> inline void from_string<AES_AES256>(aes256::Block& dest, std::string_view src) { aes_AES256_parse_block(&dest, src.data(), ErrorDetailsThrowsInDestructor{}); } diff --git a/aesxx/include/aesxx/api.hpp b/aesxx/include/aesxx/api.hpp index 70891c9..131e5e5 100644 --- a/aesxx/include/aesxx/api.hpp +++ b/aesxx/include/aesxx/api.hpp @@ -19,7 +19,15 @@ template <Algorithm algorithm> struct Types; template <Algorithm algorithm> -std::size_t get_number_of_rounds(); +std::size_t get_number_of_rounds() { + if constexpr (algorithm == AES_AES128) + return 11; + if constexpr (algorithm == AES_AES192) + return 13; + if constexpr (algorithm == AES_AES256) + return 15; + static_assert("Unrecognized algorithm"); +} template <Algorithm algorithm> void from_string(typename Types<algorithm>::Block&, std::string_view); |
