diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2015-06-17 18:29:40 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2015-06-17 18:29:40 +0300 |
commit | 0651133db30c0932877780c2f98901e4ca1072e1 (patch) | |
tree | 2b87823b4b9f4b5a75affa4b1606abb06a598c97 | |
parent | factor out 128-bit XORing (diff) | |
download | aes-tools-0651133db30c0932877780c2f98901e4ca1072e1.tar.gz aes-tools-0651133db30c0932877780c2f98901e4ca1072e1.zip |
refactoring
62 files changed, 449 insertions, 664 deletions
diff --git a/cxx/include/aesnixx/data.hpp b/cxx/include/aesnixx/data.hpp index 7a67b27..c667e94 100644 --- a/cxx/include/aesnixx/data.hpp +++ b/cxx/include/aesnixx/data.hpp @@ -23,9 +23,9 @@ namespace aesni typedef AesNI_Block192 Block192; typedef AesNI_Block256 Block256; - typedef AesNI_KeySchedule128 KeySchedule128; - typedef AesNI_KeySchedule192 KeySchedule192; - typedef AesNI_KeySchedule256 KeySchedule256; + typedef AesNI_Aes128_RoundKeys KeySchedule128; + typedef AesNI_Aes192_RoundKeys KeySchedule192; + typedef AesNI_Aes256_RoundKeys KeySchedule256; template <typename KeyScheduleT> inline std::size_t get_number_of_keys(const KeyScheduleT& key_schedule) diff --git a/examples/aes128cbc.cpp b/examples/aes128cbc.cpp index c7e6550..5bb8c67 100644 --- a/examples/aes128cbc.cpp +++ b/examples/aes128cbc.cpp @@ -29,19 +29,19 @@ int main() make_default_iv(iv); aesni::KeySchedule128 encryption_schedule; - aesni_expand_key_schedule128(key, &encryption_schedule); + aesni_aes128_expand_key(key, &encryption_schedule); dump_encryption_schedule(encryption_schedule); aesni::Block128 next_iv; - const auto ciphertext = aesni_encrypt_block_cbc128(plaintext, &encryption_schedule, iv, &next_iv); + const auto ciphertext = aesni_aes128_encrypt_block_cbc(plaintext, &encryption_schedule, iv, &next_iv); dump_ciphertext(ciphertext); dump_next_iv(next_iv); aesni::KeySchedule128 decryption_schedule; - aesni_invert_key_schedule128(&encryption_schedule, &decryption_schedule); + aesni_aes128_derive_decryption_keys(&encryption_schedule, &decryption_schedule); dump_decryption_schedule(decryption_schedule); - aesni::Block128 decrypted = aesni_decrypt_block_cbc128(ciphertext, &decryption_schedule, iv, &next_iv); + aesni::Block128 decrypted = aesni_aes128_decrypt_block_cbc(ciphertext, &decryption_schedule, iv, &next_iv); dump_decrypted(decrypted); dump_next_iv(next_iv); diff --git a/examples/aes128cfb.cpp b/examples/aes128cfb.cpp index 72a1be0..b5f78a7 100644 --- a/examples/aes128cfb.cpp +++ b/examples/aes128cfb.cpp @@ -29,15 +29,15 @@ int main() make_default_iv(iv); aesni::KeySchedule128 encryption_schedule; - aesni_expand_key_schedule128(key, &encryption_schedule); + aesni_aes128_expand_key(key, &encryption_schedule); dump_encryption_schedule(encryption_schedule); aesni::Block128 next_iv; - const auto ciphertext = aesni_encrypt_block_cfb128(plaintext, &encryption_schedule, iv, &next_iv); + const auto ciphertext = aesni_aes128_encrypt_block_cfb(plaintext, &encryption_schedule, iv, &next_iv); dump_ciphertext(ciphertext); dump_next_iv(next_iv); - const auto decrypted = aesni_decrypt_block_cfb128(ciphertext, &encryption_schedule, iv, &next_iv); + const auto decrypted = aesni_aes128_decrypt_block_cfb(ciphertext, &encryption_schedule, iv, &next_iv); dump_decrypted(decrypted); dump_next_iv(next_iv); diff --git a/examples/aes128ctr.cpp b/examples/aes128ctr.cpp index a02052c..0515336 100644 --- a/examples/aes128ctr.cpp +++ b/examples/aes128ctr.cpp @@ -29,13 +29,13 @@ int main() make_default_iv(iv); aesni::KeySchedule128 encryption_schedule; - aesni_expand_key_schedule128(key, &encryption_schedule); + aesni_aes128_expand_key(key, &encryption_schedule); dump_encryption_schedule(encryption_schedule); - const auto ciphertext = aesni_encrypt_block_ctr128(plaintext, &encryption_schedule, iv, 0); + const auto ciphertext = aesni_aes128_encrypt_block_ctr(plaintext, &encryption_schedule, iv, 0); dump_ciphertext(ciphertext); - const auto decrypted = aesni_decrypt_block_ctr128(ciphertext, &encryption_schedule, iv, 0); + const auto decrypted = aesni_aes128_decrypt_block_ctr(ciphertext, &encryption_schedule, iv, 0); dump_decrypted(decrypted); return 0; diff --git a/examples/aes128ecb.cpp b/examples/aes128ecb.cpp index 8ffda3a..b33c00a 100644 --- a/examples/aes128ecb.cpp +++ b/examples/aes128ecb.cpp @@ -26,17 +26,17 @@ int main() make_default_key(key); aesni::KeySchedule128 encryption_schedule; - aesni_expand_key_schedule128(key, &encryption_schedule); + aesni_aes128_expand_key(key, &encryption_schedule); dump_encryption_schedule(encryption_schedule); - const auto ciphertext = aesni_encrypt_block_ecb128(plaintext, &encryption_schedule); + const auto ciphertext = aesni_aes128_encrypt_block_ecb(plaintext, &encryption_schedule); dump_ciphertext(ciphertext); aesni::KeySchedule128 decryption_schedule; - aesni_invert_key_schedule128(&encryption_schedule, &decryption_schedule); + aesni_aes128_derive_decryption_keys(&encryption_schedule, &decryption_schedule); dump_decryption_schedule(decryption_schedule); - const auto decrypted = aesni_decrypt_block_ecb128(ciphertext, &decryption_schedule); + const auto decrypted = aesni_aes128_decrypt_block_ecb(ciphertext, &decryption_schedule); dump_decrypted(decrypted); return 0; diff --git a/examples/aes128ofb.cpp b/examples/aes128ofb.cpp index 6b63936..da3d750 100644 --- a/examples/aes128ofb.cpp +++ b/examples/aes128ofb.cpp @@ -29,15 +29,15 @@ int main() make_default_iv(iv); aesni::KeySchedule128 encryption_schedule; - aesni_expand_key_schedule128(key, &encryption_schedule); + aesni_aes128_expand_key(key, &encryption_schedule); dump_encryption_schedule(encryption_schedule); aesni::Block128 next_iv; - const auto ciphertext = aesni_encrypt_block_ofb128(plaintext, &encryption_schedule, iv, &next_iv); + const auto ciphertext = aesni_aes128_encrypt_block_ofb(plaintext, &encryption_schedule, iv, &next_iv); dump_ciphertext(ciphertext); dump_next_iv(next_iv); - const auto decrypted = aesni_decrypt_block_ofb128(ciphertext, &encryption_schedule, iv, &next_iv); + const auto decrypted = aesni_aes128_decrypt_block_ofb(ciphertext, &encryption_schedule, iv, &next_iv); dump_decrypted(decrypted); dump_next_iv(next_iv); diff --git a/examples/aes192cbc.cpp b/examples/aes192cbc.cpp index f4341ea..6d7ff74 100644 --- a/examples/aes192cbc.cpp +++ b/examples/aes192cbc.cpp @@ -29,19 +29,19 @@ int main() make_default_iv(iv); aesni::KeySchedule192 encryption_schedule; - aesni_expand_key_schedule192(&key, &encryption_schedule); + aesni_aes192_expand_key(&key, &encryption_schedule); dump_encryption_schedule(encryption_schedule); aesni::Block128 next_iv; - const auto ciphertext = aesni_encrypt_block_cbc192(plaintext, &encryption_schedule, iv, &next_iv); + const auto ciphertext = aesni_aes192_encrypt_block_cbc(plaintext, &encryption_schedule, iv, &next_iv); dump_ciphertext(ciphertext); dump_next_iv(next_iv); aesni::KeySchedule192 decryption_schedule; - aesni_invert_key_schedule192(&encryption_schedule, &decryption_schedule); + aesni_aes192_derive_decryption_keys(&encryption_schedule, &decryption_schedule); dump_decryption_schedule(decryption_schedule); - const auto decrypted = aesni_decrypt_block_cbc192(ciphertext, &decryption_schedule, iv, &next_iv); + const auto decrypted = aesni_aes192_decrypt_block_cbc(ciphertext, &decryption_schedule, iv, &next_iv); dump_decrypted(decrypted); dump_next_iv(next_iv); diff --git a/examples/aes192cfb.cpp b/examples/aes192cfb.cpp index 88b94b7..a8662ca 100644 --- a/examples/aes192cfb.cpp +++ b/examples/aes192cfb.cpp @@ -29,15 +29,15 @@ int main() make_default_iv(iv); aesni::KeySchedule192 encryption_schedule; - aesni_expand_key_schedule192(&key, &encryption_schedule); + aesni_aes192_expand_key(&key, &encryption_schedule); dump_encryption_schedule(encryption_schedule); aesni::Block128 next_iv; - const auto ciphertext = aesni_encrypt_block_cfb192(plaintext, &encryption_schedule, iv, &next_iv); + const auto ciphertext = aesni_aes192_encrypt_block_cfb(plaintext, &encryption_schedule, iv, &next_iv); dump_ciphertext(ciphertext); dump_next_iv(next_iv); - const auto decrypted = aesni_decrypt_block_cfb192(ciphertext, &encryption_schedule, iv, &next_iv); + const auto decrypted = aesni_aes192_decrypt_block_cfb(ciphertext, &encryption_schedule, iv, &next_iv); dump_decrypted(decrypted); dump_next_iv(next_iv); diff --git a/examples/aes192ctr.cpp b/examples/aes192ctr.cpp index f7278cf..ef4dde6 100644 --- a/examples/aes192ctr.cpp +++ b/examples/aes192ctr.cpp @@ -29,13 +29,13 @@ int main() make_default_iv(iv); aesni::KeySchedule192 encryption_schedule; - aesni_expand_key_schedule192(&key, &encryption_schedule); + aesni_aes192_expand_key(&key, &encryption_schedule); dump_encryption_schedule(encryption_schedule); - const auto ciphertext = aesni_encrypt_block_ctr192(plaintext, &encryption_schedule, iv, 0); + const auto ciphertext = aesni_aes192_encrypt_block_ctr(plaintext, &encryption_schedule, iv, 0); dump_ciphertext(ciphertext); - const auto decrypted = aesni_decrypt_block_ctr192(ciphertext, &encryption_schedule, iv, 0); + const auto decrypted = aesni_aes192_decrypt_block_ctr(ciphertext, &encryption_schedule, iv, 0); dump_decrypted(decrypted); } catch (const std::exception& e) diff --git a/examples/aes192ecb.cpp b/examples/aes192ecb.cpp index 139b48b..6faf96f 100644 --- a/examples/aes192ecb.cpp +++ b/examples/aes192ecb.cpp @@ -26,17 +26,17 @@ int main() make_default_key(key); aesni::KeySchedule192 encryption_schedule; - aesni_expand_key_schedule192(&key, &encryption_schedule); + aesni_aes192_expand_key(&key, &encryption_schedule); dump_encryption_schedule(encryption_schedule); - const auto ciphertext = aesni_encrypt_block_ecb192(plaintext, &encryption_schedule); + const auto ciphertext = aesni_aes192_encrypt_block_ecb(plaintext, &encryption_schedule); dump_ciphertext(ciphertext); aesni::KeySchedule192 decryption_schedule; - aesni_invert_key_schedule192(&encryption_schedule, &decryption_schedule); + aesni_aes192_derive_decryption_keys(&encryption_schedule, &decryption_schedule); dump_decryption_schedule(decryption_schedule); - const auto decrypted = aesni_decrypt_block_ecb192(ciphertext, &decryption_schedule); + const auto decrypted = aesni_aes192_decrypt_block_ecb(ciphertext, &decryption_schedule); dump_decrypted(decrypted); return 0; diff --git a/examples/aes192ofb.cpp b/examples/aes192ofb.cpp index 5a07278..e7de746 100644 --- a/examples/aes192ofb.cpp +++ b/examples/aes192ofb.cpp @@ -29,15 +29,15 @@ int main() make_default_iv(iv); aesni::KeySchedule192 encryption_schedule; - aesni_expand_key_schedule192(&key, &encryption_schedule); + aesni_aes192_expand_key(&key, &encryption_schedule); dump_encryption_schedule(encryption_schedule); aesni::Block128 next_iv; - const auto ciphertext = aesni_encrypt_block_ofb192(plaintext, &encryption_schedule, iv, &next_iv); + const auto ciphertext = aesni_aes192_encrypt_block_ofb(plaintext, &encryption_schedule, iv, &next_iv); dump_ciphertext(ciphertext); dump_next_iv(next_iv); - const auto decrypted = aesni_decrypt_block_ofb192(ciphertext, &encryption_schedule, iv, &next_iv); + const auto decrypted = aesni_aes192_decrypt_block_ofb(ciphertext, &encryption_schedule, iv, &next_iv); dump_decrypted(decrypted); dump_next_iv(next_iv); diff --git a/examples/aes256cbc.cpp b/examples/aes256cbc.cpp index 0253adb..66f7c38 100644 --- a/examples/aes256cbc.cpp +++ b/examples/aes256cbc.cpp @@ -29,19 +29,19 @@ int main() make_default_iv(iv); aesni::KeySchedule256 encryption_schedule; - aesni_expand_key_schedule256(&key, &encryption_schedule); + aesni_aes256_expand_key(&key, &encryption_schedule); dump_encryption_schedule(encryption_schedule); aesni::Block128 next_iv; - const auto ciphertext = aesni_encrypt_block_cbc256(plaintext, &encryption_schedule, iv, &next_iv); + const auto ciphertext = aesni_aes256_encrypt_block_cbc(plaintext, &encryption_schedule, iv, &next_iv); dump_ciphertext(ciphertext); dump_next_iv(next_iv); aesni::KeySchedule256 decryption_schedule; - aesni_invert_key_schedule256(&encryption_schedule, &decryption_schedule); + aesni_aes256_derive_decryption_keys(&encryption_schedule, &decryption_schedule); dump_decryption_schedule(decryption_schedule); - const auto decrypted = aesni_decrypt_block_cbc256(ciphertext, &decryption_schedule, iv, &next_iv); + const auto decrypted = aesni_aes256_decrypt_block_cbc(ciphertext, &decryption_schedule, iv, &next_iv); dump_decrypted(decrypted); dump_next_iv(next_iv); diff --git a/examples/aes256cfb.cpp b/examples/aes256cfb.cpp index ce05aec..8a23146 100644 --- a/examples/aes256cfb.cpp +++ b/examples/aes256cfb.cpp @@ -29,15 +29,15 @@ int main() make_default_iv(iv); aesni::KeySchedule256 encryption_schedule; - aesni_expand_key_schedule256(&key, &encryption_schedule); + aesni_aes256_expand_key(&key, &encryption_schedule); dump_encryption_schedule(encryption_schedule); aesni::Block128 next_iv; - const auto ciphertext = aesni_encrypt_block_cfb256(plaintext, &encryption_schedule, iv, &next_iv); + const auto ciphertext = aesni_aes256_encrypt_block_cfb(plaintext, &encryption_schedule, iv, &next_iv); dump_ciphertext(ciphertext); dump_next_iv(next_iv); - const auto decrypted = aesni_decrypt_block_cfb256(ciphertext, &encryption_schedule, iv, &next_iv); + const auto decrypted = aesni_aes256_decrypt_block_cfb(ciphertext, &encryption_schedule, iv, &next_iv); dump_decrypted(decrypted); dump_next_iv(next_iv); diff --git a/examples/aes256ctr.cpp b/examples/aes256ctr.cpp index 1be85f7..b5e2ae7 100644 --- a/examples/aes256ctr.cpp +++ b/examples/aes256ctr.cpp @@ -29,13 +29,13 @@ int main() make_default_iv(iv); aesni::KeySchedule256 encryption_schedule; - aesni_expand_key_schedule256(&key, &encryption_schedule); + aesni_aes256_expand_key(&key, &encryption_schedule); dump_encryption_schedule(encryption_schedule); - const auto ciphertext = aesni_encrypt_block_ctr256(plaintext, &encryption_schedule, iv, 0); + const auto ciphertext = aesni_aes256_encrypt_block_ctr(plaintext, &encryption_schedule, iv, 0); dump_ciphertext(ciphertext); - const auto decrypted = aesni_decrypt_block_ctr256(ciphertext, &encryption_schedule, iv, 0); + const auto decrypted = aesni_aes256_decrypt_block_ctr(ciphertext, &encryption_schedule, iv, 0); dump_decrypted(decrypted); } catch (const std::exception& e) diff --git a/examples/aes256ecb.cpp b/examples/aes256ecb.cpp index 72f132e..aebd14b 100644 --- a/examples/aes256ecb.cpp +++ b/examples/aes256ecb.cpp @@ -26,17 +26,17 @@ int main() make_default_key(key); aesni::KeySchedule256 encryption_schedule; - aesni_expand_key_schedule256(&key, &encryption_schedule); + aesni_aes256_expand_key(&key, &encryption_schedule); dump_encryption_schedule(encryption_schedule); - const auto ciphertext = aesni_encrypt_block_ecb256(plaintext, &encryption_schedule); + const auto ciphertext = aesni_aes256_encrypt_block_ecb(plaintext, &encryption_schedule); dump_ciphertext(ciphertext); aesni::KeySchedule256 decryption_schedule; - aesni_invert_key_schedule256(&encryption_schedule, &decryption_schedule); + aesni_aes256_derive_decryption_keys(&encryption_schedule, &decryption_schedule); dump_decryption_schedule(decryption_schedule); - const auto decrypted = aesni_decrypt_block_ecb256(ciphertext, &decryption_schedule); + const auto decrypted = aesni_aes256_decrypt_block_ecb(ciphertext, &decryption_schedule); dump_decrypted(decrypted); return 0; diff --git a/examples/aes256ofb.cpp b/examples/aes256ofb.cpp index 34f9725..cf1f1a0 100644 --- a/examples/aes256ofb.cpp +++ b/examples/aes256ofb.cpp @@ -29,15 +29,15 @@ int main() make_default_iv(iv); aesni::KeySchedule256 encryption_schedule; - aesni_expand_key_schedule256(&key, &encryption_schedule); + aesni_aes256_expand_key(&key, &encryption_schedule); dump_encryption_schedule(encryption_schedule); aesni::Block128 next_iv; - const auto ciphertext = aesni_encrypt_block_ofb256(plaintext, &encryption_schedule, iv, &next_iv); + const auto ciphertext = aesni_aes256_encrypt_block_ofb(plaintext, &encryption_schedule, iv, &next_iv); dump_ciphertext(ciphertext); dump_next_iv(next_iv); - const auto decrypted = aesni_decrypt_block_ofb256(ciphertext, &encryption_schedule, iv, &next_iv); + const auto decrypted = aesni_aes256_decrypt_block_ofb(ciphertext, &encryption_schedule, iv, &next_iv); dump_decrypted(decrypted); dump_next_iv(next_iv); diff --git a/include/aesni/block.h b/include/aesni/aes.h index 208e9d4..dcee06b 100644 --- a/include/aesni/block.h +++ b/include/aesni/aes.h @@ -4,47 +4,11 @@ * \date 2015 * \copyright This file is licensed under the terms of the MIT License. * See LICENSE.txt for details. - * - * \brief Declares 128-bit block encryption/decryption functions. */ #pragma once -/** - * \defgroup aesni_block_api Block API - * \brief 128-bit block encryption/decryption functions. - * \ingroup aesni - * \{ - * - * For each of AES-128/192/256, two functions are defined: - * - * * a key schedule "expansion" function to prepare for encryption, - * * a key schedule "reversion" function to prepare for decryption. - * - * The functions, respectively, are: - * - * * `aesni_expand_key_scheduleNNN`, - * * `aesni_reverse_key_scheduleNNN`, - * - * where `NNN` is either `128`, `192` or `256`. - * - * For each of AES-128/192/256 and modes of operation ECB, CBC, CFB, OFB, and - * CTR, two functions are defined: - * - * * a 128-bit block encryption function, - * * a 128-bit block decryption function. - * - * The functions, respectively, are: - * - * * `aesni_encrypt_block_XXXNNN`, - * * `aesni_decrypt_block_XXXNNN`, - * - * where `XXX` is either `ecb`, `cbc`, `cfb`, `ofb` or `ctr`, and `NNN` is - * either `128`, `192` or `256`. - */ - #include "data.h" -#include "raw.h" #include <assert.h> @@ -53,10 +17,76 @@ extern "C" { #endif -/** - * \defgroup aesni_block_api_aes128 AES-128 - * \{ - */ +typedef struct +{ + AesNI_Block128 keys[11]; +} +AesNI_Aes128_RoundKeys; + +typedef struct +{ + AesNI_Block128 keys[13]; +} +AesNI_Aes192_RoundKeys; + +typedef struct +{ + AesNI_Block128 keys[15]; +} +AesNI_Aes256_RoundKeys; + +void __fastcall aesni_aes128_expand_key_( + AesNI_Block128 key, + AesNI_Aes128_RoundKeys* encryption_keys); + +void __fastcall aesni_aes192_expand_key_( + AesNI_Block128 key_lo, + AesNI_Block128 key_hi, + AesNI_Aes192_RoundKeys* encryption_keys); + +void __fastcall aesni_aes256_expand_key_( + AesNI_Block128 key_lo, + AesNI_Block128 key_hi, + AesNI_Aes256_RoundKeys* encryption_keys); + +void __fastcall aesni_aes128_derive_decryption_keys_( + const AesNI_Aes128_RoundKeys* encryption_keys, + AesNI_Aes128_RoundKeys* decryption_keys); + +void __fastcall aesni_aes192_derive_decryption_keys_( + const AesNI_Aes192_RoundKeys* encryption_keys, + AesNI_Aes192_RoundKeys* decryption_keys); + +void __fastcall aesni_aes256_derive_decryption_keys_( + const AesNI_Aes256_RoundKeys* encryption_keys, + AesNI_Aes256_RoundKeys* decryption_keys); + +AesNI_Block128 __fastcall aesni_aes128_encrypt_block_( + AesNI_Block128 plaintext, + const AesNI_Aes128_RoundKeys*); + +AesNI_Block128 __fastcall aesni_aes192_encrypt_block_( + AesNI_Block128 plaintext, + const AesNI_Aes192_RoundKeys*); + +AesNI_Block128 __fastcall aesni_aes256_encrypt_block_( + AesNI_Block128 plaintext, + const AesNI_Aes256_RoundKeys*); + +AesNI_Block128 __fastcall aesni_aes128_decrypt_block_( + AesNI_Block128 ciphertext, + const AesNI_Aes128_RoundKeys*); + +AesNI_Block128 __fastcall aesni_aes192_decrypt_block_( + AesNI_Block128 ciphertext, + const AesNI_Aes192_RoundKeys*); + +AesNI_Block128 __fastcall aesni_aes256_decrypt_block_( + AesNI_Block128 ciphertext, + const AesNI_Aes256_RoundKeys*); + + + /** * \brief Expands a key schedule for AES-128 encryption. @@ -65,13 +95,13 @@ extern "C" * \param[out] key_schedule The AES-128 encryption key schedule. Must not be * `NULL`. */ -static __inline void __fastcall aesni_expand_key_schedule128( +static __inline void __fastcall aesni_aes128_expand_key( AesNI_Block128 key, - AesNI_KeySchedule128* key_schedule) + AesNI_Aes128_RoundKeys* key_schedule) { assert(key_schedule); - aesni_raw_expand_key_schedule128(key, key_schedule); + aesni_aes128_expand_key_(key, key_schedule); } /** @@ -82,14 +112,14 @@ static __inline void __fastcall aesni_expand_key_schedule128( * \param[out] inverted_schedule The AES-128 decryption key schedule. Must not * be `NULL`. */ -static __inline void __fastcall aesni_invert_key_schedule128( - AesNI_KeySchedule128* key_schedule, - AesNI_KeySchedule128* inverted_schedule) +static __inline void __fastcall aesni_aes128_derive_decryption_keys( + const AesNI_Aes128_RoundKeys* key_schedule, + AesNI_Aes128_RoundKeys* inverted_schedule) { assert(key_schedule); assert(inverted_schedule); - aesni_raw_invert_key_schedule128(key_schedule, inverted_schedule); + aesni_aes128_derive_decryption_keys_(key_schedule, inverted_schedule); } /** @@ -100,13 +130,13 @@ static __inline void __fastcall aesni_invert_key_schedule128( * `NULL`. * \return The encrypted 128-bit ciphertext. */ -static __inline AesNI_Block128 __fastcall aesni_encrypt_block_ecb128( +static __inline AesNI_Block128 __fastcall aesni_aes128_encrypt_block_ecb( AesNI_Block128 plain, - AesNI_KeySchedule128* key_schedule) + const AesNI_Aes128_RoundKeys* key_schedule) { assert(key_schedule); - return aesni_raw_encrypt_block128(plain, key_schedule); + return aesni_aes128_encrypt_block_(plain, key_schedule); } /** @@ -117,13 +147,13 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_ecb128( * be `NULL`. * \return The decrypted 128-bit plaintext. */ -static __inline AesNI_Block128 __fastcall aesni_decrypt_block_ecb128( +static __inline AesNI_Block128 __fastcall aesni_aes128_decrypt_block_ecb( AesNI_Block128 cipher, - AesNI_KeySchedule128* inverted_schedule) + const AesNI_Aes128_RoundKeys* inverted_schedule) { assert(inverted_schedule); - return aesni_raw_decrypt_block128(cipher, inverted_schedule); + return aesni_aes128_decrypt_block_(cipher, inverted_schedule); } /** @@ -137,16 +167,16 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_ecb128( * as the initialization vector for the next call. Must not be `NULL`. * \return The encrypted 128-bit ciphertext. */ -static __inline AesNI_Block128 __fastcall aesni_encrypt_block_cbc128( +static __inline AesNI_Block128 __fastcall aesni_aes128_encrypt_block_cbc( AesNI_Block128 plain, - AesNI_KeySchedule128* key_schedule, + const AesNI_Aes128_RoundKeys* key_schedule, AesNI_Block128 init_vector, AesNI_Block128* next_init_vector) { assert(key_schedule); assert(next_init_vector); - AesNI_Block128 cipher = aesni_raw_encrypt_block128( + AesNI_Block128 cipher = aesni_aes128_encrypt_block_( aesni_xor_block128(plain, init_vector), key_schedule); *next_init_vector = cipher; @@ -164,9 +194,9 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_cbc128( * as the initialization vector for the next call. Must not be `NULL`. * \return The decrypted 128-bit plaintext. */ -static __inline AesNI_Block128 __fastcall aesni_decrypt_block_cbc128( +static __inline AesNI_Block128 __fastcall aesni_aes128_decrypt_block_cbc( AesNI_Block128 cipher, - AesNI_KeySchedule128* inverted_schedule, + const AesNI_Aes128_RoundKeys* inverted_schedule, AesNI_Block128 init_vector, AesNI_Block128* next_init_vector) { @@ -174,7 +204,7 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_cbc128( assert(next_init_vector); AesNI_Block128 plain = aesni_xor_block128( - aesni_raw_decrypt_block128(cipher, inverted_schedule), + aesni_aes128_decrypt_block_(cipher, inverted_schedule), init_vector); *next_init_vector = cipher; return plain; @@ -191,9 +221,9 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_cbc128( * as the initialization vector for the next call. Must not be `NULL`. * \return The encrypted 128-bit ciphertext. */ -static __inline AesNI_Block128 __fastcall aesni_encrypt_block_cfb128( +static __inline AesNI_Block128 __fastcall aesni_aes128_encrypt_block_cfb( AesNI_Block128 plain, - AesNI_KeySchedule128* key_schedule, + const AesNI_Aes128_RoundKeys* key_schedule, AesNI_Block128 init_vector, AesNI_Block128* next_init_vector) { @@ -201,7 +231,7 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_cfb128( assert(next_init_vector); AesNI_Block128 cipher = aesni_xor_block128( - aesni_raw_encrypt_block128(init_vector, key_schedule), + aesni_aes128_encrypt_block_(init_vector, key_schedule), plain); *next_init_vector = cipher; return cipher; @@ -218,9 +248,9 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_cfb128( * as the initialization vector for the next call. Must not be `NULL`. * \return The decrypted 128-bit plaintext. */ -static __inline AesNI_Block128 __fastcall aesni_decrypt_block_cfb128( +static __inline AesNI_Block128 __fastcall aesni_aes128_decrypt_block_cfb( AesNI_Block128 cipher, - AesNI_KeySchedule128* key_schedule, + const AesNI_Aes128_RoundKeys* key_schedule, AesNI_Block128 init_vector, AesNI_Block128* next_init_vector) { @@ -228,7 +258,7 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_cfb128( assert(next_init_vector); AesNI_Block128 plain = aesni_xor_block128( - aesni_raw_encrypt_block128(init_vector, key_schedule), + aesni_aes128_encrypt_block_(init_vector, key_schedule), cipher); *next_init_vector = cipher; return plain; @@ -245,16 +275,16 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_cfb128( * as the initialization vector for the next call. Must not be `NULL`. * \return The encrypted 128-bit ciphertext. */ -static __inline AesNI_Block128 __fastcall aesni_encrypt_block_ofb128( +static __inline AesNI_Block128 __fastcall aesni_aes128_encrypt_block_ofb( AesNI_Block128 plain, - AesNI_KeySchedule128* key_schedule, + const AesNI_Aes128_RoundKeys* key_schedule, AesNI_Block128 init_vector, AesNI_Block128* next_init_vector) { assert(key_schedule); assert(next_init_vector); - AesNI_Block128 tmp = aesni_raw_encrypt_block128(init_vector, key_schedule); + AesNI_Block128 tmp = aesni_aes128_encrypt_block_(init_vector, key_schedule); *next_init_vector = tmp; return aesni_xor_block128(tmp, plain); } @@ -270,16 +300,16 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_ofb128( * as the initialization vector for the next call. Must not be `NULL`. * \return The decrypted 128-bit plaintext. */ -static __inline AesNI_Block128 __fastcall aesni_decrypt_block_ofb128( +static __inline AesNI_Block128 __fastcall aesni_aes128_decrypt_block_ofb( AesNI_Block128 cipher, - AesNI_KeySchedule128* key_schedule, + const AesNI_Aes128_RoundKeys* key_schedule, AesNI_Block128 init_vector, AesNI_Block128* next_init_vector) { assert(key_schedule); assert(next_init_vector); - AesNI_Block128 tmp = aesni_raw_encrypt_block128(init_vector, key_schedule); + AesNI_Block128 tmp = aesni_aes128_encrypt_block_(init_vector, key_schedule); *next_init_vector = tmp; return aesni_xor_block128(tmp, cipher); } @@ -295,9 +325,9 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_ofb128( * calls. * \return The encrypted 128-bit ciphertext. */ -static __inline AesNI_Block128 __fastcall aesni_encrypt_block_ctr128( +static __inline AesNI_Block128 __fastcall aesni_aes128_encrypt_block_ctr( AesNI_Block128 plain, - AesNI_KeySchedule128* key_schedule, + const AesNI_Aes128_RoundKeys* key_schedule, AesNI_Block128 init_vector, int counter) { @@ -309,7 +339,7 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_ctr128( return aesni_xor_block128( plain, - aesni_raw_encrypt_block128(init_vector, key_schedule)); + aesni_aes128_encrypt_block_(init_vector, key_schedule)); } /** @@ -323,9 +353,9 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_ctr128( * calls. * \return The decrypted 128-bit plaintext. */ -static __inline AesNI_Block128 __fastcall aesni_decrypt_block_ctr128( +static __inline AesNI_Block128 __fastcall aesni_aes128_decrypt_block_ctr( AesNI_Block128 cipher, - AesNI_KeySchedule128* key_schedule, + const AesNI_Aes128_RoundKeys* key_schedule, AesNI_Block128 init_vector, int counter) { @@ -337,7 +367,7 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_ctr128( return aesni_xor_block128( cipher, - aesni_raw_encrypt_block128(init_vector, key_schedule)); + aesni_aes128_encrypt_block_(init_vector, key_schedule)); } /** @@ -354,14 +384,14 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_ctr128( * \param[out] key_schedule The AES-192 encryption key schedule. Must not be * `NULL`. */ -static __inline void __fastcall aesni_expand_key_schedule192( +static __inline void __fastcall aesni_aes192_expand_key( AesNI_Block192* key, - AesNI_KeySchedule192* key_schedule) + AesNI_Aes192_RoundKeys* key_schedule) { assert(key); assert(key_schedule); - aesni_raw_expand_key_schedule192(key->lo, key->hi, key_schedule); + aesni_aes192_expand_key_(key->lo, key->hi, key_schedule); } /** @@ -372,14 +402,14 @@ static __inline void __fastcall aesni_expand_key_schedule192( * \param[out] inverted_schedule The AES-192 decryption key schedule. Must not * be `NULL`. */ -static __inline void __fastcall aesni_invert_key_schedule192( - AesNI_KeySchedule192* key_schedule, - AesNI_KeySchedule192* inverted_schedule) +static __inline void __fastcall aesni_aes192_derive_decryption_keys( + const AesNI_Aes192_RoundKeys* key_schedule, + AesNI_Aes192_RoundKeys* inverted_schedule) { assert(key_schedule); assert(inverted_schedule); - aesni_raw_invert_key_schedule192(key_schedule, inverted_schedule); + aesni_aes192_derive_decryption_keys_(key_schedule, inverted_schedule); } /** @@ -390,13 +420,13 @@ static __inline void __fastcall aesni_invert_key_schedule192( * `NULL`. * \return The encrypted 128-bit ciphertext. */ -static __inline AesNI_Block128 __fastcall aesni_encrypt_block_ecb192( +static __inline AesNI_Block128 __fastcall aesni_aes192_encrypt_block_ecb( AesNI_Block128 plain, - AesNI_KeySchedule192* key_schedule) + const AesNI_Aes192_RoundKeys* key_schedule) { assert(key_schedule); - return aesni_raw_encrypt_block192(plain, key_schedule); + return aesni_aes192_encrypt_block_(plain, key_schedule); } /** @@ -407,13 +437,13 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_ecb192( * be `NULL`. * \return The decrypted 128-bit plaintext. */ -static __inline AesNI_Block128 __fastcall aesni_decrypt_block_ecb192( +static __inline AesNI_Block128 __fastcall aesni_aes192_decrypt_block_ecb( AesNI_Block128 cipher, - AesNI_KeySchedule192* inverted_schedule) + const AesNI_Aes192_RoundKeys* inverted_schedule) { assert(inverted_schedule); - return aesni_raw_decrypt_block192(cipher, inverted_schedule); + return aesni_aes192_decrypt_block_(cipher, inverted_schedule); } /** @@ -427,16 +457,16 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_ecb192( * as the initialization vector for the next call. Must not be `NULL`. * \return The encrypted 128-bit ciphertext. */ -static __inline AesNI_Block128 __fastcall aesni_encrypt_block_cbc192( +static __inline AesNI_Block128 __fastcall aesni_aes192_encrypt_block_cbc( AesNI_Block128 plain, - AesNI_KeySchedule192* key_schedule, + const AesNI_Aes192_RoundKeys* key_schedule, AesNI_Block128 init_vector, AesNI_Block128* next_init_vector) { assert(key_schedule); assert(next_init_vector); - AesNI_Block128 cipher = aesni_raw_encrypt_block192( + AesNI_Block128 cipher = aesni_aes192_encrypt_block_( aesni_xor_block128(plain, init_vector), key_schedule); *next_init_vector = cipher; @@ -454,9 +484,9 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_cbc192( * as the initialization vector for the next call. Must not be `NULL`. * \return The decrypted 128-bit plaintext. */ -static __inline AesNI_Block128 __fastcall aesni_decrypt_block_cbc192( +static __inline AesNI_Block128 __fastcall aesni_aes192_decrypt_block_cbc( AesNI_Block128 cipher, - AesNI_KeySchedule192* inverted_schedule, + const AesNI_Aes192_RoundKeys* inverted_schedule, AesNI_Block128 init_vector, AesNI_Block128* next_init_vector) { @@ -464,7 +494,7 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_cbc192( assert(next_init_vector); AesNI_Block128 plain = aesni_xor_block128( - aesni_raw_decrypt_block192(cipher, inverted_schedule), + aesni_aes192_decrypt_block_(cipher, inverted_schedule), init_vector); *next_init_vector = cipher; return plain; @@ -481,9 +511,9 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_cbc192( * as the initialization vector for the next call. Must not be `NULL`. * \return The encrypted 128-bit ciphertext. */ -static __inline AesNI_Block128 __fastcall aesni_encrypt_block_cfb192( +static __inline AesNI_Block128 __fastcall aesni_aes192_encrypt_block_cfb( AesNI_Block128 plain, - AesNI_KeySchedule192* key_schedule, + const AesNI_Aes192_RoundKeys* key_schedule, AesNI_Block128 init_vector, AesNI_Block128* next_init_vector) { @@ -491,7 +521,7 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_cfb192( assert(next_init_vector); AesNI_Block128 cipher = aesni_xor_block128( - aesni_raw_encrypt_block192(init_vector, key_schedule), + aesni_aes192_encrypt_block_(init_vector, key_schedule), plain); *next_init_vector = cipher; return cipher; @@ -508,9 +538,9 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_cfb192( * as the initialization vector for the next call. Must not be `NULL`. * \return The decrypted 128-bit plaintext. */ -static __inline AesNI_Block128 __fastcall aesni_decrypt_block_cfb192( +static __inline AesNI_Block128 __fastcall aesni_aes192_decrypt_block_cfb( AesNI_Block128 cipher, - AesNI_KeySchedule192* key_schedule, + const AesNI_Aes192_RoundKeys* key_schedule, AesNI_Block128 init_vector, AesNI_Block128* next_init_vector) { @@ -518,7 +548,7 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_cfb192( assert(next_init_vector); AesNI_Block128 plain = aesni_xor_block128( - aesni_raw_encrypt_block192(init_vector, key_schedule), + aesni_aes192_encrypt_block_(init_vector, key_schedule), cipher); *next_init_vector = cipher; return plain; @@ -535,16 +565,16 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_cfb192( * as the initialization vector for the next call. Must not be `NULL`. * \return The encrypted 128-bit ciphertext. */ -static __inline AesNI_Block128 __fastcall aesni_encrypt_block_ofb192( +static __inline AesNI_Block128 __fastcall aesni_aes192_encrypt_block_ofb( AesNI_Block128 plain, - AesNI_KeySchedule192* key_schedule, + const AesNI_Aes192_RoundKeys* key_schedule, AesNI_Block128 init_vector, AesNI_Block128* next_init_vector) { assert(key_schedule); assert(next_init_vector); - AesNI_Block128 tmp = aesni_raw_encrypt_block192(init_vector, key_schedule); + AesNI_Block128 tmp = aesni_aes192_encrypt_block_(init_vector, key_schedule); *next_init_vector = tmp; return aesni_xor_block128(tmp, plain); } @@ -560,16 +590,16 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_ofb192( * as the initialization vector for the next call. Must not be `NULL`. * \return The decrypted 128-bit plaintext. */ -static __inline AesNI_Block128 __fastcall aesni_decrypt_block_ofb192( +static __inline AesNI_Block128 __fastcall aesni_aes192_decrypt_block_ofb( AesNI_Block128 cipher, - AesNI_KeySchedule192* key_schedule, + const AesNI_Aes192_RoundKeys* key_schedule, AesNI_Block128 init_vector, AesNI_Block128* next_init_vector) { assert(key_schedule); assert(next_init_vector); - AesNI_Block128 tmp = aesni_raw_encrypt_block192(init_vector, key_schedule); + AesNI_Block128 tmp = aesni_aes192_encrypt_block_(init_vector, key_schedule); *next_init_vector = tmp; return aesni_xor_block128(tmp, cipher); } @@ -585,9 +615,9 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_ofb192( * calls. * \return The encrypted 128-bit ciphertext. */ -static __inline AesNI_Block128 __fastcall aesni_encrypt_block_ctr192( +static __inline AesNI_Block128 __fastcall aesni_aes192_encrypt_block_ctr( AesNI_Block128 plain, - AesNI_KeySchedule192* key_schedule, + const AesNI_Aes192_RoundKeys* key_schedule, AesNI_Block128 init_vector, int counter) { @@ -599,7 +629,7 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_ctr192( return aesni_xor_block128( plain, - aesni_raw_encrypt_block192(init_vector, key_schedule)); + aesni_aes192_encrypt_block_(init_vector, key_schedule)); } /** @@ -613,9 +643,9 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_ctr192( * calls. * \return The decrypted 128-bit plaintext. */ -static __inline AesNI_Block128 __fastcall aesni_decrypt_block_ctr192( +static __inline AesNI_Block128 __fastcall aesni_aes192_decrypt_block_ctr( AesNI_Block128 cipher, - AesNI_KeySchedule192* key_schedule, + const AesNI_Aes192_RoundKeys* key_schedule, AesNI_Block128 init_vector, int counter) { @@ -627,7 +657,7 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_ctr192( return aesni_xor_block128( cipher, - aesni_raw_encrypt_block192(init_vector, key_schedule)); + aesni_aes192_encrypt_block_(init_vector, key_schedule)); } /** @@ -644,14 +674,14 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_ctr192( * \param[out] key_schedule The AES-256 encryption key schedule. Must not be * `NULL`. */ -static __inline void __fastcall aesni_expand_key_schedule256( - AesNI_Block256* key, - AesNI_KeySchedule256* key_schedule) +static __inline void __fastcall aesni_aes256_expand_key( + const AesNI_Block256* key, + AesNI_Aes256_RoundKeys* key_schedule) { assert(key); assert(key_schedule); - aesni_raw_expand_key_schedule256(key->lo, key->hi, key_schedule); + aesni_aes256_expand_key_(key->lo, key->hi, key_schedule); } /** @@ -662,14 +692,14 @@ static __inline void __fastcall aesni_expand_key_schedule256( * \param[out] inverted_schedule The AES-256 decryption key schedule. Must not * be `NULL`. */ -static __inline void __fastcall aesni_invert_key_schedule256( - AesNI_KeySchedule256* key_schedule, - AesNI_KeySchedule256* inverted_schedule) +static __inline void __fastcall aesni_aes256_derive_decryption_keys( + const AesNI_Aes256_RoundKeys* key_schedule, + AesNI_Aes256_RoundKeys* inverted_schedule) { assert(key_schedule); assert(inverted_schedule); - aesni_raw_invert_key_schedule256(key_schedule, inverted_schedule); + aesni_aes256_derive_decryption_keys_(key_schedule, inverted_schedule); } /** @@ -680,13 +710,13 @@ static __inline void __fastcall aesni_invert_key_schedule256( * `NULL`. * \return The encrypted 128-bit ciphertext. */ -static __inline AesNI_Block128 __fastcall aesni_encrypt_block_ecb256( +static __inline AesNI_Block128 __fastcall aesni_aes256_encrypt_block_ecb( AesNI_Block128 plain, - AesNI_KeySchedule256* key_schedule) + const AesNI_Aes256_RoundKeys* key_schedule) { assert(key_schedule); - return aesni_raw_encrypt_block256(plain, key_schedule); + return aesni_aes256_encrypt_block_(plain, key_schedule); } /** @@ -697,13 +727,13 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_ecb256( * be `NULL`. * \return The decrypted 128-bit plaintext. */ -static __inline AesNI_Block128 __fastcall aesni_decrypt_block_ecb256( +static __inline AesNI_Block128 __fastcall aesni_aes256_decrypt_block_ecb( AesNI_Block128 cipher, - AesNI_KeySchedule256* inverted_schedule) + const AesNI_Aes256_RoundKeys* inverted_schedule) { assert(inverted_schedule); - return aesni_raw_decrypt_block256(cipher, inverted_schedule); + return aesni_aes256_decrypt_block_(cipher, inverted_schedule); } /** @@ -717,16 +747,16 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_ecb256( * as the initialization vector for the next call. Must not be `NULL`. * \return The encrypted 128-bit ciphertext. */ -static __inline AesNI_Block128 __fastcall aesni_encrypt_block_cbc256( +static __inline AesNI_Block128 __fastcall aesni_aes256_encrypt_block_cbc( AesNI_Block128 plain, - AesNI_KeySchedule256* key_schedule, + const AesNI_Aes256_RoundKeys* key_schedule, AesNI_Block128 init_vector, AesNI_Block128* next_init_vector) { assert(key_schedule); assert(next_init_vector); - AesNI_Block128 cipher = aesni_raw_encrypt_block256( + AesNI_Block128 cipher = aesni_aes256_encrypt_block_( aesni_xor_block128(plain, init_vector), key_schedule); *next_init_vector = cipher; @@ -744,9 +774,9 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_cbc256( * as the initialization vector for the next call. Must not be `NULL`. * \return The decrypted 128-bit plaintext. */ -static __inline AesNI_Block128 __fastcall aesni_decrypt_block_cbc256( +static __inline AesNI_Block128 __fastcall aesni_aes256_decrypt_block_cbc( AesNI_Block128 cipher, - AesNI_KeySchedule256* inverted_schedule, + const AesNI_Aes256_RoundKeys* inverted_schedule, AesNI_Block128 init_vector, AesNI_Block128* next_init_vector) { @@ -754,7 +784,7 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_cbc256( assert(next_init_vector); AesNI_Block128 plain = aesni_xor_block128( - aesni_raw_decrypt_block256(cipher, inverted_schedule), + aesni_aes256_decrypt_block_(cipher, inverted_schedule), init_vector); *next_init_vector = cipher; return plain; @@ -771,9 +801,9 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_cbc256( * as the initialization vector for the next call. Must not be `NULL`. * \return The encrypted 128-bit ciphertext. */ -static __inline AesNI_Block128 __fastcall aesni_encrypt_block_cfb256( +static __inline AesNI_Block128 __fastcall aesni_aes256_encrypt_block_cfb( AesNI_Block128 plain, - AesNI_KeySchedule256* key_schedule, + const AesNI_Aes256_RoundKeys* key_schedule, AesNI_Block128 init_vector, AesNI_Block128* next_init_vector) { @@ -781,7 +811,7 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_cfb256( assert(next_init_vector); AesNI_Block128 cipher = aesni_xor_block128( - aesni_raw_encrypt_block256(init_vector, key_schedule), + aesni_aes256_encrypt_block_(init_vector, key_schedule), plain); *next_init_vector = cipher; return cipher; @@ -798,9 +828,9 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_cfb256( * as the initialization vector for the next call. Must not be `NULL`. * \return The decrypted 128-bit plaintext. */ -static __inline AesNI_Block128 __fastcall aesni_decrypt_block_cfb256( +static __inline AesNI_Block128 __fastcall aesni_aes256_decrypt_block_cfb( AesNI_Block128 cipher, - AesNI_KeySchedule256* key_schedule, + const AesNI_Aes256_RoundKeys* key_schedule, AesNI_Block128 init_vector, AesNI_Block128* next_init_vector) { @@ -808,7 +838,7 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_cfb256( assert(next_init_vector); AesNI_Block128 plain = aesni_xor_block128( - aesni_raw_encrypt_block256(init_vector, key_schedule), + aesni_aes256_encrypt_block_(init_vector, key_schedule), cipher); *next_init_vector = cipher; return plain; @@ -825,16 +855,16 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_cfb256( * as the initialization vector for the next call. Must not be `NULL`. * \return The encrypted 128-bit ciphertext. */ -static __inline AesNI_Block128 __fastcall aesni_encrypt_block_ofb256( +static __inline AesNI_Block128 __fastcall aesni_aes256_encrypt_block_ofb( AesNI_Block128 plain, - AesNI_KeySchedule256* key_schedule, + const AesNI_Aes256_RoundKeys* key_schedule, AesNI_Block128 init_vector, AesNI_Block128* next_init_vector) { assert(key_schedule); assert(next_init_vector); - AesNI_Block128 tmp = aesni_raw_encrypt_block256(init_vector, key_schedule); + AesNI_Block128 tmp = aesni_aes256_encrypt_block_(init_vector, key_schedule); *next_init_vector = tmp; return aesni_xor_block128(tmp, plain); } @@ -850,16 +880,16 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_ofb256( * as the initialization vector for the next call. Must not be `NULL`. * \return The decrypted 128-bit plaintext. */ -static __inline AesNI_Block128 __fastcall aesni_decrypt_block_ofb256( +static __inline AesNI_Block128 __fastcall aesni_aes256_decrypt_block_ofb( AesNI_Block128 cipher, - AesNI_KeySchedule256* key_schedule, + const AesNI_Aes256_RoundKeys* key_schedule, AesNI_Block128 init_vector, AesNI_Block128* next_init_vector) { assert(key_schedule); assert(next_init_vector); - AesNI_Block128 tmp = aesni_raw_encrypt_block256(init_vector, key_schedule); + AesNI_Block128 tmp = aesni_aes256_encrypt_block_(init_vector, key_schedule); *next_init_vector = tmp; return aesni_xor_block128(tmp, cipher); } @@ -875,9 +905,9 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_ofb256( * calls. * \return The encrypted 128-bit ciphertext. */ -static __inline AesNI_Block128 __fastcall aesni_encrypt_block_ctr256( +static __inline AesNI_Block128 __fastcall aesni_aes256_encrypt_block_ctr( AesNI_Block128 plain, - AesNI_KeySchedule256* key_schedule, + const AesNI_Aes256_RoundKeys* key_schedule, AesNI_Block128 init_vector, int counter) { @@ -889,7 +919,7 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_ctr256( return aesni_xor_block128( plain, - aesni_raw_encrypt_block256(init_vector, key_schedule)); + aesni_aes256_encrypt_block_(init_vector, key_schedule)); } /** @@ -903,9 +933,9 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_ctr256( * calls. * \return The decrypted 128-bit plaintext. */ -static __inline AesNI_Block128 __fastcall aesni_decrypt_block_ctr256( +static __inline AesNI_Block128 __fastcall aesni_aes256_decrypt_block_ctr( AesNI_Block128 cipher, - AesNI_KeySchedule256* key_schedule, + const AesNI_Aes256_RoundKeys* key_schedule, AesNI_Block128 init_vector, int counter) { @@ -917,17 +947,9 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_ctr256( return aesni_xor_block128( cipher, - aesni_raw_encrypt_block256(init_vector, key_schedule)); + aesni_aes256_encrypt_block_(init_vector, key_schedule)); } -/** - * \} - */ - #ifdef __cplusplus } #endif - -/** - * \} - */ diff --git a/include/aesni/all.h b/include/aesni/all.h index 70f5e7e..26f7a41 100644 --- a/include/aesni/all.h +++ b/include/aesni/all.h @@ -15,11 +15,10 @@ * \defgroup aesni AesNI */ +#include "aes.h" #include "algorithm.h" -#include "block.h" #include "box.h" #include "buffer.h" #include "data.h" #include "error.h" #include "mode.h" -#include "raw.h" diff --git a/include/aesni/box.h b/include/aesni/box.h index 2ae6533..70b2787 100644 --- a/include/aesni/box.h +++ b/include/aesni/box.h @@ -20,17 +20,17 @@ extern "C" typedef union { - AesNI_KeySchedule128 aes128_key_schedule; - AesNI_KeySchedule192 aes192_key_schedule; - AesNI_KeySchedule256 aes256_key_schedule; + AesNI_Aes128_RoundKeys aes128_key_schedule; + AesNI_Aes192_RoundKeys aes192_key_schedule; + AesNI_Aes256_RoundKeys aes256_key_schedule; } AesNI_EncryptionParams; typedef union { - AesNI_KeySchedule128 aes128_key_schedule; - AesNI_KeySchedule192 aes192_key_schedule; - AesNI_KeySchedule256 aes256_key_schedule; + AesNI_Aes128_RoundKeys aes128_key_schedule; + AesNI_Aes192_RoundKeys aes192_key_schedule; + AesNI_Aes256_RoundKeys aes256_key_schedule; } AesNI_DecryptionParams; diff --git a/include/aesni/buffer.h b/include/aesni/buffer.h index 2e5ecb9..d153c1b 100644 --- a/include/aesni/buffer.h +++ b/include/aesni/buffer.h @@ -24,14 +24,14 @@ AesNI_StatusCode aesni_encrypt_buffer_ecb128( size_t src_size, void* dest, size_t* dest_size, - AesNI_KeySchedule128* key_schedule, + AesNI_Aes128_RoundKeys* key_schedule, AesNI_ErrorDetails* err_details); AesNI_StatusCode aesni_decrypt_buffer_ecb128( const void* src, size_t src_size, void* dest, size_t* dest_size, - AesNI_KeySchedule128* inverted_schedule, + AesNI_Aes128_RoundKeys* inverted_schedule, AesNI_ErrorDetails* err_details); #ifdef __cplusplus diff --git a/include/aesni/data.h b/include/aesni/data.h index fbe6e31..a6dc71f 100644 --- a/include/aesni/data.h +++ b/include/aesni/data.h @@ -204,24 +204,6 @@ static __inline AesNI_Block256 __fastcall aesni_make_block256( return result; } -typedef struct -{ - AesNI_Block128 keys[11]; -} -AesNI_KeySchedule128; - -typedef struct -{ - AesNI_Block128 keys[13]; -} -AesNI_KeySchedule192; - -typedef struct -{ - AesNI_Block128 keys[15]; -} -AesNI_KeySchedule256; - static __inline AesNI_Block128 __fastcall aesni_reverse_byte_order128(AesNI_Block128 block) { return _mm_shuffle_epi8(block, aesni_make_block128(0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f)); diff --git a/include/aesni/raw.h b/include/aesni/raw.h deleted file mode 100644 index 03a89e4..0000000 --- a/include/aesni/raw.h +++ /dev/null @@ -1,218 +0,0 @@ -/** - * \file - * \author Egor Tensin <Egor.Tensin@gmail.com> - * \date 2015 - * \copyright This file is licensed under the terms of the MIT License. - * See LICENSE.txt for details. - * - * \brief *Don't use.* Declares "raw" 128-bit block encryption/decryption - * functions. - */ - -#pragma once - -/** - * \defgroup aesni_raw_api Raw API - * \brief *Don't use.* "Raw" 128-bit block encryption/decryption functions. - * \ingroup aesni - * \{ - * - * For each of AES-128/192/256, four functions are defined: - * - * * a key schedule "expansion" function to prepare for encryption, - * * a 128-bit block encryption function using the key schedule, - * * a key schedule "inversion" function to prepare for decryption, - * * a 128-bit block decryption function using the "inverted" key schedule. - * - * The functions, respectively, are: - * - * * `aesni_raw_expand_key_scheduleNNN`, - * * `aesni_raw_encrypt_blockNNN`, - * * `aesni_raw_invert_key_scheduleNNN`, - * * `aesni_raw_decrypt_blockNNN`, - * - * where `NNN` is key length (either `128`, `192` or `256`). - */ - -#include "data.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/** - * \defgroup aesni_raw_api_aes128 AES-128 - * \{ - */ - -/** - * \brief Expands a key schedule for AES-128 encryption. - * - * \param[in] key The AES-128 key. - * \param[out] key_schedule The AES-128 encryption key schedule. Must not be - * `NULL`. - */ -void __fastcall aesni_raw_expand_key_schedule128( - AesNI_Block128 key, - AesNI_KeySchedule128* key_schedule); - -/** - * \brief "Inverts" an AES-128 key schedule to prepare for decryption. - * - * \param[in] key_schedule The AES-128 encryption key schedule. Must not be - * `NULL`. - * \param[out] inverted_schedule The AES-128 decryption key schedule. Must not - * be `NULL`. - */ -void __fastcall aesni_raw_invert_key_schedule128( - const AesNI_KeySchedule128* key_schedule, - AesNI_KeySchedule128* inverted_schedule); - -/** - * \brief Encrypts a 128-bit block using AES-128. - * - * \param[in] plain The plaintext to be encrypted. - * \param[in] key_schedule The AES-128 encryption key schedule. Must not be - * `NULL`. - * \return The encrypted 128-bit ciphertext. - */ -AesNI_Block128 __fastcall aesni_raw_encrypt_block128( - AesNI_Block128 plain, - const AesNI_KeySchedule128* key_schedule); - -/** - * \brief Decrypts a 128-bit block using AES-128. - * - * \param[in] cipher The ciphertext to be decrypted. - * \param[in] inverted_schedule The AES-128 decryption key schedule. Must not - * be `NULL`. - * \return The decrypted 128-bit plaintext. - */ -AesNI_Block128 __fastcall aesni_raw_decrypt_block128( - AesNI_Block128 cipher, - const AesNI_KeySchedule128* inverted_schedule); - -/** - * \} - * - * \defgroup aesni_raw_api_aes192 AES-192 - * \{ - */ - -/** - * \brief Expands a key schedule for AES-192 encryption. - * - * \param[in] key_lo The least significant part of the AES-192 key. - * \param[in] key_hi The most significant part of the AES-192 key. - * \param[out] key_schedule The AES-192 encryption key schedule. Must not be - * `NULL`. - */ -void __fastcall aesni_raw_expand_key_schedule192( - AesNI_Block128 key_lo, - AesNI_Block128 key_hi, - AesNI_KeySchedule192* key_schedule); - -/** - * \brief "Inverts" an AES-192 key schedule to prepare for decryption. - * - * \param[in] key_schedule The AES-192 encryption key schedule. Must not be - * `NULL`. - * \param[out] inverted_schedule The AES-192 decryption key schedule. Must not - * be `NULL`. - */ -void __fastcall aesni_raw_invert_key_schedule192( - const AesNI_KeySchedule192* key_schedule, - AesNI_KeySchedule192* inverted_schedule); - -/** - * \brief Encrypts a 128-bit block using AES-192. - * - * \param[in] plain The plaintext to be encrypted. - * \param[in] key_schedule The AES-192 encryption key schedule. Must not be - * `NULL`. - * \return The encrypted 128-bit ciphertext. - */ -AesNI_Block128 __fastcall aesni_raw_encrypt_block192( - AesNI_Block128 plain, - const AesNI_KeySchedule192* key_schedule); - -/** - * \brief Decrypts a 128-bit block using AES-192. - * - * \param[in] cipher The ciphertext to be decrypted. - * \param[in] inverted_schedule The AES-192 decryption key schedule. Must not - * be `NULL`. - * \return The decrypted 128-bit plaintext. - */ -AesNI_Block128 __fastcall aesni_raw_decrypt_block192( - AesNI_Block128 cipher, - const AesNI_KeySchedule192* inverted_schedule); - -/** - * \} - * - * \defgroup aesni_raw_api_aes256 AES-256 - * \{ - */ - -/** - * \brief Expands a key schedule for AES-256 encryption. - * - * \param[in] key_lo The least significant part of the AES-256 key. - * \param[in] key_hi The most significant part of the AES-256 key. - * \param[out] key_schedule The AES-256 encryption key schedule. Must not be - * `NULL`. - */ -void __fastcall aesni_raw_expand_key_schedule256( - AesNI_Block128 key_lo, - AesNI_Block128 key_hi, - AesNI_KeySchedule256* key_schedule); - -/** - * \brief "Inverts" a AES-256 key schedule to prepare for decryption. - * - * \param[in] key_schedule The AES-256 encryption key schedule. Must not be - * `NULL`. - * \param[out] inverted_schedule The AES-256 decryption key schedule. Must not - * be `NULL`. - */ -void __fastcall aesni_raw_invert_key_schedule256( - const AesNI_KeySchedule256* key_schedule, - AesNI_KeySchedule256* inverted_schedule); - -/** - * \brief Encrypts a 128-bit block using AES-256. - * - * \param[in] plain The plaintext to be encrypted. - * \param[in] key_schedule The AES-256 encryption key schedule. Must not be - * `NULL`. - * \return The encrypted 128-bit ciphertext. - */ -AesNI_Block128 __fastcall aesni_raw_encrypt_block256( - AesNI_Block128 plain, - const AesNI_KeySchedule256* key_schedule); - -/** - * \brief Decrypts a 128-bit block using AES-256. - * - * \param[in] cipher The ciphertext to be decrypted. - * \param[in] inverted_schedule The AES-256 decryption key schedule. Must not - * be `NULL`. - * \return The decrypted 128-bit plaintext. - */ -AesNI_Block128 __fastcall aesni_raw_decrypt_block256( - AesNI_Block128 cipher, - const AesNI_KeySchedule256* inverted_schedule); - -/** - * \} - */ - -#ifdef __cplusplus -} -#endif - -/** - * \} - */ diff --git a/src/asm/aes128.asm b/src/asm/aes128.asm index 4f88f09..03a9ace 100644 --- a/src/asm/aes128.asm +++ b/src/asm/aes128.asm @@ -8,7 +8,7 @@ .code -@aesni_raw_encrypt_block128@20 proc +@aesni_aes128_encrypt_block_@20 proc pxor xmm0, [ecx] aesenc xmm0, [ecx + 10h] aesenc xmm0, [ecx + 20h] @@ -21,9 +21,9 @@ aesenc xmm0, [ecx + 90h] aesenclast xmm0, [ecx + 0A0h] ret -@aesni_raw_encrypt_block128@20 endp +@aesni_aes128_encrypt_block_@20 endp -@aesni_raw_decrypt_block128@20 proc +@aesni_aes128_decrypt_block_@20 proc pxor xmm0, [ecx] aesdec xmm0, [ecx + 10h] aesdec xmm0, [ecx + 20h] @@ -36,9 +36,9 @@ aesdec xmm0, [ecx + 90h] aesdeclast xmm0, [ecx + 0A0h] ret -@aesni_raw_decrypt_block128@20 endp +@aesni_aes128_decrypt_block_@20 endp -@aesni_raw_expand_key_schedule128@20 proc +@aesni_aes128_expand_key_@20 proc ; A "word" (in terms of the FIPS 187 standard) is a 32-bit block. ; Words are denoted by `w[N]`. ; @@ -165,9 +165,9 @@ aes128_keygen_assist: add ecx, 10h ; ecx = &w[i+8] ret -@aesni_raw_expand_key_schedule128@20 endp +@aesni_aes128_expand_key_@20 endp -@aesni_raw_invert_key_schedule128@8 proc +@aesni_aes128_derive_decryption_keys_raw@8 proc movdqa xmm5, [ecx] movdqa xmm4, [ecx + 0A0h] movdqa [edx], xmm4 @@ -197,6 +197,6 @@ aes128_keygen_assist: movdqa [edx + 50h], xmm5 ret -@aesni_raw_invert_key_schedule128@8 endp +@aesni_aes128_derive_decryption_keys_raw@8 endp end diff --git a/src/asm/aes192.asm b/src/asm/aes192.asm index e045910..cd28143 100644 --- a/src/asm/aes192.asm +++ b/src/asm/aes192.asm @@ -8,7 +8,7 @@ .code -@aesni_raw_encrypt_block192@20 proc +@aesni_aes192_encrypt_block_@20 proc pxor xmm0, [ecx] aesenc xmm0, [ecx + 10h] aesenc xmm0, [ecx + 20h] @@ -23,9 +23,9 @@ aesenc xmm0, [ecx + 0B0h] aesenclast xmm0, [ecx + 0C0h] ret -@aesni_raw_encrypt_block192@20 endp +@aesni_aes192_encrypt_block_@20 endp -@aesni_raw_decrypt_block192@20 proc +@aesni_aes192_decrypt_block_@20 proc pxor xmm0, [ecx] aesdec xmm0, [ecx + 10h] aesdec xmm0, [ecx + 20h] @@ -40,9 +40,9 @@ aesdec xmm0, [ecx + 0B0h] aesdeclast xmm0, [ecx + 0C0h] ret -@aesni_raw_decrypt_block192@20 endp +@aesni_aes192_decrypt_block_@20 endp -@aesni_raw_expand_key_schedule192@36 proc +@aesni_aes192_expand_key_@36 proc ; A "word" (in terms of the FIPS 187 standard) is a 32-bit block. ; Words are denoted by `w[N]`. ; @@ -206,9 +206,9 @@ aes192_keygen_assist: ; xmm1[31:0] == w[i+10] == RotWord(SubWord(w[i+5]))^Rcon^w[i+4]^w[i+3]^w[i+2]^w[i+1]^w[i] ret -@aesni_raw_expand_key_schedule192@36 endp +@aesni_aes192_expand_key_@36 endp -@aesni_raw_invert_key_schedule192@8 proc +@aesni_aes192_derive_decryption_keys_@8 proc movdqa xmm5, [ecx] movdqa xmm4, [ecx + 0C0h] movdqa [edx], xmm4 @@ -243,6 +243,6 @@ aes192_keygen_assist: movdqa [edx + 60h], xmm5 ret -@aesni_raw_invert_key_schedule192@8 endp +@aesni_aes192_derive_decryption_keys_@8 endp end diff --git a/src/asm/aes256.asm b/src/asm/aes256.asm index 285cf69..f1c3eaf 100644 --- a/src/asm/aes256.asm +++ b/src/asm/aes256.asm @@ -8,7 +8,7 @@ .code -@aesni_raw_encrypt_block256@20 proc +@aesni_aes256_encrypt_block_@20 proc pxor xmm0, [ecx] aesenc xmm0, [ecx + 10h] aesenc xmm0, [ecx + 20h] @@ -25,9 +25,9 @@ aesenc xmm0, [ecx + 0D0h] aesenclast xmm0, [ecx + 0E0h] ret -@aesni_raw_encrypt_block256@20 endp +@aesni_aes256_encrypt_block_@20 endp -@aesni_raw_decrypt_block256@20 proc +@aesni_aes256_decrypt_block_@20 proc pxor xmm0, [ecx] aesdec xmm0, [ecx + 10h] aesdec xmm0, [ecx + 20h] @@ -44,9 +44,9 @@ aesdec xmm0, [ecx + 0D0h] aesdeclast xmm0, [ecx + 0E0h] ret -@aesni_raw_decrypt_block256@20 endp +@aesni_aes256_decrypt_block_@20 endp -@aesni_raw_expand_key_schedule256@36 proc +@aesni_aes256_expand_key_@36 proc ; A "word" (in terms of the FIPS 187 standard) is a 32-bit block. ; Words are denoted by `w[N]`. ; @@ -239,9 +239,9 @@ aes256_keygen_assist: pxor xmm0, xmm1 ret -@aesni_raw_expand_key_schedule256@36 endp +@aesni_aes256_expand_key_@36 endp -@aesni_raw_invert_key_schedule256@8 proc +@aesni_aes256_derive_decryption_keys_raw@8 proc movdqa xmm5, [ecx] movdqa xmm4, [ecx + 0E0h] movdqa [edx], xmm4 @@ -281,6 +281,6 @@ aes256_keygen_assist: movdqa [edx + 70h], xmm5 ret -@aesni_raw_invert_key_schedule256@8 endp +@aesni_aes256_derive_decryption_keys_raw@8 endp end @@ -23,7 +23,7 @@ static AesNI_StatusCode aesni_box_encrypt_aes128( AesNI_State* output, AesNI_ErrorDetails* err_details) { - output->aes_block = aesni_raw_encrypt_block128( + output->aes_block = aesni_aes128_encrypt_block_( input->aes_block, ¶ms->aes128_key_schedule); return AESNI_SUCCESS; @@ -35,7 +35,7 @@ static AesNI_StatusCode aesni_box_decrypt_aes128( AesNI_State* output, AesNI_ErrorDetails* err_details) { - output->aes_block = aesni_raw_decrypt_block128( + output->aes_block = aesni_aes128_decrypt_block_( input->aes_block, ¶ms->aes128_key_schedule); return AESNI_SUCCESS; @@ -47,7 +47,7 @@ static AesNI_StatusCode aesni_box_encrypt_aes192( AesNI_State* output, AesNI_ErrorDetails* err_details) { - output->aes_block = aesni_raw_encrypt_block192( + output->aes_block = aesni_aes192_encrypt_block_( input->aes_block, ¶ms->aes192_key_schedule); return AESNI_SUCCESS; @@ -59,7 +59,7 @@ static AesNI_StatusCode aesni_box_decrypt_aes192( AesNI_State* output, AesNI_ErrorDetails* err_details) { - output->aes_block = aesni_raw_decrypt_block192( + output->aes_block = aesni_aes192_decrypt_block_( input->aes_block, ¶ms->aes192_key_schedule); return AESNI_SUCCESS; @@ -71,7 +71,7 @@ static AesNI_StatusCode aesni_box_encrypt_aes256( AesNI_State* output, AesNI_ErrorDetails* err_details) { - output->aes_block = aesni_raw_encrypt_block256( + output->aes_block = aesni_aes256_encrypt_block_( input->aes_block, ¶ms->aes256_key_schedule); return AESNI_SUCCESS; @@ -83,7 +83,7 @@ static AesNI_StatusCode aesni_box_decrypt_aes256( AesNI_State* output, AesNI_ErrorDetails* err_details) { - output->aes_block = aesni_raw_decrypt_block256( + output->aes_block = aesni_aes256_decrypt_block_( input->aes_block, ¶ms->aes256_key_schedule); return AESNI_SUCCESS; @@ -132,10 +132,10 @@ static AesNI_StatusCode aesni_box_init_aes128( const AesNI_AlgorithmParams* algorithm_params, AesNI_ErrorDetails* err_details) { - aesni_raw_expand_key_schedule128( + aesni_aes128_expand_key_( algorithm_params->aes128_key, &box->encrypt_params.aes128_key_schedule); - aesni_raw_invert_key_schedule128( + aesni_aes128_derive_decryption_keys_( &box->encrypt_params.aes128_key_schedule, &box->decrypt_params.aes128_key_schedule); return AESNI_SUCCESS; @@ -146,11 +146,11 @@ static AesNI_StatusCode aesni_box_init_aes192( const AesNI_AlgorithmParams* algorithm_params, AesNI_ErrorDetails* err_details) { - aesni_raw_expand_key_schedule192( + aesni_aes192_expand_key_( algorithm_params->aes192_key.lo, algorithm_params->aes192_key.hi, &box->encrypt_params.aes192_key_schedule); - aesni_raw_invert_key_schedule192( + aesni_aes192_derive_decryption_keys_( &box->encrypt_params.aes192_key_schedule, &box->decrypt_params.aes192_key_schedule); return AESNI_SUCCESS; @@ -161,11 +161,11 @@ static AesNI_StatusCode aesni_box_init_aes256( const AesNI_AlgorithmParams* algorithm_params, AesNI_ErrorDetails* err_details) { - aesni_raw_expand_key_schedule256( + aesni_aes256_expand_key_( algorithm_params->aes256_key.lo, algorithm_params->aes256_key.hi, &box->encrypt_params.aes256_key_schedule); - aesni_raw_invert_key_schedule256( + aesni_aes256_derive_decryption_keys_( &box->encrypt_params.aes256_key_schedule, &box->decrypt_params.aes256_key_schedule); return AESNI_SUCCESS; diff --git a/src/buffer.c b/src/buffer.c index a4aed96..983c5cf 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -18,7 +18,7 @@ AesNI_StatusCode aesni_encrypt_buffer_ecb128( size_t src_size, void* dest, size_t* dest_size, - AesNI_KeySchedule128* key_schedule, + AesNI_Aes128_RoundKeys* key_schedule, AesNI_ErrorDetails* err_details) { if (dest_size == NULL) @@ -40,7 +40,7 @@ AesNI_StatusCode aesni_encrypt_buffer_ecb128( for (size_t i = 0; i < src_len; ++i, (char*) src += 16, (char*) dest += 16) { AesNI_Block128 plaintext = aesni_load_block128(src); - AesNI_Block128 ciphertext = aesni_encrypt_block_ecb128(plaintext, key_schedule); + AesNI_Block128 ciphertext = aesni_aes128_encrypt_block_ecb(plaintext, key_schedule); aesni_store_block128(dest, ciphertext); } @@ -57,7 +57,7 @@ AesNI_StatusCode aesni_encrypt_buffer_ecb128( } AesNI_Block128 plaintext = aesni_load_block128(padding); - AesNI_Block128 ciphertext = aesni_encrypt_block_ecb128(plaintext, key_schedule); + AesNI_Block128 ciphertext = aesni_aes128_encrypt_block_ecb(plaintext, key_schedule); aesni_store_block128(dest, ciphertext); return AESNI_SUCCESS; @@ -80,7 +80,7 @@ AesNI_StatusCode aesni_decrypt_buffer_ecb128( size_t src_size, void* dest, size_t* dest_size, - AesNI_KeySchedule128* inverted_schedule, + AesNI_Aes128_RoundKeys* inverted_schedule, AesNI_ErrorDetails* err_details) { if (dest_size == NULL) @@ -100,12 +100,12 @@ AesNI_StatusCode aesni_decrypt_buffer_ecb128( for (size_t i = 0; i < src_len - 1; ++i, (char*) src += 16, (char*) dest += 16) { AesNI_Block128 ciphertext = aesni_load_block128(src); - AesNI_Block128 plaintext = aesni_decrypt_block_ecb128(ciphertext, inverted_schedule); + AesNI_Block128 plaintext = aesni_aes128_decrypt_block_ecb(ciphertext, inverted_schedule); aesni_store_block128(dest, plaintext); } AesNI_Block128 ciphertext = aesni_load_block128(src); - AesNI_Block128 plaintext = aesni_decrypt_block_ecb128(ciphertext, inverted_schedule); + AesNI_Block128 plaintext = aesni_aes128_decrypt_block_ecb(ciphertext, inverted_schedule); unsigned char padding[16]; aesni_store_block128(padding, plaintext); diff --git a/src/c/aes128.c b/src/c/aes128.c index 92bc4a6..49ebc4a 100644 --- a/src/c/aes128.c +++ b/src/c/aes128.c @@ -11,9 +11,9 @@ #include <emmintrin.h> #include <wmmintrin.h> -AesNI_Block128 __fastcall aesni_raw_encrypt_block128( +AesNI_Block128 __fastcall aesni_aes128_encrypt_block_( AesNI_Block128 plain, - const AesNI_KeySchedule128* key_schedule) + const AesNI_Aes128_RoundKeys* key_schedule) { plain = _mm_xor_si128(plain, key_schedule->keys[0]); plain = _mm_aesenc_si128(plain, key_schedule->keys[1]); @@ -28,9 +28,9 @@ AesNI_Block128 __fastcall aesni_raw_encrypt_block128( return _mm_aesenclast_si128(plain, key_schedule->keys[10]); } -AesNI_Block128 __fastcall aesni_raw_decrypt_block128( +AesNI_Block128 __fastcall aesni_aes128_decrypt_block_( AesNI_Block128 cipher, - const AesNI_KeySchedule128* inverted_schedule) + const AesNI_Aes128_RoundKeys* inverted_schedule) { cipher = _mm_xor_si128(cipher, inverted_schedule->keys[0]); cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[1]); @@ -45,7 +45,7 @@ AesNI_Block128 __fastcall aesni_raw_decrypt_block128( return _mm_aesdeclast_si128(cipher, inverted_schedule->keys[10]); } -static AesNI_Block128 __fastcall aes128_keygen_assist( +static AesNI_Block128 __fastcall aesni_aes128_expand_key_assist( AesNI_Block128 prev, AesNI_Block128 hwgen) { @@ -64,26 +64,26 @@ static AesNI_Block128 __fastcall aes128_keygen_assist( return prev; } -void __fastcall aesni_raw_expand_key_schedule128( +void __fastcall aesni_aes128_expand_key_( AesNI_Block128 key, - AesNI_KeySchedule128* key_schedule) + AesNI_Aes128_RoundKeys* key_schedule) { AesNI_Block128 prev = key_schedule->keys[0] = key; - prev = key_schedule->keys[1] = aes128_keygen_assist(prev, _mm_aeskeygenassist_si128(prev, 0x01)); - prev = key_schedule->keys[2] = aes128_keygen_assist(prev, _mm_aeskeygenassist_si128(prev, 0x02)); - prev = key_schedule->keys[3] = aes128_keygen_assist(prev, _mm_aeskeygenassist_si128(prev, 0x04)); - prev = key_schedule->keys[4] = aes128_keygen_assist(prev, _mm_aeskeygenassist_si128(prev, 0x08)); - prev = key_schedule->keys[5] = aes128_keygen_assist(prev, _mm_aeskeygenassist_si128(prev, 0x10)); - prev = key_schedule->keys[6] = aes128_keygen_assist(prev, _mm_aeskeygenassist_si128(prev, 0x20)); - prev = key_schedule->keys[7] = aes128_keygen_assist(prev, _mm_aeskeygenassist_si128(prev, 0x40)); - prev = key_schedule->keys[8] = aes128_keygen_assist(prev, _mm_aeskeygenassist_si128(prev, 0x80)); - prev = key_schedule->keys[9] = aes128_keygen_assist(prev, _mm_aeskeygenassist_si128(prev, 0x1b)); - prev = key_schedule->keys[10] = aes128_keygen_assist(prev, _mm_aeskeygenassist_si128(prev, 0x36)); + prev = key_schedule->keys[1] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x01)); + prev = key_schedule->keys[2] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x02)); + prev = key_schedule->keys[3] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x04)); + prev = key_schedule->keys[4] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x08)); + prev = key_schedule->keys[5] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x10)); + prev = key_schedule->keys[6] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x20)); + prev = key_schedule->keys[7] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x40)); + prev = key_schedule->keys[8] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x80)); + prev = key_schedule->keys[9] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x1b)); + prev = key_schedule->keys[10] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x36)); } -void __fastcall aesni_raw_invert_key_schedule128( - const AesNI_KeySchedule128* key_schedule, - AesNI_KeySchedule128* inverted_schedule) +void __fastcall aesni_aes128_derive_decryption_keys_( + const AesNI_Aes128_RoundKeys* key_schedule, + AesNI_Aes128_RoundKeys* inverted_schedule) { inverted_schedule->keys[0] = key_schedule->keys[10]; inverted_schedule->keys[1] = _mm_aesimc_si128(key_schedule->keys[9]); diff --git a/src/c/aes192.c b/src/c/aes192.c index b3a7e9f..d6ecea1 100644 --- a/src/c/aes192.c +++ b/src/c/aes192.c @@ -11,9 +11,9 @@ #include <emmintrin.h> #include <wmmintrin.h> -AesNI_Block128 __fastcall aesni_raw_encrypt_block192( +AesNI_Block128 __fastcall aesni_aes192_encrypt_block_( AesNI_Block128 plain, - const AesNI_KeySchedule192* key_schedule) + const AesNI_Aes192_RoundKeys* key_schedule) { plain = _mm_xor_si128(plain, key_schedule->keys[0]); plain = _mm_aesenc_si128(plain, key_schedule->keys[1]); @@ -30,9 +30,9 @@ AesNI_Block128 __fastcall aesni_raw_encrypt_block192( return _mm_aesenclast_si128(plain, key_schedule->keys[12]); } -AesNI_Block128 __fastcall aesni_raw_decrypt_block192( +AesNI_Block128 __fastcall aesni_aes192_decrypt_block_( AesNI_Block128 cipher, - const AesNI_KeySchedule192* inverted_schedule) + const AesNI_Aes192_RoundKeys* inverted_schedule) { cipher = _mm_xor_si128(cipher, inverted_schedule->keys[0]); cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[1]); @@ -49,7 +49,7 @@ AesNI_Block128 __fastcall aesni_raw_decrypt_block192( return _mm_aesdeclast_si128(cipher, inverted_schedule->keys[12]); } -static void __fastcall aes192_keygen_assist( +static void __fastcall aesni_aes192_expand_key_assist( AesNI_Block128* prev_lo, AesNI_Block128* prev_hi, AesNI_Block128 hwgen) @@ -74,49 +74,49 @@ static void __fastcall aes192_keygen_assist( *prev_hi = _mm_xor_si128(*prev_hi, tmp); } -void __fastcall aesni_raw_expand_key_schedule192( +void __fastcall aesni_aes192_expand_key_( AesNI_Block128 key_lo, AesNI_Block128 key_hi, - AesNI_KeySchedule192* key_schedule) + AesNI_Aes192_RoundKeys* key_schedule) { key_schedule->keys[0] = key_lo; key_schedule->keys[1] = key_hi; - aes192_keygen_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x01)); + aesni_aes192_expand_key_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x01)); key_schedule->keys[1] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(key_schedule->keys[1]), _mm_castsi128_pd(key_lo), 0)); key_schedule->keys[2] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(key_lo), _mm_castsi128_pd(key_hi), 1)); - aes192_keygen_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x02)); + aesni_aes192_expand_key_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x02)); key_schedule->keys[3] = key_lo; key_schedule->keys[4] = key_hi; - aes192_keygen_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x04)); + aesni_aes192_expand_key_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x04)); key_schedule->keys[4] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(key_schedule->keys[4]), _mm_castsi128_pd(key_lo), 0)); key_schedule->keys[5] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(key_lo), _mm_castsi128_pd(key_hi), 1)); - aes192_keygen_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x08)); + aesni_aes192_expand_key_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x08)); key_schedule->keys[6] = key_lo; key_schedule->keys[7] = key_hi; - aes192_keygen_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x10)); + aesni_aes192_expand_key_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x10)); key_schedule->keys[7] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(key_schedule->keys[7]), _mm_castsi128_pd(key_lo), 0)); key_schedule->keys[8] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(key_lo), _mm_castsi128_pd(key_hi), 1)); - aes192_keygen_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x20)); + aesni_aes192_expand_key_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x20)); key_schedule->keys[9] = key_lo; key_schedule->keys[10] = key_hi; - aes192_keygen_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x40)); + aesni_aes192_expand_key_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x40)); key_schedule->keys[10] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(key_schedule->keys[10]), _mm_castsi128_pd(key_lo), 0)); key_schedule->keys[11] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(key_lo), _mm_castsi128_pd(key_hi), 1)); - aes192_keygen_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x80)); + aesni_aes192_expand_key_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x80)); key_schedule->keys[12] = key_lo; } -void __fastcall aesni_raw_invert_key_schedule192( - const AesNI_KeySchedule192* key_schedule, - AesNI_KeySchedule192* inverted_schedule) +void __fastcall aesni_aes192_derive_decryption_keys_( + const AesNI_Aes192_RoundKeys* key_schedule, + AesNI_Aes192_RoundKeys* inverted_schedule) { inverted_schedule->keys[0] = key_schedule->keys[12]; inverted_schedule->keys[1] = _mm_aesimc_si128(key_schedule->keys[11]); diff --git a/src/c/aes256.c b/src/c/aes256.c index cd48d0d..05e643e 100644 --- a/src/c/aes256.c +++ b/src/c/aes256.c @@ -11,9 +11,9 @@ #include <emmintrin.h> #include <wmmintrin.h> -AesNI_Block128 __fastcall aesni_raw_encrypt_block256( +AesNI_Block128 __fastcall aesni_aes256_encrypt_block_( AesNI_Block128 plain, - const AesNI_KeySchedule256* key_schedule) + const AesNI_Aes256_RoundKeys* key_schedule) { plain = _mm_xor_si128(plain, key_schedule->keys[0]); plain = _mm_aesenc_si128(plain, key_schedule->keys[1]); @@ -32,9 +32,9 @@ AesNI_Block128 __fastcall aesni_raw_encrypt_block256( return _mm_aesenclast_si128(plain, key_schedule->keys[14]); } -AesNI_Block128 __fastcall aesni_raw_decrypt_block256( +AesNI_Block128 __fastcall aesni_aes256_decrypt_block_( AesNI_Block128 cipher, - const AesNI_KeySchedule256* inverted_schedule) + const AesNI_Aes256_RoundKeys* inverted_schedule) { cipher = _mm_xor_si128(cipher, inverted_schedule->keys[0]); cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[1]); @@ -53,7 +53,7 @@ AesNI_Block128 __fastcall aesni_raw_decrypt_block256( return _mm_aesdeclast_si128(cipher, inverted_schedule->keys[14]); } -static AesNI_Block128 __fastcall aes256_keygen_assist( +static AesNI_Block128 __fastcall aesni_aes256_expand_key_assist( AesNI_Block128* prev_lo, AesNI_Block128* prev_hi, AesNI_Block128 hwgen) @@ -76,10 +76,10 @@ static AesNI_Block128 __fastcall aes256_keygen_assist( return *prev_hi; } -void __fastcall aesni_raw_expand_key_schedule256( +void __fastcall aesni_aes256_expand_key_( AesNI_Block128 key_lo, AesNI_Block128 key_hi, - AesNI_KeySchedule256* key_schedule) + AesNI_Aes256_RoundKeys* key_schedule) { AesNI_Block128 prev_lo, prev_hi; AesNI_Block128 hwgen; @@ -89,60 +89,60 @@ void __fastcall aesni_raw_expand_key_schedule256( hwgen = _mm_aeskeygenassist_si128(prev_hi, 0x01); hwgen = _mm_shuffle_epi32(hwgen, 0xff); - key_schedule->keys[2] = aes256_keygen_assist(&prev_lo, &prev_hi, hwgen); + key_schedule->keys[2] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen); hwgen = _mm_aeskeygenassist_si128(prev_hi, 0); hwgen = _mm_shuffle_epi32(hwgen, 0xaa); - key_schedule->keys[3] = aes256_keygen_assist(&prev_lo, &prev_hi, hwgen); + key_schedule->keys[3] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen); hwgen = _mm_aeskeygenassist_si128(prev_hi, 0x02); hwgen = _mm_shuffle_epi32(hwgen, 0xff); - key_schedule->keys[4] = aes256_keygen_assist(&prev_lo, &prev_hi, hwgen); + key_schedule->keys[4] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen); hwgen = _mm_aeskeygenassist_si128(prev_hi, 0); hwgen = _mm_shuffle_epi32(hwgen, 0xaa); - key_schedule->keys[5] = aes256_keygen_assist(&prev_lo, &prev_hi, hwgen); + key_schedule->keys[5] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen); hwgen = _mm_aeskeygenassist_si128(prev_hi, 0x04); hwgen = _mm_shuffle_epi32(hwgen, 0xff); - key_schedule->keys[6] = aes256_keygen_assist(&prev_lo, &prev_hi, hwgen); + key_schedule->keys[6] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen); hwgen = _mm_aeskeygenassist_si128(prev_hi, 0); hwgen = _mm_shuffle_epi32(hwgen, 0xaa); - key_schedule->keys[7] = aes256_keygen_assist(&prev_lo, &prev_hi, hwgen); + key_schedule->keys[7] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen); hwgen = _mm_aeskeygenassist_si128(prev_hi, 0x08); hwgen = _mm_shuffle_epi32(hwgen, 0xff); - key_schedule->keys[8] = aes256_keygen_assist(&prev_lo, &prev_hi, hwgen); + key_schedule->keys[8] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen); hwgen = _mm_aeskeygenassist_si128(prev_hi, 0); hwgen = _mm_shuffle_epi32(hwgen, 0xaa); - key_schedule->keys[9] = aes256_keygen_assist(&prev_lo, &prev_hi, hwgen); + key_schedule->keys[9] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen); hwgen = _mm_aeskeygenassist_si128(prev_hi, 0x10); hwgen = _mm_shuffle_epi32(hwgen, 0xff); - key_schedule->keys[10] = aes256_keygen_assist(&prev_lo, &prev_hi, hwgen); + key_schedule->keys[10] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen); hwgen = _mm_aeskeygenassist_si128(prev_hi, 0); hwgen = _mm_shuffle_epi32(hwgen, 0xaa); - key_schedule->keys[11] = aes256_keygen_assist(&prev_lo, &prev_hi, hwgen); + key_schedule->keys[11] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen); hwgen = _mm_aeskeygenassist_si128(prev_hi, 0x20); hwgen = _mm_shuffle_epi32(hwgen, 0xff); - key_schedule->keys[12] = aes256_keygen_assist(&prev_lo, &prev_hi, hwgen); + key_schedule->keys[12] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen); hwgen = _mm_aeskeygenassist_si128(prev_hi, 0); hwgen = _mm_shuffle_epi32(hwgen, 0xaa); - key_schedule->keys[13] = aes256_keygen_assist(&prev_lo, &prev_hi, hwgen); + key_schedule->keys[13] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen); hwgen = _mm_aeskeygenassist_si128(prev_hi, 0x40); hwgen = _mm_shuffle_epi32(hwgen, 0xff); - key_schedule->keys[14] = aes256_keygen_assist(&prev_lo, &prev_hi, hwgen); + key_schedule->keys[14] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen); } -void __fastcall aesni_raw_invert_key_schedule256( - const AesNI_KeySchedule256* key_schedule, - AesNI_KeySchedule256* inverted_schedule) +void __fastcall aesni_aes256_derive_decryption_keys_( + const AesNI_Aes256_RoundKeys* key_schedule, + AesNI_Aes256_RoundKeys* inverted_schedule) { inverted_schedule->keys[0] = key_schedule->keys[14]; inverted_schedule->keys[1] = _mm_aesimc_si128(key_schedule->keys[13]); diff --git a/test/aes128cbc_decrypt_block.c b/test/aes128cbc_decrypt_block.c index 933c279..73586eb 100644 --- a/test/aes128cbc_decrypt_block.c +++ b/test/aes128cbc_decrypt_block.c @@ -23,7 +23,7 @@ int main(int argc, char** argv) for (--argc, ++argv; argc > -1; --argc, ++argv) { AesNI_Block128 plain, key, cipher, iv; - AesNI_KeySchedule128 key_schedule, inverted_schedule; + AesNI_Aes128_RoundKeys key_schedule, inverted_schedule; if (argc < 2) exit_with_usage(); @@ -40,8 +40,8 @@ int main(int argc, char** argv) exit_with_usage(); } - aesni_expand_key_schedule128(key, &key_schedule); - aesni_invert_key_schedule128(&key_schedule, &inverted_schedule); + aesni_aes128_expand_key(key, &key_schedule); + aesni_aes128_derive_decryption_keys(&key_schedule, &inverted_schedule); for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) { @@ -53,7 +53,7 @@ int main(int argc, char** argv) fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv); continue; } - plain = aesni_decrypt_block_cbc128(cipher, &inverted_schedule, iv, &iv); + plain = aesni_aes128_decrypt_block_cbc(cipher, &inverted_schedule, iv, &iv); aesni_print_block128(&plain, NULL); } } diff --git a/test/aes128cbc_encrypt_block.c b/test/aes128cbc_encrypt_block.c index 109dfc1..dfdd7d3 100644 --- a/test/aes128cbc_encrypt_block.c +++ b/test/aes128cbc_encrypt_block.c @@ -23,7 +23,7 @@ int main(int argc, char** argv) for (--argc, ++argv; argc > -1; --argc, ++argv) { AesNI_Block128 plain, key, cipher, iv; - AesNI_KeySchedule128 key_schedule; + AesNI_Aes128_RoundKeys key_schedule; if (argc < 2) exit_with_usage(); @@ -40,7 +40,7 @@ int main(int argc, char** argv) exit_with_usage(); } - aesni_expand_key_schedule128(key, &key_schedule); + aesni_aes128_expand_key(key, &key_schedule); for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) { @@ -52,7 +52,7 @@ int main(int argc, char** argv) fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv); continue; } - cipher = aesni_encrypt_block_cbc128(plain, &key_schedule, iv, &iv); + cipher = aesni_aes128_encrypt_block_cbc(plain, &key_schedule, iv, &iv); aesni_print_block128(&cipher, NULL); } } diff --git a/test/aes128cfb_decrypt_block.c b/test/aes128cfb_decrypt_block.c index 4f4803a..a78f276 100644 --- a/test/aes128cfb_decrypt_block.c +++ b/test/aes128cfb_decrypt_block.c @@ -23,7 +23,7 @@ int main(int argc, char** argv) for (--argc, ++argv; argc > -1; --argc, ++argv) { AesNI_Block128 plain, key, cipher, iv; - AesNI_KeySchedule128 key_schedule; + AesNI_Aes128_RoundKeys key_schedule; if (argc < 2) exit_with_usage(); @@ -40,7 +40,7 @@ int main(int argc, char** argv) exit_with_usage(); } - aesni_expand_key_schedule128(key, &key_schedule); + aesni_aes128_expand_key(key, &key_schedule); for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) { @@ -52,7 +52,7 @@ int main(int argc, char** argv) fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv); continue; } - plain = aesni_decrypt_block_cfb128(cipher, &key_schedule, iv, &iv); + plain = aesni_aes128_decrypt_block_cfb(cipher, &key_schedule, iv, &iv); aesni_print_block128(&plain, NULL); } } diff --git a/test/aes128cfb_encrypt_block.c b/test/aes128cfb_encrypt_block.c index 90a1a4b..576a2ed 100644 --- a/test/aes128cfb_encrypt_block.c +++ b/test/aes128cfb_encrypt_block.c @@ -23,7 +23,7 @@ int main(int argc, char** argv) for (--argc, ++argv; argc > -1; --argc, ++argv) { AesNI_Block128 plain, key, cipher, iv; - AesNI_KeySchedule128 key_schedule; + AesNI_Aes128_RoundKeys key_schedule; if (argc < 2) exit_with_usage(); @@ -40,7 +40,7 @@ int main(int argc, char** argv) exit_with_usage(); } - aesni_expand_key_schedule128(key, &key_schedule); + aesni_aes128_expand_key(key, &key_schedule); for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) { @@ -52,7 +52,7 @@ int main(int argc, char** argv) fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv); continue; } - cipher = aesni_encrypt_block_cfb128(plain, &key_schedule, iv, &iv); + cipher = aesni_aes128_encrypt_block_cfb(plain, &key_schedule, iv, &iv); aesni_print_block128(&cipher, NULL); } } diff --git a/test/aes128ctr_decrypt_block.c b/test/aes128ctr_decrypt_block.c index 54c8375..940d2f4 100644 --- a/test/aes128ctr_decrypt_block.c +++ b/test/aes128ctr_decrypt_block.c @@ -23,7 +23,7 @@ int main(int argc, char** argv) for (--argc, ++argv; argc > -1; --argc, ++argv) { AesNI_Block128 plain, key, cipher, iv; - AesNI_KeySchedule128 key_schedule; + AesNI_Aes128_RoundKeys key_schedule; if (argc < 2) exit_with_usage(); @@ -40,7 +40,7 @@ int main(int argc, char** argv) exit_with_usage(); } - aesni_expand_key_schedule128(key, &key_schedule); + aesni_aes128_expand_key(key, &key_schedule); int ctr = 0; @@ -54,7 +54,7 @@ int main(int argc, char** argv) fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv); continue; } - plain = aesni_decrypt_block_ctr128(cipher, &key_schedule, iv, ctr++); + plain = aesni_aes128_decrypt_block_ctr(cipher, &key_schedule, iv, ctr++); aesni_print_block128(&plain, NULL); } } diff --git a/test/aes128ctr_encrypt_block.c b/test/aes128ctr_encrypt_block.c index d5cec3b..32dd216 100644 --- a/test/aes128ctr_encrypt_block.c +++ b/test/aes128ctr_encrypt_block.c @@ -23,7 +23,7 @@ int main(int argc, char** argv) for (--argc, ++argv; argc > -1; --argc, ++argv) { AesNI_Block128 plain, key, cipher, iv; - AesNI_KeySchedule128 key_schedule; + AesNI_Aes128_RoundKeys key_schedule; if (argc < 2) exit_with_usage(); @@ -40,7 +40,7 @@ int main(int argc, char** argv) exit_with_usage(); } - aesni_expand_key_schedule128(key, &key_schedule); + aesni_aes128_expand_key(key, &key_schedule); int ctr = 0; @@ -54,7 +54,7 @@ int main(int argc, char** argv) fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv); continue; } - cipher = aesni_encrypt_block_ctr128(plain, &key_schedule, iv, ctr++); + cipher = aesni_aes128_encrypt_block_ctr(plain, &key_schedule, iv, ctr++); aesni_print_block128(&cipher, NULL); } } diff --git a/test/aes128ecb_decrypt_block.c b/test/aes128ecb_decrypt_block.c index f470ecc..5885fb9 100644 --- a/test/aes128ecb_decrypt_block.c +++ b/test/aes128ecb_decrypt_block.c @@ -23,7 +23,7 @@ int main(int argc, char** argv) for (--argc, ++argv; argc > -1; --argc, ++argv) { AesNI_Block128 plain, key, cipher; - AesNI_KeySchedule128 key_schedule, inverted_schedule; + AesNI_Aes128_RoundKeys key_schedule, inverted_schedule; if (argc < 1) exit_with_usage(); @@ -34,8 +34,8 @@ int main(int argc, char** argv) exit_with_usage(); } - aesni_expand_key_schedule128(key, &key_schedule); - aesni_invert_key_schedule128(&key_schedule, &inverted_schedule); + aesni_aes128_expand_key(key, &key_schedule); + aesni_aes128_derive_decryption_keys(&key_schedule, &inverted_schedule); for (--argc, ++argv; argc > 0; --argc, ++argv) { @@ -47,7 +47,7 @@ int main(int argc, char** argv) fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv); continue; } - plain = aesni_decrypt_block_ecb128(cipher, &inverted_schedule); + plain = aesni_aes128_decrypt_block_ecb(cipher, &inverted_schedule); aesni_print_block128(&plain, NULL); } } diff --git a/test/aes128ecb_encrypt_block.c b/test/aes128ecb_encrypt_block.c index be86d05..040d47d 100644 --- a/test/aes128ecb_encrypt_block.c +++ b/test/aes128ecb_encrypt_block.c @@ -23,7 +23,7 @@ int main(int argc, char** argv) for (--argc, ++argv; argc > -1; --argc, ++argv) { AesNI_Block128 plain, key, cipher; - AesNI_KeySchedule128 key_schedule; + AesNI_Aes128_RoundKeys key_schedule; if (argc < 1) exit_with_usage(); @@ -34,7 +34,7 @@ int main(int argc, char** argv) exit_with_usage(); } - aesni_expand_key_schedule128(key, &key_schedule); + aesni_aes128_expand_key(key, &key_schedule); for (--argc, ++argv; argc > 0; --argc, ++argv) { @@ -46,7 +46,7 @@ int main(int argc, char** argv) fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv); continue; } - cipher = aesni_encrypt_block_ecb128(plain, &key_schedule); + cipher = aesni_aes128_encrypt_block_ecb(plain, &key_schedule); aesni_print_block128(&cipher, NULL); } } diff --git a/test/aes128ofb_decrypt_block.c b/test/aes128ofb_decrypt_block.c index b8a6880..16f148d 100644 --- a/test/aes128ofb_decrypt_block.c +++ b/test/aes128ofb_decrypt_block.c @@ -23,7 +23,7 @@ int main(int argc, char** argv) for (--argc, ++argv; argc > -1; --argc, ++argv) { AesNI_Block128 plain, key, cipher, iv; - AesNI_KeySchedule128 key_schedule; + AesNI_Aes128_RoundKeys key_schedule; if (argc < 2) exit_with_usage(); @@ -40,7 +40,7 @@ int main(int argc, char** argv) exit_with_usage(); } - aesni_expand_key_schedule128(key, &key_schedule); + aesni_aes128_expand_key(key, &key_schedule); for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) { @@ -52,7 +52,7 @@ int main(int argc, char** argv) fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv); continue; } - plain = aesni_decrypt_block_ofb128(cipher, &key_schedule, iv, &iv); + plain = aesni_aes128_decrypt_block_ofb(cipher, &key_schedule, iv, &iv); aesni_print_block128(&plain, NULL); } } diff --git a/test/aes128ofb_encrypt_block.c b/test/aes128ofb_encrypt_block.c index a64fa31..4532cc8 100644 --- a/test/aes128ofb_encrypt_block.c +++ b/test/aes128ofb_encrypt_block.c @@ -23,7 +23,7 @@ int main(int argc, char** argv) for (--argc, ++argv; argc > -1; --argc, ++argv) { AesNI_Block128 plain, key, cipher, iv; - AesNI_KeySchedule128 key_schedule; + AesNI_Aes128_RoundKeys key_schedule; if (argc < 2) exit_with_usage(); @@ -40,7 +40,7 @@ int main(int argc, char** argv) exit_with_usage(); } - aesni_expand_key_schedule128(key, &key_schedule); + aesni_aes128_expand_key(key, &key_schedule); for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) { @@ -52,7 +52,7 @@ int main(int argc, char** argv) fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv); continue; } - cipher = aesni_encrypt_block_ofb128(plain, &key_schedule, iv, &iv); + cipher = aesni_aes128_encrypt_block_ofb(plain, &key_schedule, iv, &iv); aesni_print_block128(&cipher, NULL); } } diff --git a/test/aes192cbc_decrypt_block.c b/test/aes192cbc_decrypt_block.c index 2ee439f..9d5e1d6 100644 --- a/test/aes192cbc_decrypt_block.c +++ b/test/aes192cbc_decrypt_block.c @@ -24,7 +24,7 @@ int main(int argc, char** argv) { AesNI_Block128 plain, cipher, iv; AesNI_Block192 key; - AesNI_KeySchedule192 key_schedule, inverted_schedule; + AesNI_Aes192_RoundKeys key_schedule, inverted_schedule; if (argc < 2) exit_with_usage(); @@ -41,8 +41,8 @@ int main(int argc, char** argv) exit_with_usage(); } - aesni_expand_key_schedule192(&key, &key_schedule); - aesni_invert_key_schedule192(&key_schedule, &inverted_schedule); + aesni_aes192_expand_key(&key, &key_schedule); + aesni_aes192_derive_decryption_keys(&key_schedule, &inverted_schedule); for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) { @@ -54,7 +54,7 @@ int main(int argc, char** argv) fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv); continue; } - plain = aesni_decrypt_block_cbc192(cipher, &inverted_schedule, iv, &iv); + plain = aesni_aes192_decrypt_block_cbc(cipher, &inverted_schedule, iv, &iv); aesni_print_block128(&plain, NULL); } } diff --git a/test/aes192cbc_encrypt_block.c b/test/aes192cbc_encrypt_block.c index ffd164e..d562ae5 100644 --- a/test/aes192cbc_encrypt_block.c +++ b/test/aes192cbc_encrypt_block.c @@ -24,7 +24,7 @@ int main(int argc, char** argv) { AesNI_Block128 plain, cipher, iv; AesNI_Block192 key; - AesNI_KeySchedule192 key_schedule; + AesNI_Aes192_RoundKeys key_schedule; if (argc < 2) exit_with_usage(); @@ -41,7 +41,7 @@ int main(int argc, char** argv) exit_with_usage(); } - aesni_expand_key_schedule192(&key, &key_schedule); + aesni_aes192_expand_key(&key, &key_schedule); for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) { @@ -53,7 +53,7 @@ int main(int argc, char** argv) fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv); continue; } - cipher = aesni_encrypt_block_cbc192(plain, &key_schedule, iv, &iv); + cipher = aesni_aes192_encrypt_block_cbc(plain, &key_schedule, iv, &iv); aesni_print_block128(&cipher, NULL); } } diff --git a/test/aes192cfb_decrypt_block.c b/test/aes192cfb_decrypt_block.c index 4bd04bd..b5703d1 100644 --- a/test/aes192cfb_decrypt_block.c +++ b/test/aes192cfb_decrypt_block.c @@ -24,7 +24,7 @@ int main(int argc, char** argv) { AesNI_Block128 plain, cipher, iv; AesNI_Block192 key; - AesNI_KeySchedule192 key_schedule; + AesNI_Aes192_RoundKeys key_schedule; if (argc < 2) exit_with_usage(); @@ -41,7 +41,7 @@ int main(int argc, char** argv) exit_with_usage(); } - aesni_expand_key_schedule192(&key, &key_schedule); + aesni_aes192_expand_key(&key, &key_schedule); for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) { @@ -53,7 +53,7 @@ int main(int argc, char** argv) fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv); continue; } - plain = aesni_decrypt_block_cfb192(cipher, &key_schedule, iv, &iv); + plain = aesni_aes192_decrypt_block_cfb(cipher, &key_schedule, iv, &iv); aesni_print_block128(&plain, NULL); } } diff --git a/test/aes192cfb_encrypt_block.c b/test/aes192cfb_encrypt_block.c index 6248e94..a23aa72 100644 --- a/test/aes192cfb_encrypt_block.c +++ b/test/aes192cfb_encrypt_block.c @@ -24,7 +24,7 @@ int main(int argc, char** argv) { AesNI_Block128 plain, cipher, iv; AesNI_Block192 key; - AesNI_KeySchedule192 key_schedule; + AesNI_Aes192_RoundKeys key_schedule; if (argc < 2) exit_with_usage(); @@ -41,7 +41,7 @@ int main(int argc, char** argv) exit_with_usage(); } - aesni_expand_key_schedule192(&key, &key_schedule); + aesni_aes192_expand_key(&key, &key_schedule); for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) { @@ -53,7 +53,7 @@ int main(int argc, char** argv) fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv); continue; } - cipher = aesni_encrypt_block_cfb192(plain, &key_schedule, iv, &iv); + cipher = aesni_aes192_encrypt_block_cfb(plain, &key_schedule, iv, &iv); aesni_print_block128(&cipher, NULL); } } diff --git a/test/aes192ctr_decrypt_block.c b/test/aes192ctr_decrypt_block.c index 6d0387e..14e91d9 100644 --- a/test/aes192ctr_decrypt_block.c +++ b/test/aes192ctr_decrypt_block.c @@ -24,7 +24,7 @@ int main(int argc, char** argv) { AesNI_Block128 plain, cipher, iv; AesNI_Block192 key; - AesNI_KeySchedule192 key_schedule; + AesNI_Aes192_RoundKeys key_schedule; if (argc < 2) exit_with_usage(); @@ -41,7 +41,7 @@ int main(int argc, char** argv) exit_with_usage(); } - aesni_expand_key_schedule192(&key, &key_schedule); + aesni_aes192_expand_key(&key, &key_schedule); int ctr = 0; @@ -55,7 +55,7 @@ int main(int argc, char** argv) fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv); continue; } - plain = aesni_decrypt_block_ctr192(cipher, &key_schedule, iv, ctr++); + plain = aesni_aes192_decrypt_block_ctr(cipher, &key_schedule, iv, ctr++); aesni_print_block128(&plain, NULL); } } diff --git a/test/aes192ctr_encrypt_block.c b/test/aes192ctr_encrypt_block.c index d0780c1..e613d87 100644 --- a/test/aes192ctr_encrypt_block.c +++ b/test/aes192ctr_encrypt_block.c @@ -24,7 +24,7 @@ int main(int argc, char** argv) { AesNI_Block128 plain, cipher, iv; AesNI_Block192 key; - AesNI_KeySchedule192 key_schedule; + AesNI_Aes192_RoundKeys key_schedule; if (argc < 2) exit_with_usage(); @@ -41,7 +41,7 @@ int main(int argc, char** argv) exit_with_usage(); } - aesni_expand_key_schedule192(&key, &key_schedule); + aesni_aes192_expand_key(&key, &key_schedule); int ctr = 0; @@ -55,7 +55,7 @@ int main(int argc, char** argv) fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv); continue; } - cipher = aesni_encrypt_block_ctr192(plain, &key_schedule, iv, ctr++); + cipher = aesni_aes192_encrypt_block_ctr(plain, &key_schedule, iv, ctr++); aesni_print_block128(&cipher, NULL); } } diff --git a/test/aes192ecb_decrypt_block.c b/test/aes192ecb_decrypt_block.c index 399e00c..39689e9 100644 --- a/test/aes192ecb_decrypt_block.c +++ b/test/aes192ecb_decrypt_block.c @@ -24,7 +24,7 @@ int main(int argc, char** argv) { AesNI_Block128 plain, cipher; AesNI_Block192 key; - AesNI_KeySchedule192 key_schedule, inverted_schedule; + AesNI_Aes192_RoundKeys key_schedule, inverted_schedule; if (argc < 1) exit_with_usage(); @@ -35,8 +35,8 @@ int main(int argc, char** argv) exit_with_usage(); } - aesni_expand_key_schedule192(&key, &key_schedule); - aesni_invert_key_schedule192(&key_schedule, &inverted_schedule); + aesni_aes192_expand_key(&key, &key_schedule); + aesni_aes192_derive_decryption_keys(&key_schedule, &inverted_schedule); for (--argc, ++argv; argc > 0; --argc, ++argv) { @@ -48,7 +48,7 @@ int main(int argc, char** argv) fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv); continue; } - plain = aesni_decrypt_block_ecb192(cipher, &inverted_schedule); + plain = aesni_aes192_decrypt_block_ecb(cipher, &inverted_schedule); aesni_print_block128(&plain, NULL); } } diff --git a/test/aes192ecb_encrypt_block.c b/test/aes192ecb_encrypt_block.c index 051efc3..167ffd4 100644 --- a/test/aes192ecb_encrypt_block.c +++ b/test/aes192ecb_encrypt_block.c @@ -24,7 +24,7 @@ int main(int argc, char** argv) { AesNI_Block128 plain, cipher; AesNI_Block192 key; - AesNI_KeySchedule192 key_schedule; + AesNI_Aes192_RoundKeys key_schedule; if (argc < 1) exit_with_usage(); @@ -35,7 +35,7 @@ int main(int argc, char** argv) exit_with_usage(); } - aesni_expand_key_schedule192(&key, &key_schedule); + aesni_aes192_expand_key(&key, &key_schedule); for (--argc, ++argv; argc > 0; --argc, ++argv) { @@ -47,7 +47,7 @@ int main(int argc, char** argv) fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv); continue; } - cipher = aesni_encrypt_block_ecb192(plain, &key_schedule); + cipher = aesni_aes192_encrypt_block_ecb(plain, &key_schedule); aesni_print_block128(&cipher, NULL); } } diff --git a/test/aes192ofb_decrypt_block.c b/test/aes192ofb_decrypt_block.c index 0cc1501..4dd5fbb 100644 --- a/test/aes192ofb_decrypt_block.c +++ b/test/aes192ofb_decrypt_block.c @@ -24,7 +24,7 @@ int main(int argc, char** argv) { AesNI_Block128 plain, cipher, iv; AesNI_Block192 key; - AesNI_KeySchedule192 key_schedule; + AesNI_Aes192_RoundKeys key_schedule; if (argc < 2) exit_with_usage(); @@ -41,7 +41,7 @@ int main(int argc, char** argv) exit_with_usage(); } - aesni_expand_key_schedule192(&key, &key_schedule); + aesni_aes192_expand_key(&key, &key_schedule); for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) { @@ -53,7 +53,7 @@ int main(int argc, char** argv) fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv); continue; } - plain = aesni_decrypt_block_ofb192(cipher, &key_schedule, iv, &iv); + plain = aesni_aes192_decrypt_block_ofb(cipher, &key_schedule, iv, &iv); aesni_print_block128(&plain, NULL); } } diff --git a/test/aes192ofb_encrypt_block.c b/test/aes192ofb_encrypt_block.c index 8282c23..2a45b79 100644 --- a/test/aes192ofb_encrypt_block.c +++ b/test/aes192ofb_encrypt_block.c @@ -24,7 +24,7 @@ int main(int argc, char** argv) { AesNI_Block128 plain, cipher, iv; AesNI_Block192 key; - AesNI_KeySchedule192 key_schedule; + AesNI_Aes192_RoundKeys key_schedule; if (argc < 2) exit_with_usage(); @@ -41,7 +41,7 @@ int main(int argc, char** argv) exit_with_usage(); } - aesni_expand_key_schedule192(&key, &key_schedule); + aesni_aes192_expand_key(&key, &key_schedule); for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) { @@ -53,7 +53,7 @@ int main(int argc, char** argv) fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv); continue; } - cipher = aesni_encrypt_block_ofb192(plain, &key_schedule, iv, &iv); + cipher = aesni_aes192_encrypt_block_ofb(plain, &key_schedule, iv, &iv); aesni_print_block128(&cipher, NULL); } } diff --git a/test/aes256cbc_decrypt_block.c b/test/aes256cbc_decrypt_block.c index b3b15ce..7cfd85a 100644 --- a/test/aes256cbc_decrypt_block.c +++ b/test/aes256cbc_decrypt_block.c @@ -24,7 +24,7 @@ int main(int argc, char** argv) { AesNI_Block128 plain, cipher, iv; AesNI_Block256 key; - AesNI_KeySchedule256 key_schedule, inverted_schedule; + AesNI_Aes256_RoundKeys key_schedule, inverted_schedule; if (argc < 2) exit_with_usage(); @@ -41,8 +41,8 @@ int main(int argc, char** argv) exit_with_usage(); } - aesni_expand_key_schedule256(&key, &key_schedule); - aesni_invert_key_schedule256(&key_schedule, &inverted_schedule); + aesni_aes256_expand_key(&key, &key_schedule); + aesni_aes256_derive_decryption_keys(&key_schedule, &inverted_schedule); for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) { @@ -54,7 +54,7 @@ int main(int argc, char** argv) fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv); continue; } - plain = aesni_decrypt_block_cbc256(cipher, &inverted_schedule, iv, &iv); + plain = aesni_aes256_decrypt_block_cbc(cipher, &inverted_schedule, iv, &iv); aesni_print_block128(&plain, NULL); } } diff --git a/test/aes256cbc_encrypt_block.c b/test/aes256cbc_encrypt_block.c index cb3be83..9c0c24b 100644 --- a/test/aes256cbc_encrypt_block.c +++ b/test/aes256cbc_encrypt_block.c @@ -24,7 +24,7 @@ int main(int argc, char** argv) { AesNI_Block128 plain, cipher, iv; AesNI_Block256 key; - AesNI_KeySchedule256 key_schedule; + AesNI_Aes256_RoundKeys key_schedule; if (argc < 2) exit_with_usage(); @@ -41,7 +41,7 @@ int main(int argc, char** argv) exit_with_usage(); } - aesni_expand_key_schedule256(&key, &key_schedule); + aesni_aes256_expand_key(&key, &key_schedule); for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) { @@ -53,7 +53,7 @@ int main(int argc, char** argv) fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv); continue; } - cipher = aesni_encrypt_block_cbc256(plain, &key_schedule, iv, &iv); + cipher = aesni_aes256_encrypt_block_cbc(plain, &key_schedule, iv, &iv); aesni_print_block128(&cipher, NULL); } } diff --git a/test/aes256cfb_decrypt_block.c b/test/aes256cfb_decrypt_block.c index cfdfb4b..3f8f696 100644 --- a/test/aes256cfb_decrypt_block.c +++ b/test/aes256cfb_decrypt_block.c @@ -24,7 +24,7 @@ int main(int argc, char** argv) { AesNI_Block128 plain, cipher, iv; AesNI_Block256 key; - AesNI_KeySchedule256 key_schedule; + AesNI_Aes256_RoundKeys key_schedule; if (argc < 2) exit_with_usage(); @@ -41,7 +41,7 @@ int main(int argc, char** argv) exit_with_usage(); } - aesni_expand_key_schedule256(&key, &key_schedule); + aesni_aes256_expand_key(&key, &key_schedule); for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) { @@ -53,7 +53,7 @@ int main(int argc, char** argv) fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv); continue; } - plain = aesni_decrypt_block_cfb256(cipher, &key_schedule, iv, &iv); + plain = aesni_aes256_decrypt_block_cfb(cipher, &key_schedule, iv, &iv); aesni_print_block128(&plain, NULL); } } diff --git a/test/aes256cfb_encrypt_block.c b/test/aes256cfb_encrypt_block.c index 0a73528..aca05a8 100644 --- a/test/aes256cfb_encrypt_block.c +++ b/test/aes256cfb_encrypt_block.c @@ -24,7 +24,7 @@ int main(int argc, char** argv) { AesNI_Block128 plain, cipher, iv; AesNI_Block256 key; - AesNI_KeySchedule256 key_schedule; + AesNI_Aes256_RoundKeys key_schedule; if (argc < 2) exit_with_usage(); @@ -41,7 +41,7 @@ int main(int argc, char** argv) exit_with_usage(); } - aesni_expand_key_schedule256(&key, &key_schedule); + aesni_aes256_expand_key(&key, &key_schedule); for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) { @@ -53,7 +53,7 @@ int main(int argc, char** argv) fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv); continue; } - cipher = aesni_encrypt_block_cfb256(plain, &key_schedule, iv, &iv); + cipher = aesni_aes256_encrypt_block_cfb(plain, &key_schedule, iv, &iv); aesni_print_block128(&cipher, NULL); } } diff --git a/test/aes256ctr_decrypt_block.c b/test/aes256ctr_decrypt_block.c index 6e7f875..8255a11 100644 --- a/test/aes256ctr_decrypt_block.c +++ b/test/aes256ctr_decrypt_block.c @@ -24,7 +24,7 @@ int main(int argc, char** argv) { AesNI_Block128 plain, cipher, iv; AesNI_Block256 key; - AesNI_KeySchedule256 key_schedule; + AesNI_Aes256_RoundKeys key_schedule; if (argc < 2) exit_with_usage(); @@ -41,7 +41,7 @@ int main(int argc, char** argv) exit_with_usage(); } - aesni_expand_key_schedule256(&key, &key_schedule); + aesni_aes256_expand_key(&key, &key_schedule); int ctr = 0; @@ -55,7 +55,7 @@ int main(int argc, char** argv) fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv); continue; } - plain = aesni_decrypt_block_ctr256(cipher, &key_schedule, iv, ctr++); + plain = aesni_aes256_decrypt_block_ctr(cipher, &key_schedule, iv, ctr++); aesni_print_block128(&plain, NULL); } } diff --git a/test/aes256ctr_encrypt_block.c b/test/aes256ctr_encrypt_block.c index 667b593..580c6e7 100644 --- a/test/aes256ctr_encrypt_block.c +++ b/test/aes256ctr_encrypt_block.c @@ -24,7 +24,7 @@ int main(int argc, char** argv) { AesNI_Block128 plain, cipher, iv; AesNI_Block256 key; - AesNI_KeySchedule256 key_schedule; + AesNI_Aes256_RoundKeys key_schedule; if (argc < 2) exit_with_usage(); @@ -41,7 +41,7 @@ int main(int argc, char** argv) exit_with_usage(); } - aesni_expand_key_schedule256(&key, &key_schedule); + aesni_aes256_expand_key(&key, &key_schedule); int ctr = 0; @@ -55,7 +55,7 @@ int main(int argc, char** argv) fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv); continue; } - cipher = aesni_encrypt_block_ctr256(plain, &key_schedule, iv, ctr++); + cipher = aesni_aes256_encrypt_block_ctr(plain, &key_schedule, iv, ctr++); aesni_print_block128(&cipher, NULL); } } diff --git a/test/aes256ecb_decrypt_block.c b/test/aes256ecb_decrypt_block.c index 0ea066a..f4b38c5 100644 --- a/test/aes256ecb_decrypt_block.c +++ b/test/aes256ecb_decrypt_block.c @@ -24,7 +24,7 @@ int main(int argc, char** argv) { AesNI_Block128 plain, cipher; AesNI_Block256 key; - AesNI_KeySchedule256 key_schedule, inverted_schedule; + AesNI_Aes256_RoundKeys key_schedule, inverted_schedule; if (argc < 1) exit_with_usage(); @@ -35,8 +35,8 @@ int main(int argc, char** argv) exit_with_usage(); } - aesni_expand_key_schedule256(&key, &key_schedule); - aesni_invert_key_schedule256(&key_schedule, &inverted_schedule); + aesni_aes256_expand_key(&key, &key_schedule); + aesni_aes256_derive_decryption_keys(&key_schedule, &inverted_schedule); for (--argc, ++argv; argc > 0; --argc, ++argv) { @@ -48,7 +48,7 @@ int main(int argc, char** argv) fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv); continue; } - plain = aesni_decrypt_block_ecb256(cipher, &inverted_schedule); + plain = aesni_aes256_decrypt_block_ecb(cipher, &inverted_schedule); aesni_print_block128(&plain, NULL); } } diff --git a/test/aes256ecb_encrypt_block.c b/test/aes256ecb_encrypt_block.c index 289c82f..7752383 100644 --- a/test/aes256ecb_encrypt_block.c +++ b/test/aes256ecb_encrypt_block.c @@ -24,7 +24,7 @@ int main(int argc, char** argv) { AesNI_Block128 plain, cipher; AesNI_Block256 key; - AesNI_KeySchedule256 key_schedule; + AesNI_Aes256_RoundKeys key_schedule; if (argc < 1) exit_with_usage(); @@ -35,7 +35,7 @@ int main(int argc, char** argv) exit_with_usage(); } - aesni_expand_key_schedule256(&key, &key_schedule); + aesni_aes256_expand_key(&key, &key_schedule); for (--argc, ++argv; argc > 0; --argc, ++argv) { @@ -47,7 +47,7 @@ int main(int argc, char** argv) fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv); continue; } - cipher = aesni_encrypt_block_ecb256(plain, &key_schedule); + cipher = aesni_aes256_encrypt_block_ecb(plain, &key_schedule); aesni_print_block128(&cipher, NULL); } } diff --git a/test/aes256ofb_decrypt_block.c b/test/aes256ofb_decrypt_block.c index e323d79..b1c533d 100644 --- a/test/aes256ofb_decrypt_block.c +++ b/test/aes256ofb_decrypt_block.c @@ -24,7 +24,7 @@ int main(int argc, char** argv) { AesNI_Block128 plain, cipher, iv; AesNI_Block256 key; - AesNI_KeySchedule256 key_schedule; + AesNI_Aes256_RoundKeys key_schedule; if (argc < 2) exit_with_usage(); @@ -41,7 +41,7 @@ int main(int argc, char** argv) exit_with_usage(); } - aesni_expand_key_schedule256(&key, &key_schedule); + aesni_aes256_expand_key(&key, &key_schedule); for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) { @@ -53,7 +53,7 @@ int main(int argc, char** argv) fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv); continue; } - plain = aesni_decrypt_block_ofb256(cipher, &key_schedule, iv, &iv); + plain = aesni_aes256_decrypt_block_ofb(cipher, &key_schedule, iv, &iv); aesni_print_block128(&plain, NULL); } } diff --git a/test/aes256ofb_encrypt_block.c b/test/aes256ofb_encrypt_block.c index 7a185eb..975a653 100644 --- a/test/aes256ofb_encrypt_block.c +++ b/test/aes256ofb_encrypt_block.c @@ -24,7 +24,7 @@ int main(int argc, char** argv) { AesNI_Block128 plain, cipher, iv; AesNI_Block256 key; - AesNI_KeySchedule256 key_schedule; + AesNI_Aes256_RoundKeys key_schedule; if (argc < 2) exit_with_usage(); @@ -41,7 +41,7 @@ int main(int argc, char** argv) exit_with_usage(); } - aesni_expand_key_schedule256(&key, &key_schedule); + aesni_aes256_expand_key(&key, &key_schedule); for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) { @@ -53,7 +53,7 @@ int main(int argc, char** argv) fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv); continue; } - cipher = aesni_encrypt_block_ofb256(plain, &key_schedule, iv, &iv); + cipher = aesni_aes256_encrypt_block_ofb(plain, &key_schedule, iv, &iv); aesni_print_block128(&cipher, NULL); } } diff --git a/utils/aes128ecb_decrypt_file.cpp b/utils/aes128ecb_decrypt_file.cpp index 5d9afd2..b2abe8f 100644 --- a/utils/aes128ecb_decrypt_file.cpp +++ b/utils/aes128ecb_decrypt_file.cpp @@ -37,7 +37,7 @@ namespace int main(int argc, char** argv) { AesNI_Block128 key; - AesNI_KeySchedule128 key_schedule, inverted_schedule; + AesNI_Aes128_RoundKeys key_schedule, inverted_schedule; if (argc != 4) exit_with_usage(); @@ -60,8 +60,8 @@ int main(int argc, char** argv) src_buf.assign(std::istreambuf_iterator<char>(src_ifs), std::istreambuf_iterator<char>()); - aesni_expand_key_schedule128(key, &key_schedule); - aesni_invert_key_schedule128(&key_schedule, &inverted_schedule); + aesni_aes128_expand_key(key, &key_schedule); + aesni_aes128_derive_decryption_keys(&key_schedule, &inverted_schedule); std::size_t dest_size; diff --git a/utils/aes128ecb_encrypt_file.cpp b/utils/aes128ecb_encrypt_file.cpp index a2d13c6..05863c2 100644 --- a/utils/aes128ecb_encrypt_file.cpp +++ b/utils/aes128ecb_encrypt_file.cpp @@ -37,7 +37,7 @@ namespace int main(int argc, char** argv) { AesNI_Block128 key; - AesNI_KeySchedule128 key_schedule; + AesNI_Aes128_RoundKeys key_schedule; if (argc != 4) exit_with_usage(); @@ -60,7 +60,7 @@ int main(int argc, char** argv) src_buf.assign(std::istreambuf_iterator<char>(src_ifs), std::istreambuf_iterator<char>()); - aesni_expand_key_schedule128(key, &key_schedule); + aesni_aes128_expand_key(key, &key_schedule); std::size_t dest_size; |