diff options
Diffstat (limited to '')
-rw-r--r-- | cxx/include/aesxx/aes.hpp | 194 | ||||
-rw-r--r-- | cxx/include/aesxx/algorithm.hpp | 4 | ||||
-rw-r--r-- | cxx/include/aesxx/api.hpp | 6 | ||||
-rw-r--r-- | cxx/include/aesxx/box.hpp | 46 | ||||
-rw-r--r-- | cxx/include/aesxx/data.hpp | 20 | ||||
-rw-r--r-- | cxx/include/aesxx/debug.hpp | 2 | ||||
-rw-r--r-- | cxx/include/aesxx/error.hpp | 26 | ||||
-rw-r--r-- | cxx/include/aesxx/mode.hpp | 150 |
8 files changed, 224 insertions, 224 deletions
diff --git a/cxx/include/aesxx/aes.hpp b/cxx/include/aesxx/aes.hpp index 698c0ef..fe0ade4 100644 --- a/cxx/include/aesxx/aes.hpp +++ b/cxx/include/aesxx/aes.hpp @@ -19,17 +19,17 @@ #include <string> -namespace aesni +namespace aes { namespace aes128 { - typedef AesNI_AES128_Block Block; - typedef AesNI_AES128_RoundKeys RoundKeys; - typedef AesNI_AES128_Key Key; + typedef AES_AES128_Block Block; + typedef AES_AES128_RoundKeys RoundKeys; + typedef AES_AES128_Key Key; } template <> - struct Types<AESNI_AES128> + struct Types<AES_AES128> { typedef aes128::Block Block; typedef aes128::RoundKeys RoundKeys; @@ -37,84 +37,84 @@ namespace aesni }; template <> - std::size_t get_number_of_rounds<AESNI_AES128>() + std::size_t get_number_of_rounds<AES_AES128>() { return 11; } template <> - void from_string<AESNI_AES128>(aes128::Block& dest, const char* src) + void from_string<AES_AES128>(aes128::Block& dest, const char* src) { - aesni_AES128_parse_block(&dest, src, ErrorDetailsThrowsInDestructor()); + aes_AES128_parse_block(&dest, src, ErrorDetailsThrowsInDestructor()); } template <> - std::string to_string<AESNI_AES128>(const aes128::Block& src) + std::string to_string<AES_AES128>(const aes128::Block& src) { - AesNI_AES128_BlockString str; - aesni_AES128_format_block(&str, &src, ErrorDetailsThrowsInDestructor()); + AES_AES128_BlockString str; + aes_AES128_format_block(&str, &src, ErrorDetailsThrowsInDestructor()); return { str.str }; } template <> - std::string to_matrix_string<AESNI_AES128>(const aes128::Block& src) + std::string to_matrix_string<AES_AES128>(const aes128::Block& src) { - AesNI_AES128_BlockMatrixString str; - aesni_AES128_format_block_as_matrix(&str, &src, ErrorDetailsThrowsInDestructor()); + AES_AES128_BlockMatrixString str; + aes_AES128_format_block_as_matrix(&str, &src, ErrorDetailsThrowsInDestructor()); return { str.str }; } template <> - void from_string<AESNI_AES128>(aes128::Key& dest, const char* src) + void from_string<AES_AES128>(aes128::Key& dest, const char* src) { - aesni_AES128_parse_key(&dest, src, ErrorDetailsThrowsInDestructor()); + aes_AES128_parse_key(&dest, src, ErrorDetailsThrowsInDestructor()); } template <> - std::string to_string<AESNI_AES128>(const aes128::Key& src) + std::string to_string<AES_AES128>(const aes128::Key& src) { - AesNI_AES128_KeyString str; - aesni_AES128_format_key(&str, &src, ErrorDetailsThrowsInDestructor()); + AES_AES128_KeyString str; + aes_AES128_format_key(&str, &src, ErrorDetailsThrowsInDestructor()); return { str.str }; } template <> - inline void expand_key<AESNI_AES128>( + inline void expand_key<AES_AES128>( const aes128::Key& key, aes128::RoundKeys& encryption_keys) { - aesni_AES128_expand_key(&key, &encryption_keys); + aes_AES128_expand_key(&key, &encryption_keys); } template <> - inline void derive_decryption_keys<AESNI_AES128>( + inline void derive_decryption_keys<AES_AES128>( const aes128::RoundKeys& encryption_keys, aes128::RoundKeys& decryption_keys) { - aesni_AES128_derive_decryption_keys( + aes_AES128_derive_decryption_keys( &encryption_keys, &decryption_keys); } - AESNIXX_ENCRYPT_BLOCK_ECB(AES128); - AESNIXX_DECRYPT_BLOCK_ECB(AES128); - AESNIXX_ENCRYPT_BLOCK_CBC(AES128); - AESNIXX_DECRYPT_BLOCK_CBC(AES128); - AESNIXX_ENCRYPT_BLOCK_CFB(AES128); - AESNIXX_DECRYPT_BLOCK_CFB(AES128); - AESNIXX_ENCRYPT_BLOCK_OFB(AES128); - AESNIXX_DECRYPT_BLOCK_OFB(AES128); - AESNIXX_ENCRYPT_BLOCK_CTR(AES128); - AESNIXX_DECRYPT_BLOCK_CTR(AES128); + AESXX_ENCRYPT_BLOCK_ECB(AES128); + AESXX_DECRYPT_BLOCK_ECB(AES128); + AESXX_ENCRYPT_BLOCK_CBC(AES128); + AESXX_DECRYPT_BLOCK_CBC(AES128); + AESXX_ENCRYPT_BLOCK_CFB(AES128); + AESXX_DECRYPT_BLOCK_CFB(AES128); + AESXX_ENCRYPT_BLOCK_OFB(AES128); + AESXX_DECRYPT_BLOCK_OFB(AES128); + AESXX_ENCRYPT_BLOCK_CTR(AES128); + AESXX_DECRYPT_BLOCK_CTR(AES128); namespace aes192 { - typedef AesNI_AES192_Block Block; - typedef AesNI_AES192_RoundKeys RoundKeys; - typedef AesNI_AES192_Key Key; + typedef AES_AES192_Block Block; + typedef AES_AES192_RoundKeys RoundKeys; + typedef AES_AES192_Key Key; } template <> - struct Types<AESNI_AES192> + struct Types<AES_AES192> { typedef aes192::Block Block; typedef aes192::RoundKeys RoundKeys; @@ -122,84 +122,84 @@ namespace aesni }; template <> - std::size_t get_number_of_rounds<AESNI_AES192>() + std::size_t get_number_of_rounds<AES_AES192>() { return 13; } template <> - void from_string<AESNI_AES192>(aes192::Block& dest, const char* src) + void from_string<AES_AES192>(aes192::Block& dest, const char* src) { - aesni_AES192_parse_block(&dest, src, ErrorDetailsThrowsInDestructor()); + aes_AES192_parse_block(&dest, src, ErrorDetailsThrowsInDestructor()); } template <> - std::string to_string<AESNI_AES192>(const aes192::Block& src) + std::string to_string<AES_AES192>(const aes192::Block& src) { - AesNI_AES192_BlockString str; - aesni_AES192_format_block(&str, &src, ErrorDetailsThrowsInDestructor()); + AES_AES192_BlockString str; + aes_AES192_format_block(&str, &src, ErrorDetailsThrowsInDestructor()); return { str.str }; } template <> - std::string to_matrix_string<AESNI_AES192>(const aes192::Block& src) + std::string to_matrix_string<AES_AES192>(const aes192::Block& src) { - AesNI_AES192_BlockMatrixString str; - aesni_AES192_format_block_as_matrix(&str, &src, ErrorDetailsThrowsInDestructor()); + AES_AES192_BlockMatrixString str; + aes_AES192_format_block_as_matrix(&str, &src, ErrorDetailsThrowsInDestructor()); return { str.str }; } template <> - void from_string<AESNI_AES192>(aes192::Key& dest, const char* src) + void from_string<AES_AES192>(aes192::Key& dest, const char* src) { - aesni_AES192_parse_key(&dest, src, ErrorDetailsThrowsInDestructor()); + aes_AES192_parse_key(&dest, src, ErrorDetailsThrowsInDestructor()); } template <> - std::string to_string<AESNI_AES192>(const aes192::Key& src) + std::string to_string<AES_AES192>(const aes192::Key& src) { - AesNI_AES192_KeyString str; - aesni_AES192_format_key(&str, &src, ErrorDetailsThrowsInDestructor()); + AES_AES192_KeyString str; + aes_AES192_format_key(&str, &src, ErrorDetailsThrowsInDestructor()); return { str.str }; } template <> - inline void expand_key<AESNI_AES192>( + inline void expand_key<AES_AES192>( const aes192::Key& key, aes192::RoundKeys& encryption_keys) { - aesni_AES192_expand_key(&key, &encryption_keys); + aes_AES192_expand_key(&key, &encryption_keys); } template <> - inline void derive_decryption_keys<AESNI_AES192>( + inline void derive_decryption_keys<AES_AES192>( const aes192::RoundKeys& encryption_keys, aes192::RoundKeys& decryption_keys) { - aesni_AES192_derive_decryption_keys( + aes_AES192_derive_decryption_keys( &encryption_keys, &decryption_keys); } - AESNIXX_ENCRYPT_BLOCK_ECB(AES192); - AESNIXX_DECRYPT_BLOCK_ECB(AES192); - AESNIXX_ENCRYPT_BLOCK_CBC(AES192); - AESNIXX_DECRYPT_BLOCK_CBC(AES192); - AESNIXX_ENCRYPT_BLOCK_CFB(AES192); - AESNIXX_DECRYPT_BLOCK_CFB(AES192); - AESNIXX_ENCRYPT_BLOCK_OFB(AES192); - AESNIXX_DECRYPT_BLOCK_OFB(AES192); - AESNIXX_ENCRYPT_BLOCK_CTR(AES192); - AESNIXX_DECRYPT_BLOCK_CTR(AES192); + AESXX_ENCRYPT_BLOCK_ECB(AES192); + AESXX_DECRYPT_BLOCK_ECB(AES192); + AESXX_ENCRYPT_BLOCK_CBC(AES192); + AESXX_DECRYPT_BLOCK_CBC(AES192); + AESXX_ENCRYPT_BLOCK_CFB(AES192); + AESXX_DECRYPT_BLOCK_CFB(AES192); + AESXX_ENCRYPT_BLOCK_OFB(AES192); + AESXX_DECRYPT_BLOCK_OFB(AES192); + AESXX_ENCRYPT_BLOCK_CTR(AES192); + AESXX_DECRYPT_BLOCK_CTR(AES192); namespace aes256 { - typedef AesNI_AES256_Block Block; - typedef AesNI_AES256_RoundKeys RoundKeys; - typedef AesNI_AES256_Key Key; + typedef AES_AES256_Block Block; + typedef AES_AES256_RoundKeys RoundKeys; + typedef AES_AES256_Key Key; } template <> - struct Types<AESNI_AES256> + struct Types<AES_AES256> { typedef aes256::Block Block; typedef aes256::RoundKeys RoundKeys; @@ -207,72 +207,72 @@ namespace aesni }; template <> - std::size_t get_number_of_rounds<AESNI_AES256>() + std::size_t get_number_of_rounds<AES_AES256>() { return 15; } template <> - void from_string<AESNI_AES256>(aes256::Block& dest, const char* src) + void from_string<AES_AES256>(aes256::Block& dest, const char* src) { - aesni_AES256_parse_block(&dest, src, ErrorDetailsThrowsInDestructor()); + aes_AES256_parse_block(&dest, src, ErrorDetailsThrowsInDestructor()); } template <> - std::string to_string<AESNI_AES256>(const aes256::Block& src) + std::string to_string<AES_AES256>(const aes256::Block& src) { - AesNI_AES256_BlockString str; - aesni_AES256_format_block(&str, &src, ErrorDetailsThrowsInDestructor()); + AES_AES256_BlockString str; + aes_AES256_format_block(&str, &src, ErrorDetailsThrowsInDestructor()); return { str.str }; } template <> - std::string to_matrix_string<AESNI_AES256>(const aes256::Block& src) + std::string to_matrix_string<AES_AES256>(const aes256::Block& src) { - AesNI_AES256_BlockMatrixString str; - aesni_AES256_format_block_as_matrix(&str, &src, ErrorDetailsThrowsInDestructor()); + AES_AES256_BlockMatrixString str; + aes_AES256_format_block_as_matrix(&str, &src, ErrorDetailsThrowsInDestructor()); return { str.str }; } template <> - void from_string<AESNI_AES256>(aes256::Key& dest, const char* src) + void from_string<AES_AES256>(aes256::Key& dest, const char* src) { - aesni_AES256_parse_key(&dest, src, ErrorDetailsThrowsInDestructor()); + aes_AES256_parse_key(&dest, src, ErrorDetailsThrowsInDestructor()); } template <> - std::string to_string<AESNI_AES256>(const aes256::Key& src) + std::string to_string<AES_AES256>(const aes256::Key& src) { - AesNI_AES256_KeyString str; - aesni_AES256_format_key(&str, &src, ErrorDetailsThrowsInDestructor()); + AES_AES256_KeyString str; + aes_AES256_format_key(&str, &src, ErrorDetailsThrowsInDestructor()); return { str.str }; } template <> - inline void expand_key<AESNI_AES256>( + inline void expand_key<AES_AES256>( const aes256::Key& key, aes256::RoundKeys& encryption_keys) { - aesni_AES256_expand_key(&key, &encryption_keys); + aes_AES256_expand_key(&key, &encryption_keys); } template <> - inline void derive_decryption_keys<AESNI_AES256>( + inline void derive_decryption_keys<AES_AES256>( const aes256::RoundKeys& encryption_keys, aes256::RoundKeys& decryption_keys) { - aesni_AES256_derive_decryption_keys( + aes_AES256_derive_decryption_keys( &encryption_keys, &decryption_keys); } - AESNIXX_ENCRYPT_BLOCK_ECB(AES256); - AESNIXX_DECRYPT_BLOCK_ECB(AES256); - AESNIXX_ENCRYPT_BLOCK_CBC(AES256); - AESNIXX_DECRYPT_BLOCK_CBC(AES256); - AESNIXX_ENCRYPT_BLOCK_CFB(AES256); - AESNIXX_DECRYPT_BLOCK_CFB(AES256); - AESNIXX_ENCRYPT_BLOCK_OFB(AES256); - AESNIXX_DECRYPT_BLOCK_OFB(AES256); - AESNIXX_ENCRYPT_BLOCK_CTR(AES256); - AESNIXX_DECRYPT_BLOCK_CTR(AES256); + AESXX_ENCRYPT_BLOCK_ECB(AES256); + AESXX_DECRYPT_BLOCK_ECB(AES256); + AESXX_ENCRYPT_BLOCK_CBC(AES256); + AESXX_DECRYPT_BLOCK_CBC(AES256); + AESXX_ENCRYPT_BLOCK_CFB(AES256); + AESXX_DECRYPT_BLOCK_CFB(AES256); + AESXX_ENCRYPT_BLOCK_OFB(AES256); + AESXX_DECRYPT_BLOCK_OFB(AES256); + AESXX_ENCRYPT_BLOCK_CTR(AES256); + AESXX_DECRYPT_BLOCK_CTR(AES256); } diff --git a/cxx/include/aesxx/algorithm.hpp b/cxx/include/aesxx/algorithm.hpp index e2c73ac..c6f06d7 100644 --- a/cxx/include/aesxx/algorithm.hpp +++ b/cxx/include/aesxx/algorithm.hpp @@ -10,7 +10,7 @@ #include <aes/all.h> -namespace aesni +namespace aes { - typedef AesNI_Algorithm Algorithm; + typedef AES_Algorithm Algorithm; } diff --git a/cxx/include/aesxx/api.hpp b/cxx/include/aesxx/api.hpp index 6995ae2..0b183a8 100644 --- a/cxx/include/aesxx/api.hpp +++ b/cxx/include/aesxx/api.hpp @@ -16,7 +16,7 @@ #include <string> #include <type_traits> -namespace aesni +namespace aes { template <Algorithm algorithm> struct Types; @@ -129,7 +129,7 @@ namespace aesni const typename Types<algorithm>::Block& plaintext, typename Types<algorithm>::Block& ciphertext) { - aesni::encrypt_block<algorithm, mode>( + aes::encrypt_block<algorithm, mode>( plaintext, encryption_keys, iv, ciphertext); } @@ -161,7 +161,7 @@ namespace aesni const typename Types<algorithm>::Block& ciphertext, typename Types<algorithm>::Block& plaintext) { - aesni::decrypt_block<algorithm, mode>( + aes::decrypt_block<algorithm, mode>( ciphertext, decryption_keys, iv, plaintext); } diff --git a/cxx/include/aesxx/box.hpp b/cxx/include/aesxx/box.hpp index ffca6ce..7df8c97 100644 --- a/cxx/include/aesxx/box.hpp +++ b/cxx/include/aesxx/box.hpp @@ -21,26 +21,26 @@ #include <string> #include <vector> -namespace aesni +namespace aes { class Box { public: - typedef AesNI_BoxBlock Block; - typedef AesNI_BoxKey Key; + typedef AES_BoxBlock Block; + typedef AES_BoxKey Key; static std::string format_key(const Key& src, Algorithm algorithm) { - AesNI_BoxKeyString str; - aesni_box_format_key( + AES_BoxKeyString str; + aes_box_format_key( &str, algorithm, &src, ErrorDetailsThrowsInDestructor()); return reinterpret_cast<const char*>(&str); } static std::string format_block(const Block& src, Algorithm algorithm) { - AesNI_BoxBlockString str; - aesni_box_format_block( + AES_BoxBlockString str; + aes_box_format_block( &str, algorithm, &src, ErrorDetailsThrowsInDestructor()); return reinterpret_cast<const char*>(&str); } @@ -50,7 +50,7 @@ namespace aesni Algorithm algorithm, const char* src) { - aesni_box_parse_block(&dest, algorithm, src, + aes_box_parse_block(&dest, algorithm, src, ErrorDetailsThrowsInDestructor()); } @@ -67,7 +67,7 @@ namespace aesni Algorithm algorithm, const char* src) { - aesni_box_parse_key(&dest, algorithm, src, + aes_box_parse_key(&dest, algorithm, src, ErrorDetailsThrowsInDestructor()); } @@ -81,9 +81,9 @@ namespace aesni Box(Algorithm algorithm, const Key& key) : algorithm(algorithm) - , mode(AESNI_ECB) + , mode(AES_ECB) { - aesni_box_init(&impl, algorithm, &key, mode, nullptr, + aes_box_init(&impl, algorithm, &key, mode, nullptr, ErrorDetailsThrowsInDestructor()); } @@ -91,20 +91,20 @@ namespace aesni : algorithm(algorithm) , mode(mode) { - aesni_box_init(&impl, algorithm, &key, mode, &iv, + aes_box_init(&impl, algorithm, &key, mode, &iv, ErrorDetailsThrowsInDestructor()); } void encrypt_block(const Block& plaintext, Block& ciphertext) { - aesni_box_encrypt_block( + aes_box_encrypt_block( &impl, &plaintext, &ciphertext, ErrorDetailsThrowsInDestructor()); } void decrypt_block(const Block& ciphertext, Block& plaintext) { - aesni_box_decrypt_block( + aes_box_decrypt_block( &impl, &ciphertext, &plaintext, ErrorDetailsThrowsInDestructor()); } @@ -115,24 +115,24 @@ namespace aesni { std::size_t dest_size; - aesni_box_encrypt_buffer( + aes_box_encrypt_buffer( &impl, src_buf, src_size, nullptr, &dest_size, - aesni::ErrorDetailsThrowsInDestructor()); + aes::ErrorDetailsThrowsInDestructor()); std::vector<unsigned char> dest_buf; dest_buf.resize(dest_size); - aesni_box_encrypt_buffer( + aes_box_encrypt_buffer( &impl, src_buf, src_size, dest_buf.data(), &dest_size, - aesni::ErrorDetailsThrowsInDestructor()); + aes::ErrorDetailsThrowsInDestructor()); dest_buf.resize(dest_size); return dest_buf; @@ -144,24 +144,24 @@ namespace aesni { std::size_t dest_size; - aesni_box_decrypt_buffer( + aes_box_decrypt_buffer( &impl, src_buf, src_size, nullptr, &dest_size, - aesni::ErrorDetailsThrowsInDestructor()); + aes::ErrorDetailsThrowsInDestructor()); std::vector<unsigned char> dest_buf; dest_buf.resize(dest_size); - aesni_box_decrypt_buffer( + aes_box_decrypt_buffer( &impl, src_buf, src_size, dest_buf.data(), &dest_size, - aesni::ErrorDetailsThrowsInDestructor()); + aes::ErrorDetailsThrowsInDestructor()); dest_buf.resize(dest_size); return dest_buf; @@ -207,6 +207,6 @@ namespace aesni Algorithm algorithm; Mode mode; - AesNI_Box impl; + AES_Box impl; }; } diff --git a/cxx/include/aesxx/data.hpp b/cxx/include/aesxx/data.hpp index f52fe3e..9b07343 100644 --- a/cxx/include/aesxx/data.hpp +++ b/cxx/include/aesxx/data.hpp @@ -12,47 +12,47 @@ #include <aes/all.h> -namespace aesni +namespace aes { - typedef AesNI_Block128 Block128; + typedef AES_Block128 Block128; inline void make_block(Block128& dest, int hi3, int hi2, int lo1, int lo0) { - dest = aesni_make_block128(hi3, hi2, lo1, lo0); + dest = aes_make_block128(hi3, hi2, lo1, lo0); } inline void load_block(Block128& dest, const void* src) { - dest = aesni_load_block128(src); + dest = aes_load_block128(src); } inline void load_block_aligned(Block128& dest, const void* src) { - dest = aesni_load_block128_aligned(src); + dest = aes_load_block128_aligned(src); } inline void store_block(void* dest, Block128& src) { - aesni_store_block128(dest, src); + aes_store_block128(dest, src); } inline void store_block_aligned(void* dest, Block128& src) { - aesni_store_block128_aligned(dest, src); + aes_store_block128_aligned(dest, src); } inline Block128 xor_blocks(Block128& a, Block128& b) { - return aesni_xor_block128(a, b); + return aes_xor_block128(a, b); } inline Block128 reverse_byte_order(Block128& block) { - return aesni_reverse_byte_order_block128(block); + return aes_reverse_byte_order_block128(block); } inline Block128 inc_block(Block128& block) { - return aesni_inc_block128(block); + return aes_inc_block128(block); } } diff --git a/cxx/include/aesxx/debug.hpp b/cxx/include/aesxx/debug.hpp index f3e35f4..d690257 100644 --- a/cxx/include/aesxx/debug.hpp +++ b/cxx/include/aesxx/debug.hpp @@ -19,7 +19,7 @@ #include <sstream> #include <string> -namespace aesni +namespace aes { namespace aux { diff --git a/cxx/include/aesxx/error.hpp b/cxx/include/aesxx/error.hpp index 1f22535..85f45bf 100644 --- a/cxx/include/aesxx/error.hpp +++ b/cxx/include/aesxx/error.hpp @@ -24,12 +24,12 @@ #include <string> #include <vector> -namespace aesni +namespace aes { class Error : public std::runtime_error { public: - Error(const AesNI_ErrorDetails& err_details) + Error(const AES_ErrorDetails& err_details) : std::runtime_error(format_error_message(err_details)) { copy_call_stack(err_details); @@ -45,27 +45,27 @@ namespace aesni } private: - static std::string format_error_message(const AesNI_ErrorDetails& err_details) + static std::string format_error_message(const AES_ErrorDetails& err_details) { std::vector<char> buf; - buf.resize(aesni_format_error(&err_details, NULL, 0)); - aesni_format_error(&err_details, buf.data(), buf.size()); + buf.resize(aes_format_error(&err_details, NULL, 0)); + aes_format_error(&err_details, buf.data(), buf.size()); return { buf.begin(), buf.end() }; } - void copy_call_stack(const AesNI_ErrorDetails& err_details) + void copy_call_stack(const AES_ErrorDetails& err_details) { call_stack_size = err_details.call_stack_size; std::memcpy(call_stack, err_details.call_stack, call_stack_size * sizeof(void*)); } - void* call_stack[AESNI_MAX_CALL_STACK_LENGTH]; + void* call_stack[AES_MAX_CALL_STACK_LENGTH]; std::size_t call_stack_size; }; std::ostream& operator<<(std::ostream& os, const Error& e) { - os << "AesNI error: " << e.what() << '\n'; + os << "AES error: " << e.what() << '\n'; os << "Call stack:\n"; e.for_each_in_call_stack([&os] (void* addr, const std::string& name) { @@ -79,20 +79,20 @@ namespace aesni public: ErrorDetailsThrowsInDestructor() { - aesni_success(get()); + aes_success(get()); } ~ErrorDetailsThrowsInDestructor() BOOST_NOEXCEPT_IF(false) { - if (aesni_is_error(aesni_get_error_code(get()))) + if (aes_is_error(aes_get_error_code(get()))) throw Error(impl); } - AesNI_ErrorDetails* get() { return &impl; } + AES_ErrorDetails* get() { return &impl; } - operator AesNI_ErrorDetails*() { return get(); } + operator AES_ErrorDetails*() { return get(); } private: - AesNI_ErrorDetails impl; + AES_ErrorDetails impl; }; } diff --git a/cxx/include/aesxx/mode.hpp b/cxx/include/aesxx/mode.hpp index 706c4b5..70f16c6 100644 --- a/cxx/include/aesxx/mode.hpp +++ b/cxx/include/aesxx/mode.hpp @@ -12,16 +12,16 @@ #include <type_traits> -namespace aesni +namespace aes { - typedef AesNI_Mode Mode; + typedef AES_Mode Mode; template <Mode mode> struct ModeRequiresInitializationVector : public std::true_type { }; template <> - struct ModeRequiresInitializationVector<AESNI_ECB> : public std::false_type + struct ModeRequiresInitializationVector<AES_ECB> : public std::false_type { }; template <Mode mode> @@ -30,127 +30,127 @@ namespace aesni inline bool mode_requires_initialization_vector(Mode mode) { - return mode != AESNI_ECB; + return mode != AES_ECB; } template <> - struct ModeUsesEncryptionKeysOnly<AESNI_ECB> : public std::false_type + struct ModeUsesEncryptionKeysOnly<AES_ECB> : public std::false_type { }; template <> - struct ModeUsesEncryptionKeysOnly<AESNI_CBC> : public std::false_type + struct ModeUsesEncryptionKeysOnly<AES_CBC> : public std::false_type { }; inline bool mode_uses_encryption_keys_only(Mode mode) { - return mode != AESNI_ECB && mode != AESNI_CBC; + return mode != AES_ECB && mode != AES_CBC; } -#define AESNIXX_ENCRYPT_BLOCK_ECB(prefix) \ +#define AESXX_ENCRYPT_BLOCK_ECB(prefix) \ template <> \ - inline void encrypt_block<AESNI_## prefix, AESNI_ECB>( \ - const typename Types<AESNI_## prefix>::Block& plaintext, \ - const typename Types<AESNI_## prefix>::RoundKeys& encryption_keys, \ - typename Types<AESNI_## prefix>::Block& ciphertext) \ + inline void encrypt_block<AES_## prefix, AES_ECB>( \ + const typename Types<AES_## prefix>::Block& plaintext, \ + const typename Types<AES_## prefix>::RoundKeys& encryption_keys, \ + typename Types<AES_## prefix>::Block& ciphertext) \ { \ - ciphertext = aesni_## prefix ##_encrypt_block_ECB(plaintext, &encryption_keys); \ + ciphertext = aes_## prefix ##_encrypt_block_ECB(plaintext, &encryption_keys); \ } -#define AESNIXX_DECRYPT_BLOCK_ECB(prefix) \ +#define AESXX_DECRYPT_BLOCK_ECB(prefix) \ template <> \ - inline void decrypt_block<AESNI_## prefix, AESNI_ECB>( \ - const typename Types<AESNI_## prefix>::Block& ciphertext, \ - const typename Types<AESNI_## prefix>::RoundKeys& decryption_keys, \ - typename Types<AESNI_## prefix>::Block& plaintext) \ + inline void decrypt_block<AES_## prefix, AES_ECB>( \ + const typename Types<AES_## prefix>::Block& ciphertext, \ + const typename Types<AES_## prefix>::RoundKeys& decryption_keys, \ + typename Types<AES_## prefix>::Block& plaintext) \ { \ - plaintext = aesni_## prefix ##_decrypt_block_ECB(ciphertext, &decryption_keys); \ + plaintext = aes_## prefix ##_decrypt_block_ECB(ciphertext, &decryption_keys); \ } -#define AESNIXX_ENCRYPT_BLOCK_CBC(prefix) \ +#define AESXX_ENCRYPT_BLOCK_CBC(prefix) \ template <> \ - inline void encrypt_block<AESNI_## prefix, AESNI_CBC>( \ - const typename Types<AESNI_## prefix>::Block& plaintext, \ - const typename Types<AESNI_## prefix>::RoundKeys& encryption_keys, \ - typename Types<AESNI_## prefix>::Block& iv, \ - typename Types<AESNI_## prefix>::Block& ciphertext) \ + inline void encrypt_block<AES_## prefix, AES_CBC>( \ + const typename Types<AES_## prefix>::Block& plaintext, \ + const typename Types<AES_## prefix>::RoundKeys& encryption_keys, \ + typename Types<AES_## prefix>::Block& iv, \ + typename Types<AES_## prefix>::Block& ciphertext) \ { \ - ciphertext = aesni_## prefix ##_encrypt_block_CBC(plaintext, &encryption_keys, iv, &iv); \ + ciphertext = aes_## prefix ##_encrypt_block_CBC(plaintext, &encryption_keys, iv, &iv); \ } -#define AESNIXX_DECRYPT_BLOCK_CBC(prefix) \ +#define AESXX_DECRYPT_BLOCK_CBC(prefix) \ template <> \ - inline void decrypt_block<AESNI_## prefix, AESNI_CBC>( \ - const typename Types<AESNI_## prefix>::Block& ciphertext, \ - const typename Types<AESNI_## prefix>::RoundKeys& decryption_keys, \ - typename Types<AESNI_## prefix>::Block& iv, \ - typename Types<AESNI_## prefix>::Block& plaintext) \ + inline void decrypt_block<AES_## prefix, AES_CBC>( \ + const typename Types<AES_## prefix>::Block& ciphertext, \ + const typename Types<AES_## prefix>::RoundKeys& decryption_keys, \ + typename Types<AES_## prefix>::Block& iv, \ + typename Types<AES_## prefix>::Block& plaintext) \ { \ - plaintext = aesni_## prefix ##_decrypt_block_CBC(ciphertext, &decryption_keys, iv, &iv); \ + plaintext = aes_## prefix ##_decrypt_block_CBC(ciphertext, &decryption_keys, iv, &iv); \ } -#define AESNIXX_ENCRYPT_BLOCK_CFB(prefix) \ +#define AESXX_ENCRYPT_BLOCK_CFB(prefix) \ template <> \ - inline void encrypt_block<AESNI_## prefix, AESNI_CFB>( \ - const typename Types<AESNI_## prefix>::Block& plaintext, \ - const typename Types<AESNI_## prefix>::RoundKeys& encryption_keys, \ - typename Types<AESNI_## prefix>::Block& iv, \ - typename Types<AESNI_## prefix>::Block& ciphertext) \ + inline void encrypt_block<AES_## prefix, AES_CFB>( \ + const typename Types<AES_## prefix>::Block& plaintext, \ + const typename Types<AES_## prefix>::RoundKeys& encryption_keys, \ + typename Types<AES_## prefix>::Block& iv, \ + typename Types<AES_## prefix>::Block& ciphertext) \ { \ - ciphertext = aesni_## prefix ##_encrypt_block_CFB(plaintext, &encryption_keys, iv, &iv); \ + ciphertext = aes_## prefix ##_encrypt_block_CFB(plaintext, &encryption_keys, iv, &iv); \ } -#define AESNIXX_DECRYPT_BLOCK_CFB(prefix) \ +#define AESXX_DECRYPT_BLOCK_CFB(prefix) \ template <> \ - inline void decrypt_block<AESNI_## prefix, AESNI_CFB>( \ - const typename Types<AESNI_## prefix>::Block& ciphertext, \ - const typename Types<AESNI_## prefix>::RoundKeys& encryption_keys, \ - typename Types<AESNI_## prefix>::Block& iv, \ - typename Types<AESNI_## prefix>::Block& plaintext) \ + inline void decrypt_block<AES_## prefix, AES_CFB>( \ + const typename Types<AES_## prefix>::Block& ciphertext, \ + const typename Types<AES_## prefix>::RoundKeys& encryption_keys, \ + typename Types<AES_## prefix>::Block& iv, \ + typename Types<AES_## prefix>::Block& plaintext) \ { \ - plaintext = aesni_## prefix ##_decrypt_block_CFB(ciphertext, &encryption_keys, iv, &iv); \ + plaintext = aes_## prefix ##_decrypt_block_CFB(ciphertext, &encryption_keys, iv, &iv); \ } -#define AESNIXX_ENCRYPT_BLOCK_OFB(prefix) \ +#define AESXX_ENCRYPT_BLOCK_OFB(prefix) \ template <> \ - inline void encrypt_block<AESNI_## prefix, AESNI_OFB>( \ - const typename Types<AESNI_## prefix>::Block& plaintext, \ - const typename Types<AESNI_## prefix>::RoundKeys& encryption_keys, \ - typename Types<AESNI_## prefix>::Block& iv, \ - typename Types<AESNI_## prefix>::Block& ciphertext) \ + inline void encrypt_block<AES_## prefix, AES_OFB>( \ + const typename Types<AES_## prefix>::Block& plaintext, \ + const typename Types<AES_## prefix>::RoundKeys& encryption_keys, \ + typename Types<AES_## prefix>::Block& iv, \ + typename Types<AES_## prefix>::Block& ciphertext) \ { \ - ciphertext = aesni_## prefix ##_encrypt_block_OFB(plaintext, &encryption_keys, iv, &iv); \ + ciphertext = aes_## prefix ##_encrypt_block_OFB(plaintext, &encryption_keys, iv, &iv); \ } -#define AESNIXX_DECRYPT_BLOCK_OFB(prefix) \ +#define AESXX_DECRYPT_BLOCK_OFB(prefix) \ template <> \ - inline void decrypt_block<AESNI_## prefix, AESNI_OFB>( \ - const typename Types<AESNI_## prefix>::Block& ciphertext, \ - const typename Types<AESNI_## prefix>::RoundKeys& encryption_keys, \ - typename Types<AESNI_## prefix>::Block& iv, \ - typename Types<AESNI_## prefix>::Block& plaintext) \ + inline void decrypt_block<AES_## prefix, AES_OFB>( \ + const typename Types<AES_## prefix>::Block& ciphertext, \ + const typename Types<AES_## prefix>::RoundKeys& encryption_keys, \ + typename Types<AES_## prefix>::Block& iv, \ + typename Types<AES_## prefix>::Block& plaintext) \ { \ - plaintext = aesni_## prefix ##_decrypt_block_OFB(ciphertext, &encryption_keys, iv, &iv); \ + plaintext = aes_## prefix ##_decrypt_block_OFB(ciphertext, &encryption_keys, iv, &iv); \ } -#define AESNIXX_ENCRYPT_BLOCK_CTR(prefix) \ +#define AESXX_ENCRYPT_BLOCK_CTR(prefix) \ template <> \ - inline void encrypt_block<AESNI_## prefix, AESNI_CTR>( \ - const typename Types<AESNI_## prefix>::Block& plaintext, \ - const typename Types<AESNI_## prefix>::RoundKeys& encryption_keys, \ - typename Types<AESNI_## prefix>::Block& iv, \ - typename Types<AESNI_## prefix>::Block& ciphertext) \ + inline void encrypt_block<AES_## prefix, AES_CTR>( \ + const typename Types<AES_## prefix>::Block& plaintext, \ + const typename Types<AES_## prefix>::RoundKeys& encryption_keys, \ + typename Types<AES_## prefix>::Block& iv, \ + typename Types<AES_## prefix>::Block& ciphertext) \ { \ - ciphertext = aesni_## prefix ##_encrypt_block_CTR(plaintext, &encryption_keys, iv, &iv); \ + ciphertext = aes_## prefix ##_encrypt_block_CTR(plaintext, &encryption_keys, iv, &iv); \ } -#define AESNIXX_DECRYPT_BLOCK_CTR(prefix) \ +#define AESXX_DECRYPT_BLOCK_CTR(prefix) \ template <> \ - inline void decrypt_block<AESNI_## prefix, AESNI_CTR>( \ - const typename Types<AESNI_## prefix>::Block& ciphertext, \ - const typename Types<AESNI_## prefix>::RoundKeys& encryption_keys, \ - typename Types<AESNI_## prefix>::Block& iv, \ - typename Types<AESNI_## prefix>::Block& plaintext) \ + inline void decrypt_block<AES_## prefix, AES_CTR>( \ + const typename Types<AES_## prefix>::Block& ciphertext, \ + const typename Types<AES_## prefix>::RoundKeys& encryption_keys, \ + typename Types<AES_## prefix>::Block& iv, \ + typename Types<AES_## prefix>::Block& plaintext) \ { \ - plaintext = aesni_## prefix ##_decrypt_block_CTR(ciphertext, &encryption_keys, iv, &iv); \ + plaintext = aes_## prefix ##_decrypt_block_CTR(ciphertext, &encryption_keys, iv, &iv); \ } } |