From f0393777befc4ff1024513dab3ab6bad0e7ec45f Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Thu, 19 May 2016 04:48:59 +0300 Subject: 'aesni' -> 'aes' --- cxx/include/aesxx/aes.hpp | 194 ++++++++++++++++++++-------------------- cxx/include/aesxx/algorithm.hpp | 4 +- cxx/include/aesxx/api.hpp | 6 +- cxx/include/aesxx/box.hpp | 46 +++++----- cxx/include/aesxx/data.hpp | 20 ++--- cxx/include/aesxx/debug.hpp | 2 +- cxx/include/aesxx/error.hpp | 26 +++--- cxx/include/aesxx/mode.hpp | 150 +++++++++++++++---------------- 8 files changed, 224 insertions(+), 224 deletions(-) (limited to 'cxx/include/aesxx') 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 -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 + struct Types { typedef aes128::Block Block; typedef aes128::RoundKeys RoundKeys; @@ -37,84 +37,84 @@ namespace aesni }; template <> - std::size_t get_number_of_rounds() + std::size_t get_number_of_rounds() { return 11; } template <> - void from_string(aes128::Block& dest, const char* src) + void from_string(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(const aes128::Block& src) + std::string to_string(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(const aes128::Block& src) + std::string to_matrix_string(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(aes128::Key& dest, const char* src) + void from_string(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(const aes128::Key& src) + std::string to_string(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( + inline void expand_key( 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( + inline void derive_decryption_keys( 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 + struct Types { typedef aes192::Block Block; typedef aes192::RoundKeys RoundKeys; @@ -122,84 +122,84 @@ namespace aesni }; template <> - std::size_t get_number_of_rounds() + std::size_t get_number_of_rounds() { return 13; } template <> - void from_string(aes192::Block& dest, const char* src) + void from_string(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(const aes192::Block& src) + std::string to_string(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(const aes192::Block& src) + std::string to_matrix_string(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(aes192::Key& dest, const char* src) + void from_string(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(const aes192::Key& src) + std::string to_string(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( + inline void expand_key( 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( + inline void derive_decryption_keys( 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 + struct Types { typedef aes256::Block Block; typedef aes256::RoundKeys RoundKeys; @@ -207,72 +207,72 @@ namespace aesni }; template <> - std::size_t get_number_of_rounds() + std::size_t get_number_of_rounds() { return 15; } template <> - void from_string(aes256::Block& dest, const char* src) + void from_string(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(const aes256::Block& src) + std::string to_string(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(const aes256::Block& src) + std::string to_matrix_string(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(aes256::Key& dest, const char* src) + void from_string(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(const aes256::Key& src) + std::string to_string(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( + inline void expand_key( 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( + inline void derive_decryption_keys( 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 -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 #include -namespace aesni +namespace aes { template struct Types; @@ -129,7 +129,7 @@ namespace aesni const typename Types::Block& plaintext, typename Types::Block& ciphertext) { - aesni::encrypt_block( + aes::encrypt_block( plaintext, encryption_keys, iv, ciphertext); } @@ -161,7 +161,7 @@ namespace aesni const typename Types::Block& ciphertext, typename Types::Block& plaintext) { - aesni::decrypt_block( + aes::decrypt_block( 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 #include -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(&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(&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 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 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 -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 #include -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 #include -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 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 -namespace aesni +namespace aes { - typedef AesNI_Mode Mode; + typedef AES_Mode Mode; template struct ModeRequiresInitializationVector : public std::true_type { }; template <> - struct ModeRequiresInitializationVector : public std::false_type + struct ModeRequiresInitializationVector : public std::false_type { }; template @@ -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 : public std::false_type + struct ModeUsesEncryptionKeysOnly : public std::false_type { }; template <> - struct ModeUsesEncryptionKeysOnly : public std::false_type + struct ModeUsesEncryptionKeysOnly : 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( \ - const typename Types::Block& plaintext, \ - const typename Types::RoundKeys& encryption_keys, \ - typename Types::Block& ciphertext) \ + inline void encrypt_block( \ + const typename Types::Block& plaintext, \ + const typename Types::RoundKeys& encryption_keys, \ + typename Types::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( \ - const typename Types::Block& ciphertext, \ - const typename Types::RoundKeys& decryption_keys, \ - typename Types::Block& plaintext) \ + inline void decrypt_block( \ + const typename Types::Block& ciphertext, \ + const typename Types::RoundKeys& decryption_keys, \ + typename Types::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( \ - const typename Types::Block& plaintext, \ - const typename Types::RoundKeys& encryption_keys, \ - typename Types::Block& iv, \ - typename Types::Block& ciphertext) \ + inline void encrypt_block( \ + const typename Types::Block& plaintext, \ + const typename Types::RoundKeys& encryption_keys, \ + typename Types::Block& iv, \ + typename Types::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( \ - const typename Types::Block& ciphertext, \ - const typename Types::RoundKeys& decryption_keys, \ - typename Types::Block& iv, \ - typename Types::Block& plaintext) \ + inline void decrypt_block( \ + const typename Types::Block& ciphertext, \ + const typename Types::RoundKeys& decryption_keys, \ + typename Types::Block& iv, \ + typename Types::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( \ - const typename Types::Block& plaintext, \ - const typename Types::RoundKeys& encryption_keys, \ - typename Types::Block& iv, \ - typename Types::Block& ciphertext) \ + inline void encrypt_block( \ + const typename Types::Block& plaintext, \ + const typename Types::RoundKeys& encryption_keys, \ + typename Types::Block& iv, \ + typename Types::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( \ - const typename Types::Block& ciphertext, \ - const typename Types::RoundKeys& encryption_keys, \ - typename Types::Block& iv, \ - typename Types::Block& plaintext) \ + inline void decrypt_block( \ + const typename Types::Block& ciphertext, \ + const typename Types::RoundKeys& encryption_keys, \ + typename Types::Block& iv, \ + typename Types::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( \ - const typename Types::Block& plaintext, \ - const typename Types::RoundKeys& encryption_keys, \ - typename Types::Block& iv, \ - typename Types::Block& ciphertext) \ + inline void encrypt_block( \ + const typename Types::Block& plaintext, \ + const typename Types::RoundKeys& encryption_keys, \ + typename Types::Block& iv, \ + typename Types::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( \ - const typename Types::Block& ciphertext, \ - const typename Types::RoundKeys& encryption_keys, \ - typename Types::Block& iv, \ - typename Types::Block& plaintext) \ + inline void decrypt_block( \ + const typename Types::Block& ciphertext, \ + const typename Types::RoundKeys& encryption_keys, \ + typename Types::Block& iv, \ + typename Types::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( \ - const typename Types::Block& plaintext, \ - const typename Types::RoundKeys& encryption_keys, \ - typename Types::Block& iv, \ - typename Types::Block& ciphertext) \ + inline void encrypt_block( \ + const typename Types::Block& plaintext, \ + const typename Types::RoundKeys& encryption_keys, \ + typename Types::Block& iv, \ + typename Types::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( \ - const typename Types::Block& ciphertext, \ - const typename Types::RoundKeys& encryption_keys, \ - typename Types::Block& iv, \ - typename Types::Block& plaintext) \ + inline void decrypt_block( \ + const typename Types::Block& ciphertext, \ + const typename Types::RoundKeys& encryption_keys, \ + typename Types::Block& iv, \ + typename Types::Block& plaintext) \ { \ - plaintext = aesni_## prefix ##_decrypt_block_CTR(ciphertext, &encryption_keys, iv, &iv); \ + plaintext = aes_## prefix ##_decrypt_block_CTR(ciphertext, &encryption_keys, iv, &iv); \ } } -- cgit v1.2.3