aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2015-06-17 21:09:42 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2015-06-17 21:09:42 +0300
commit8430473494fcdbf39e02fcff80d51124df728e97 (patch)
treeba2a30c419e2d2e9fdd05ff697d98e24f1ef1876
parentfactoring out AES-specific stuff (diff)
downloadaes-tools-8430473494fcdbf39e02fcff80d51124df728e97.tar.gz
aes-tools-8430473494fcdbf39e02fcff80d51124df728e97.zip
refactoring
-rw-r--r--cxx/include/aesnixx/data.hpp4
-rw-r--r--include/aesni/aes.h732
-rw-r--r--include/aesni/buffer.h4
-rw-r--r--src/asm/aes128.asm4
-rw-r--r--src/asm/aes256.asm4
-rw-r--r--src/buffer.c20
-rw-r--r--src/c/aes128.c102
-rw-r--r--src/c/aes192.c126
-rw-r--r--src/c/aes256.c134
-rw-r--r--test/aes128cbc_decrypt_block.c14
-rw-r--r--test/aes128cbc_encrypt_block.c12
-rw-r--r--test/aes128cfb_decrypt_block.c12
-rw-r--r--test/aes128cfb_encrypt_block.c12
-rw-r--r--test/aes128ctr_decrypt_block.c12
-rw-r--r--test/aes128ctr_encrypt_block.c12
-rw-r--r--test/aes128ecb_decrypt_block.c14
-rw-r--r--test/aes128ecb_encrypt_block.c12
-rw-r--r--test/aes128ofb_decrypt_block.c12
-rw-r--r--test/aes128ofb_encrypt_block.c12
-rw-r--r--test/aes192cbc_decrypt_block.c14
-rw-r--r--test/aes192cbc_encrypt_block.c12
-rw-r--r--test/aes192cfb_decrypt_block.c12
-rw-r--r--test/aes192cfb_encrypt_block.c12
-rw-r--r--test/aes192ctr_decrypt_block.c12
-rw-r--r--test/aes192ctr_encrypt_block.c12
-rw-r--r--test/aes192ecb_decrypt_block.c14
-rw-r--r--test/aes192ecb_encrypt_block.c12
-rw-r--r--test/aes192ofb_decrypt_block.c12
-rw-r--r--test/aes192ofb_encrypt_block.c12
-rw-r--r--test/aes256cbc_decrypt_block.c14
-rw-r--r--test/aes256cbc_encrypt_block.c12
-rw-r--r--test/aes256cfb_decrypt_block.c12
-rw-r--r--test/aes256cfb_encrypt_block.c12
-rw-r--r--test/aes256ctr_decrypt_block.c12
-rw-r--r--test/aes256ctr_encrypt_block.c12
-rw-r--r--test/aes256ecb_decrypt_block.c14
-rw-r--r--test/aes256ecb_encrypt_block.c12
-rw-r--r--test/aes256ofb_decrypt_block.c12
-rw-r--r--test/aes256ofb_encrypt_block.c12
-rw-r--r--utils/aes128ecb_decrypt_file.cpp10
-rw-r--r--utils/aes128ecb_encrypt_file.cpp8
41 files changed, 717 insertions, 803 deletions
diff --git a/cxx/include/aesnixx/data.hpp b/cxx/include/aesnixx/data.hpp
index c667e94..e620915 100644
--- a/cxx/include/aesnixx/data.hpp
+++ b/cxx/include/aesnixx/data.hpp
@@ -28,9 +28,9 @@ namespace aesni
typedef AesNI_Aes256_RoundKeys KeySchedule256;
template <typename KeyScheduleT>
- inline std::size_t get_number_of_keys(const KeyScheduleT& key_schedule)
+ inline std::size_t get_number_of_keys(const KeyScheduleT& round_keys)
{
- return sizeof(key_schedule) / sizeof(Block128);
+ return sizeof(round_keys) / sizeof(Block128);
}
inline void make_block(Block128& dest, int hi3, int hi2, int lo1, int lo0)
diff --git a/include/aesni/aes.h b/include/aesni/aes.h
index dcee06b..6e11b0c 100644
--- a/include/aesni/aes.h
+++ b/include/aesni/aes.h
@@ -85,869 +85,783 @@ AesNI_Block128 __fastcall aesni_aes256_decrypt_block_(
AesNI_Block128 ciphertext,
const AesNI_Aes256_RoundKeys*);
-
-
-
/**
- * \brief Expands a key schedule for AES-128 encryption.
+ * \brief Expands an AES-128 key into 10 encryption round keys.
*
* \param[in] key The AES-128 key.
- * \param[out] key_schedule The AES-128 encryption key schedule. Must not be
- * `NULL`.
+ * \param[out] encryption_keys The AES-128 encryption round keys. Must not be `NULL`.
*/
static __inline void __fastcall aesni_aes128_expand_key(
AesNI_Block128 key,
- AesNI_Aes128_RoundKeys* key_schedule)
+ AesNI_Aes128_RoundKeys* encryption_keys)
{
- assert(key_schedule);
+ assert(encryption_keys);
- aesni_aes128_expand_key_(key, key_schedule);
+ aesni_aes128_expand_key_(key, encryption_keys);
}
/**
- * \brief "Inverts" an AES-128 key schedule to prepare for decryption.
+ * \brief Derives AES-128 decryption round keys from AES-128 encryption round keys.
*
- * \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`.
+ * \param[in] encryption_keys The AES-128 encryption round keys. Must not be `NULL`.
+ * \param[out] decryption_keys The AES-128 decryption round keys. Must not be `NULL`.
*/
static __inline void __fastcall aesni_aes128_derive_decryption_keys(
- const AesNI_Aes128_RoundKeys* key_schedule,
- AesNI_Aes128_RoundKeys* inverted_schedule)
+ const AesNI_Aes128_RoundKeys* encryption_keys,
+ AesNI_Aes128_RoundKeys* decryption_keys)
{
- assert(key_schedule);
- assert(inverted_schedule);
+ assert(encryption_keys);
+ assert(decryption_keys);
- aesni_aes128_derive_decryption_keys_(key_schedule, inverted_schedule);
+ aesni_aes128_derive_decryption_keys_(encryption_keys, decryption_keys);
}
/**
* \brief Encrypts a 128-bit block using AES-128 in ECB mode of operation.
*
- * \param[in] plain The plaintext to be encrypted.
- * \param[in] key_schedule The AES-128 encryption key schedule. Must not be
- * `NULL`.
+ * \param[in] plaintext The plaintext to be encrypted.
+ * \param[in] encryption_keys The AES-128 encryption round keys. Must not be `NULL`.
+ *
* \return The encrypted 128-bit ciphertext.
*/
static __inline AesNI_Block128 __fastcall aesni_aes128_encrypt_block_ecb(
- AesNI_Block128 plain,
- const AesNI_Aes128_RoundKeys* key_schedule)
+ AesNI_Block128 plaintext,
+ const AesNI_Aes128_RoundKeys* encryption_keys)
{
- assert(key_schedule);
+ assert(encryption_keys);
- return aesni_aes128_encrypt_block_(plain, key_schedule);
+ return aesni_aes128_encrypt_block_(plaintext, encryption_keys);
}
/**
* \brief Decrypts a 128-bit block using AES-128 in ECB mode of operation.
*
- * \param[in] cipher The ciphertext to be decrypted.
- * \param[in] inverted_schedule The AES-128 decryption key schedule. Must not
- * be `NULL`.
+ * \param[in] ciphertext The ciphertext to be decrypted.
+ * \param[in] decryption_keys The AES-128 decryption round keys. Must not be `NULL`.
+ *
* \return The decrypted 128-bit plaintext.
*/
static __inline AesNI_Block128 __fastcall aesni_aes128_decrypt_block_ecb(
- AesNI_Block128 cipher,
- const AesNI_Aes128_RoundKeys* inverted_schedule)
+ AesNI_Block128 ciphertext,
+ const AesNI_Aes128_RoundKeys* decryption_keys)
{
- assert(inverted_schedule);
+ assert(decryption_keys);
- return aesni_aes128_decrypt_block_(cipher, inverted_schedule);
+ return aesni_aes128_decrypt_block_(ciphertext, decryption_keys);
}
/**
* \brief Encrypts a 128-bit block using AES-128 in CBC mode of operation.
*
- * \param[in] plain The plaintext to be encrypted.
- * \param[in] key_schedule The AES-128 encryption key schedule. Must not be
- * `NULL`.
+ * \param[in] plaintext The plaintext to be encrypted.
+ * \param[in] encryption_keys The AES-128 encryption round keys. Must not be `NULL`.
* \param[in] init_vector The CBC initialization vector.
- * \param[out] next_init_vector The next CBC initialization vector to be used
- * as the initialization vector for the next call. Must not be `NULL`.
+ * \param[out] next_init_vector The initialization vector to be used for the next call. Must not be `NULL`.
+ *
* \return The encrypted 128-bit ciphertext.
*/
static __inline AesNI_Block128 __fastcall aesni_aes128_encrypt_block_cbc(
- AesNI_Block128 plain,
- const AesNI_Aes128_RoundKeys* key_schedule,
+ AesNI_Block128 plaintext,
+ const AesNI_Aes128_RoundKeys* encryption_keys,
AesNI_Block128 init_vector,
AesNI_Block128* next_init_vector)
{
- assert(key_schedule);
+ assert(encryption_keys);
assert(next_init_vector);
- AesNI_Block128 cipher = aesni_aes128_encrypt_block_(
- aesni_xor_block128(plain, init_vector),
- key_schedule);
- *next_init_vector = cipher;
- return cipher;
+ AesNI_Block128 ciphertext = aesni_aes128_encrypt_block_(aesni_xor_block128(plaintext, init_vector), encryption_keys);
+ *next_init_vector = ciphertext;
+ return ciphertext;
}
/**
* \brief Decrypts a 128-bit block using AES-128 in CBC mode of operation.
*
- * \param[in] cipher The ciphertext to be decrypted.
- * \param[in] inverted_schedule The AES-128 decryption key schedule. Must not
- * be `NULL`.
+ * \param[in] ciphertext The ciphertext to be decrypted.
+ * \param[in] decryption_keys The AES-128 decryption round keys. Must not be `NULL`.
* \param[in] init_vector The CBC initialization vector.
- * \param[out] next_init_vector The next CBC initialization vector to be used
- * as the initialization vector for the next call. Must not be `NULL`.
+ * \param[out] next_init_vector The initialization vector to be used for the next call. Must not be `NULL`.
+ *
* \return The decrypted 128-bit plaintext.
*/
static __inline AesNI_Block128 __fastcall aesni_aes128_decrypt_block_cbc(
- AesNI_Block128 cipher,
- const AesNI_Aes128_RoundKeys* inverted_schedule,
+ AesNI_Block128 ciphertext,
+ const AesNI_Aes128_RoundKeys* decryption_keys,
AesNI_Block128 init_vector,
AesNI_Block128* next_init_vector)
{
- assert(inverted_schedule);
+ assert(decryption_keys);
assert(next_init_vector);
- AesNI_Block128 plain = aesni_xor_block128(
- aesni_aes128_decrypt_block_(cipher, inverted_schedule),
- init_vector);
- *next_init_vector = cipher;
- return plain;
+ AesNI_Block128 plaintext = aesni_xor_block128(aesni_aes128_decrypt_block_(ciphertext, decryption_keys), init_vector);
+ *next_init_vector = ciphertext;
+ return plaintext;
}
/**
* \brief Encrypts a 128-bit block using AES-128 in CFB mode of operation.
*
- * \param[in] plain The plaintext to be encrypted.
- * \param[in] key_schedule The AES-128 encryption key schedule. Must not be
- * `NULL`.
+ * \param[in] plaintext The plaintext to be encrypted.
+ * \param[in] encryption_keys The AES-128 encryption round keys. Must not be `NULL`.
* \param[in] init_vector The CFB initialization vector.
- * \param[out] next_init_vector The next CFB initialization vector to be used
- * as the initialization vector for the next call. Must not be `NULL`.
+ * \param[out] next_init_vector The initialization vector to be used for the next call. Must not be `NULL`.
+ *
* \return The encrypted 128-bit ciphertext.
*/
static __inline AesNI_Block128 __fastcall aesni_aes128_encrypt_block_cfb(
- AesNI_Block128 plain,
- const AesNI_Aes128_RoundKeys* key_schedule,
+ AesNI_Block128 plaintext,
+ const AesNI_Aes128_RoundKeys* encryption_keys,
AesNI_Block128 init_vector,
AesNI_Block128* next_init_vector)
{
- assert(key_schedule);
+ assert(encryption_keys);
assert(next_init_vector);
- AesNI_Block128 cipher = aesni_xor_block128(
- aesni_aes128_encrypt_block_(init_vector, key_schedule),
- plain);
- *next_init_vector = cipher;
- return cipher;
+ AesNI_Block128 ciphertext = aesni_xor_block128(aesni_aes128_encrypt_block_(init_vector, encryption_keys), plaintext);
+ *next_init_vector = ciphertext;
+ return ciphertext;
}
/**
* \brief Decrypts a 128-bit block using AES-128 in CFB mode of operation.
*
- * \param[in] cipher The ciphertext to be decrypted.
- * \param[in] key_schedule The AES-128 **encryption** key schedule. Must not be
- * `NULL`.
+ * \param[in] ciphertext The ciphertext to be decrypted.
+ * \param[in] encryption_keys The AES-128 **encryption** round keys. Must not be `NULL`.
* \param[in] init_vector The CFB initialization vector.
- * \param[out] next_init_vector The next CFB initialization vector to be used
- * as the initialization vector for the next call. Must not be `NULL`.
+ * \param[out] next_init_vector The initialization vector to be used for the next call. Must not be `NULL`.
+ *
* \return The decrypted 128-bit plaintext.
*/
static __inline AesNI_Block128 __fastcall aesni_aes128_decrypt_block_cfb(
- AesNI_Block128 cipher,
- const AesNI_Aes128_RoundKeys* key_schedule,
+ AesNI_Block128 ciphertext,
+ const AesNI_Aes128_RoundKeys* encryption_keys,
AesNI_Block128 init_vector,
AesNI_Block128* next_init_vector)
{
- assert(key_schedule);
+ assert(encryption_keys);
assert(next_init_vector);
- AesNI_Block128 plain = aesni_xor_block128(
- aesni_aes128_encrypt_block_(init_vector, key_schedule),
- cipher);
- *next_init_vector = cipher;
- return plain;
+ AesNI_Block128 plaintext = aesni_xor_block128(aesni_aes128_encrypt_block_(init_vector, encryption_keys), ciphertext);
+ *next_init_vector = ciphertext;
+ return plaintext;
}
/**
* \brief Encrypts a 128-bit block using AES-128 in OFB mode of operation.
*
- * \param[in] plain The plaintext to be encrypted.
- * \param[in] key_schedule The AES-128 encryption key schedule. Must not be
- * `NULL`.
+ * \param[in] plaintext The plaintext to be encrypted.
+ * \param[in] encryption_keys The AES-128 encryption round keys. Must not be `NULL`.
* \param[in] init_vector The OFB initialization vector.
- * \param[out] next_init_vector The next OFB initialization vector to be used
- * as the initialization vector for the next call. Must not be `NULL`.
+ * \param[out] next_init_vector The initialization vector to be used for the next call. Must not be `NULL`.
+ *
* \return The encrypted 128-bit ciphertext.
*/
static __inline AesNI_Block128 __fastcall aesni_aes128_encrypt_block_ofb(
- AesNI_Block128 plain,
- const AesNI_Aes128_RoundKeys* key_schedule,
+ AesNI_Block128 plaintext,
+ const AesNI_Aes128_RoundKeys* encryption_keys,
AesNI_Block128 init_vector,
AesNI_Block128* next_init_vector)
{
- assert(key_schedule);
+ assert(encryption_keys);
assert(next_init_vector);
- AesNI_Block128 tmp = aesni_aes128_encrypt_block_(init_vector, key_schedule);
+ AesNI_Block128 tmp = aesni_aes128_encrypt_block_(init_vector, encryption_keys);
*next_init_vector = tmp;
- return aesni_xor_block128(tmp, plain);
+ return aesni_xor_block128(tmp, plaintext);
}
/**
* \brief Decrypts a 128-bit block using AES-128 in OFB mode of operation.
*
- * \param[in] cipher The ciphertext to be decrypted.
- * \param[in] key_schedule The AES-128 **encryption** key schedule. Must not be
- * `NULL`.
+ * \param[in] ciphertext The ciphertext to be decrypted.
+ * \param[in] encryption_keys The AES-128 **encryption** round keys. Must not be `NULL`.
* \param[in] init_vector The OFB initialization vector.
- * \param[out] next_init_vector The next OFB initialization vector to be used
- * as the initialization vector for the next call. Must not be `NULL`.
+ * \param[out] next_init_vector The initialization vector to be used for the next call. Must not be `NULL`.
+ *
* \return The decrypted 128-bit plaintext.
*/
static __inline AesNI_Block128 __fastcall aesni_aes128_decrypt_block_ofb(
- AesNI_Block128 cipher,
- const AesNI_Aes128_RoundKeys* key_schedule,
+ AesNI_Block128 ciphertext,
+ const AesNI_Aes128_RoundKeys* encryption_keys,
AesNI_Block128 init_vector,
AesNI_Block128* next_init_vector)
{
- assert(key_schedule);
+ assert(encryption_keys);
assert(next_init_vector);
- AesNI_Block128 tmp = aesni_aes128_encrypt_block_(init_vector, key_schedule);
+ AesNI_Block128 tmp = aesni_aes128_encrypt_block_(init_vector, encryption_keys);
*next_init_vector = tmp;
- return aesni_xor_block128(tmp, cipher);
+ return aesni_xor_block128(tmp, ciphertext);
}
/**
* \brief Encrypts a 128-bit block using AES-128 in CTR mode of operation.
*
- * \param[in] plain The plaintext to be encrypted.
- * \param[in] key_schedule The AES-128 encryption key schedule. Must not be
- * `NULL`.
+ * \param[in] plaintext The plaintext to be encrypted.
+ * \param[in] encryption_keys The AES-128 encryption round keys. Must not be `NULL`.
* \param[in] init_vector The CTR initialization vector.
- * \param[in] counter The counter, typically incremented between consecutive
- * calls.
+ * \param[in] counter The counter, typically incremented between consecutive calls.
+ *
* \return The encrypted 128-bit ciphertext.
*/
static __inline AesNI_Block128 __fastcall aesni_aes128_encrypt_block_ctr(
- AesNI_Block128 plain,
- const AesNI_Aes128_RoundKeys* key_schedule,
+ AesNI_Block128 plaintext,
+ const AesNI_Aes128_RoundKeys* encryption_keys,
AesNI_Block128 init_vector,
int counter)
{
- assert(key_schedule);
+ assert(encryption_keys);
- init_vector = aesni_be2le128(_mm_add_epi32(
- aesni_le2be128(init_vector),
- aesni_make_block128(0, 0, 0, counter)));
+ init_vector = aesni_le2be128(init_vector);
+ init_vector = _mm_add_epi32(init_vector, aesni_make_block128(0, 0, 0, counter));
+ init_vector = aesni_be2le128(init_vector);
- return aesni_xor_block128(
- plain,
- aesni_aes128_encrypt_block_(init_vector, key_schedule));
+ return aesni_xor_block128(plaintext, aesni_aes128_encrypt_block_(init_vector, encryption_keys));
}
/**
* \brief Decrypts a 128-bit block using AES-128 in CTR mode of operation.
*
- * \param[in] cipher The ciphertext to be decrypted.
- * \param[in] key_schedule The AES-128 **encryption** key schedule. Must not be
- * `NULL`.
+ * \param[in] ciphertext The ciphertext to be decrypted.
+ * \param[in] encryption_keys The AES-128 **encryption** round keys. Must not be `NULL`.
* \param[in] init_vector The CTR initialization vector.
- * \param[in] counter The counter, typically incremented between consecutive
- * calls.
+ * \param[in] counter The counter, typically incremented between consecutive calls.
+ *
* \return The decrypted 128-bit plaintext.
*/
static __inline AesNI_Block128 __fastcall aesni_aes128_decrypt_block_ctr(
- AesNI_Block128 cipher,
- const AesNI_Aes128_RoundKeys* key_schedule,
+ AesNI_Block128 ciphertext,
+ const AesNI_Aes128_RoundKeys* encryption_keys,
AesNI_Block128 init_vector,
int counter)
{
- assert(key_schedule);
+ assert(encryption_keys);
- init_vector = aesni_be2le128(_mm_add_epi32(
- aesni_le2be128(init_vector),
- aesni_make_block128(0, 0, 0, counter)));
+ init_vector = aesni_le2be128(init_vector);
+ init_vector = _mm_add_epi32(init_vector, aesni_make_block128(0, 0, 0, counter));
+ init_vector = aesni_be2le128(init_vector);
- return aesni_xor_block128(
- cipher,
- aesni_aes128_encrypt_block_(init_vector, key_schedule));
+ return aesni_xor_block128(ciphertext, aesni_aes128_encrypt_block_(init_vector, encryption_keys));
}
/**
- * \}
- *
- * \defgroup aesni_block_api_aes192 AES-192
- * \{
- */
-
-/**
- * \brief Expands a key schedule for AES-192 encryption.
+ * \brief Expands an AES-192 key into 12 encryption round keys.
*
- * \param[in] key The AES-192 key. Must not be `NULL`.
- * \param[out] key_schedule The AES-192 encryption key schedule. Must not be
- * `NULL`.
+ * \param[in] key The AES-192 key.
+ * \param[out] encryption_keys The AES-192 encryption round keys. Must not be `NULL`.
*/
static __inline void __fastcall aesni_aes192_expand_key(
AesNI_Block192* key,
- AesNI_Aes192_RoundKeys* key_schedule)
+ AesNI_Aes192_RoundKeys* encryption_keys)
{
assert(key);
- assert(key_schedule);
+ assert(encryption_keys);
- aesni_aes192_expand_key_(key->lo, key->hi, key_schedule);
+ aesni_aes192_expand_key_(key->lo, key->hi, encryption_keys);
}
/**
- * \brief "Inverts" an AES-192 key schedule to prepare for decryption.
+ * \brief Derives AES-192 decryption round keys from AES-192 encryption round keys.
*
- * \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`.
+ * \param[in] encryption_keys The AES-192 encryption round keys. Must not be `NULL`.
+ * \param[out] decryption_keys The AES-192 decryption round keys. Must not be `NULL`.
*/
static __inline void __fastcall aesni_aes192_derive_decryption_keys(
- const AesNI_Aes192_RoundKeys* key_schedule,
- AesNI_Aes192_RoundKeys* inverted_schedule)
+ const AesNI_Aes192_RoundKeys* encryption_keys,
+ AesNI_Aes192_RoundKeys* decryption_keys)
{
- assert(key_schedule);
- assert(inverted_schedule);
+ assert(encryption_keys);
+ assert(decryption_keys);
- aesni_aes192_derive_decryption_keys_(key_schedule, inverted_schedule);
+ aesni_aes192_derive_decryption_keys_(encryption_keys, decryption_keys);
}
/**
* \brief Encrypts a 128-bit block using AES-192 in ECB mode of operation.
*
- * \param[in] plain The plaintext to be encrypted.
- * \param[in] key_schedule The AES-192 encryption key schedule. Must not be
- * `NULL`.
+ * \param[in] plaintext The plaintext to be encrypted.
+ * \param[in] encryption_keys The AES-192 encryption round keys. Must not be `NULL`.
+ *
* \return The encrypted 128-bit ciphertext.
*/
static __inline AesNI_Block128 __fastcall aesni_aes192_encrypt_block_ecb(
- AesNI_Block128 plain,
- const AesNI_Aes192_RoundKeys* key_schedule)
+ AesNI_Block128 plaintext,
+ const AesNI_Aes192_RoundKeys* encryption_keys)
{
- assert(key_schedule);
+ assert(encryption_keys);
- return aesni_aes192_encrypt_block_(plain, key_schedule);
+ return aesni_aes192_encrypt_block_(plaintext, encryption_keys);
}
/**
* \brief Decrypts a 128-bit block using AES-192 in ECB mode of operation.
*
- * \param[in] cipher The ciphertext to be decrypted.
- * \param[in] inverted_schedule The AES-192 decryption key schedule. Must not
- * be `NULL`.
+ * \param[in] ciphertext The ciphertext to be decrypted.
+ * \param[in] decryption_keys The AES-192 decryption round keys. Must not be `NULL`.
+ *
* \return The decrypted 128-bit plaintext.
*/
static __inline AesNI_Block128 __fastcall aesni_aes192_decrypt_block_ecb(
- AesNI_Block128 cipher,
- const AesNI_Aes192_RoundKeys* inverted_schedule)
+ AesNI_Block128 ciphertext,
+ const AesNI_Aes192_RoundKeys* decryption_keys)
{
- assert(inverted_schedule);
+ assert(decryption_keys);
- return aesni_aes192_decrypt_block_(cipher, inverted_schedule);
+ return aesni_aes192_decrypt_block_(ciphertext, decryption_keys);
}
/**
* \brief Encrypts a 128-bit block using AES-192 in CBC mode of operation.
*
- * \param[in] plain The plaintext to be encrypted.
- * \param[in] key_schedule The AES-192 encryption key schedule. Must not be
- * `NULL`.
+ * \param[in] plaintext The plaintext to be encrypted.
+ * \param[in] encryption_keys The AES-192 encryption round keys. Must not be `NULL`.
* \param[in] init_vector The CBC initialization vector.
- * \param[out] next_init_vector The next CBC initialization vector to be used
- * as the initialization vector for the next call. Must not be `NULL`.
+ * \param[out] next_init_vector The initialization vector to be used for the next call. Must not be `NULL`.
+ *
* \return The encrypted 128-bit ciphertext.
*/
static __inline AesNI_Block128 __fastcall aesni_aes192_encrypt_block_cbc(
- AesNI_Block128 plain,
- const AesNI_Aes192_RoundKeys* key_schedule,
+ AesNI_Block128 plaintext,
+ const AesNI_Aes192_RoundKeys* encryption_keys,
AesNI_Block128 init_vector,
AesNI_Block128* next_init_vector)
{
- assert(key_schedule);
+ assert(encryption_keys);
assert(next_init_vector);
- AesNI_Block128 cipher = aesni_aes192_encrypt_block_(
- aesni_xor_block128(plain, init_vector),
- key_schedule);
- *next_init_vector = cipher;
- return cipher;
+ AesNI_Block128 ciphertext = aesni_aes192_encrypt_block_(aesni_xor_block128(plaintext, init_vector), encryption_keys);
+ *next_init_vector = ciphertext;
+ return ciphertext;
}
/**
* \brief Decrypts a 128-bit block using AES-192 in CBC mode of operation.
*
- * \param[in] cipher The ciphertext to be decrypted.
- * \param[in] inverted_schedule The AES-192 decryption key schedule. Must not
- * be `NULL`.
+ * \param[in] ciphertext The ciphertext to be decrypted.
+ * \param[in] decryption_keys The AES-192 decryption round keys. Must not be `NULL`.
* \param[in] init_vector The CBC initialization vector.
- * \param[out] next_init_vector The next CBC initialization vector to be used
- * as the initialization vector for the next call. Must not be `NULL`.
+ * \param[out] next_init_vector The initialization vector to be used for the next call. Must not be `NULL`.
+ *
* \return The decrypted 128-bit plaintext.
*/
static __inline AesNI_Block128 __fastcall aesni_aes192_decrypt_block_cbc(
- AesNI_Block128 cipher,
- const AesNI_Aes192_RoundKeys* inverted_schedule,
+ AesNI_Block128 ciphertext,
+ const AesNI_Aes192_RoundKeys* decryption_keys,
AesNI_Block128 init_vector,
AesNI_Block128* next_init_vector)
{
- assert(inverted_schedule);
+ assert(decryption_keys);
assert(next_init_vector);
- AesNI_Block128 plain = aesni_xor_block128(
- aesni_aes192_decrypt_block_(cipher, inverted_schedule),
- init_vector);
- *next_init_vector = cipher;
- return plain;
+ AesNI_Block128 plaintext = aesni_xor_block128(aesni_aes192_decrypt_block_(ciphertext, decryption_keys), init_vector);
+ *next_init_vector = ciphertext;
+ return plaintext;
}
/**
* \brief Encrypts a 128-bit block using AES-192 in CFB mode of operation.
*
- * \param[in] plain The plaintext to be encrypted.
- * \param[in] key_schedule The AES-192 encryption key schedule. Must not be
- * `NULL`.
+ * \param[in] plaintext The plaintext to be encrypted.
+ * \param[in] encryption_keys The AES-192 encryption round keys. Must not be `NULL`.
* \param[in] init_vector The CFB initialization vector.
- * \param[out] next_init_vector The next CFB initialization vector to be used
- * as the initialization vector for the next call. Must not be `NULL`.
+ * \param[out] next_init_vector The initialization vector to be used for the next call. Must not be `NULL`.
+ *
* \return The encrypted 128-bit ciphertext.
*/
static __inline AesNI_Block128 __fastcall aesni_aes192_encrypt_block_cfb(
- AesNI_Block128 plain,
- const AesNI_Aes192_RoundKeys* key_schedule,
+ AesNI_Block128 plaintext,
+ const AesNI_Aes192_RoundKeys* encryption_keys,
AesNI_Block128 init_vector,
AesNI_Block128* next_init_vector)
{
- assert(key_schedule);
+ assert(encryption_keys);
assert(next_init_vector);
- AesNI_Block128 cipher = aesni_xor_block128(
- aesni_aes192_encrypt_block_(init_vector, key_schedule),
- plain);
- *next_init_vector = cipher;
- return cipher;
+ AesNI_Block128 ciphertext = aesni_xor_block128(aesni_aes192_encrypt_block_(init_vector, encryption_keys), plaintext);
+ *next_init_vector = ciphertext;
+ return ciphertext;
}
/**
* \brief Decrypts a 128-bit block using AES-192 in CFB mode of operation.
*
- * \param[in] cipher The ciphertext to be decrypted.
- * \param[in] key_schedule The AES-192 **encryption** key schedule. Must not be
- * `NULL`.
+ * \param[in] ciphertext The ciphertext to be decrypted.
+ * \param[in] encryption_keys The AES-192 **encryption** round keys. Must not be `NULL`.
* \param[in] init_vector The CFB initialization vector.
- * \param[out] next_init_vector The next CFB initialization vector to be used
- * as the initialization vector for the next call. Must not be `NULL`.
+ * \param[out] next_init_vector The initialization vector to be used for the next call. Must not be `NULL`.
+ *
* \return The decrypted 128-bit plaintext.
*/
static __inline AesNI_Block128 __fastcall aesni_aes192_decrypt_block_cfb(
- AesNI_Block128 cipher,
- const AesNI_Aes192_RoundKeys* key_schedule,
+ AesNI_Block128 ciphertext,
+ const AesNI_Aes192_RoundKeys* encryption_keys,
AesNI_Block128 init_vector,
AesNI_Block128* next_init_vector)
{
- assert(key_schedule);
+ assert(encryption_keys);
assert(next_init_vector);
- AesNI_Block128 plain = aesni_xor_block128(
- aesni_aes192_encrypt_block_(init_vector, key_schedule),
- cipher);
- *next_init_vector = cipher;
- return plain;
+ AesNI_Block128 plaintext = aesni_xor_block128(aesni_aes192_encrypt_block_(init_vector, encryption_keys), ciphertext);
+ *next_init_vector = ciphertext;
+ return plaintext;
}
/**
* \brief Encrypts a 128-bit block using AES-192 in OFB mode of operation.
*
- * \param[in] plain The plaintext to be encrypted.
- * \param[in] key_schedule The AES-192 encryption key schedule. Must not be
- * `NULL`.
+ * \param[in] plaintext The plaintext to be encrypted.
+ * \param[in] encryption_keys The AES-192 encryption round keys. Must not be `NULL`.
* \param[in] init_vector The OFB initialization vector.
- * \param[out] next_init_vector The next OFB initialization vector to be used
- * as the initialization vector for the next call. Must not be `NULL`.
+ * \param[out] next_init_vector The initialization vector to be used for the next call. Must not be `NULL`.
+ *
* \return The encrypted 128-bit ciphertext.
*/
static __inline AesNI_Block128 __fastcall aesni_aes192_encrypt_block_ofb(
- AesNI_Block128 plain,
- const AesNI_Aes192_RoundKeys* key_schedule,
+ AesNI_Block128 plaintext,
+ const AesNI_Aes192_RoundKeys* encryption_keys,
AesNI_Block128 init_vector,
AesNI_Block128* next_init_vector)
{
- assert(key_schedule);
+ assert(encryption_keys);
assert(next_init_vector);
- AesNI_Block128 tmp = aesni_aes192_encrypt_block_(init_vector, key_schedule);
+ AesNI_Block128 tmp = aesni_aes192_encrypt_block_(init_vector, encryption_keys);
*next_init_vector = tmp;
- return aesni_xor_block128(tmp, plain);
+ return aesni_xor_block128(tmp, plaintext);
}
/**
* \brief Decrypts a 128-bit block using AES-192 in OFB mode of operation.
*
- * \param[in] cipher The ciphertext to be decrypted.
- * \param[in] key_schedule The AES-192 **encryption** key schedule. Must not be
- * `NULL`.
+ * \param[in] ciphertext The ciphertext to be decrypted.
+ * \param[in] encryption_keys The AES-192 **encryption** round keys. Must not be `NULL`.
* \param[in] init_vector The OFB initialization vector.
- * \param[out] next_init_vector The next OFB initialization vector to be used
- * as the initialization vector for the next call. Must not be `NULL`.
+ * \param[out] next_init_vector The initialization vector to be used for the next call. Must not be `NULL`.
+ *
* \return The decrypted 128-bit plaintext.
*/
static __inline AesNI_Block128 __fastcall aesni_aes192_decrypt_block_ofb(
- AesNI_Block128 cipher,
- const AesNI_Aes192_RoundKeys* key_schedule,
+ AesNI_Block128 ciphertext,
+ const AesNI_Aes192_RoundKeys* encryption_keys,
AesNI_Block128 init_vector,
AesNI_Block128* next_init_vector)
{
- assert(key_schedule);
+ assert(encryption_keys);
assert(next_init_vector);
- AesNI_Block128 tmp = aesni_aes192_encrypt_block_(init_vector, key_schedule);
+ AesNI_Block128 tmp = aesni_aes192_encrypt_block_(init_vector, encryption_keys);
*next_init_vector = tmp;
- return aesni_xor_block128(tmp, cipher);
+ return aesni_xor_block128(tmp, ciphertext);
}
/**
* \brief Encrypts a 128-bit block using AES-192 in CTR mode of operation.
*
- * \param[in] plain The plaintext to be encrypted.
- * \param[in] key_schedule The AES-192 encryption key schedule. Must not be
- * `NULL`.
+ * \param[in] plaintext The plaintext to be encrypted.
+ * \param[in] encryption_keys The AES-192 encryption round keys. Must not be `NULL`.
* \param[in] init_vector The CTR initialization vector.
- * \param[in] counter The counter, typically incremented between consecutive
- * calls.
+ * \param[in] counter The counter, typically incremented between consecutive calls.
+ *
* \return The encrypted 128-bit ciphertext.
*/
static __inline AesNI_Block128 __fastcall aesni_aes192_encrypt_block_ctr(
- AesNI_Block128 plain,
- const AesNI_Aes192_RoundKeys* key_schedule,
+ AesNI_Block128 plaintext,
+ const AesNI_Aes192_RoundKeys* encryption_keys,
AesNI_Block128 init_vector,
int counter)
{
- assert(key_schedule);
+ assert(encryption_keys);
- init_vector = aesni_be2le128(_mm_add_epi32(
- aesni_le2be128(init_vector),
- aesni_make_block128(0, 0, 0, counter)));
+ init_vector = aesni_le2be128(init_vector);
+ init_vector = _mm_add_epi32(init_vector, aesni_make_block128(0, 0, 0, counter));
+ init_vector = aesni_be2le128(init_vector);
- return aesni_xor_block128(
- plain,
- aesni_aes192_encrypt_block_(init_vector, key_schedule));
+ return aesni_xor_block128(plaintext, aesni_aes192_encrypt_block_(init_vector, encryption_keys));
}
/**
* \brief Decrypts a 128-bit block using AES-192 in CTR mode of operation.
*
- * \param[in] cipher The ciphertext to be decrypted.
- * \param[in] key_schedule The AES-192 **encryption** key schedule. Must not be
- * `NULL`.
+ * \param[in] ciphertext The ciphertext to be decrypted.
+ * \param[in] encryption_keys The AES-192 **encryption** round keys. Must not be `NULL`.
* \param[in] init_vector The CTR initialization vector.
- * \param[in] counter The counter, typically incremented between consecutive
- * calls.
+ * \param[in] counter The counter, typically incremented between consecutive calls.
+ *
* \return The decrypted 128-bit plaintext.
*/
static __inline AesNI_Block128 __fastcall aesni_aes192_decrypt_block_ctr(
- AesNI_Block128 cipher,
- const AesNI_Aes192_RoundKeys* key_schedule,
+ AesNI_Block128 ciphertext,
+ const AesNI_Aes192_RoundKeys* encryption_keys,
AesNI_Block128 init_vector,
int counter)
{
- assert(key_schedule);
+ assert(encryption_keys);
- init_vector = aesni_be2le128(_mm_add_epi32(
- aesni_le2be128(init_vector),
- aesni_make_block128(0, 0, 0, counter)));
+ init_vector = aesni_le2be128(init_vector);
+ init_vector = _mm_add_epi32(init_vector, aesni_make_block128(0, 0, 0, counter));
+ init_vector = aesni_be2le128(init_vector);
- return aesni_xor_block128(
- cipher,
- aesni_aes192_encrypt_block_(init_vector, key_schedule));
+ return aesni_xor_block128(ciphertext, aesni_aes192_encrypt_block_(init_vector, encryption_keys));
}
/**
- * \}
- *
- * \defgroup aesni_block_api_aes256 AES-256
- * \{
- */
-
-/**
- * \brief Expands a key schedule for AES-256 encryption.
+ * \brief Expands an AES-256 key into 14 encryption round keys.
*
- * \param[in] key The AES-256 key. Must not be `NULL`.
- * \param[out] key_schedule The AES-256 encryption key schedule. Must not be
- * `NULL`.
+ * \param[in] key The AES-256 key.
+ * \param[out] encryption_keys The AES-256 encryption round keys. Must not be `NULL`.
*/
static __inline void __fastcall aesni_aes256_expand_key(
const AesNI_Block256* key,
- AesNI_Aes256_RoundKeys* key_schedule)
+ AesNI_Aes256_RoundKeys* encryption_keys)
{
assert(key);
- assert(key_schedule);
+ assert(encryption_keys);
- aesni_aes256_expand_key_(key->lo, key->hi, key_schedule);
+ aesni_aes256_expand_key_(key->lo, key->hi, encryption_keys);
}
/**
- * \brief "Inverts" an AES-256 key schedule to prepare for decryption.
+ * \brief Derives AES-256 decryption round keys from AES-256 encryption round keys.
*
- * \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`.
+ * \param[in] encryption_keys The AES-256 encryption round keys. Must not be `NULL`.
+ * \param[out] decryption_keys The AES-256 decryption round keys. Must not be `NULL`.
*/
static __inline void __fastcall aesni_aes256_derive_decryption_keys(
- const AesNI_Aes256_RoundKeys* key_schedule,
- AesNI_Aes256_RoundKeys* inverted_schedule)
+ const AesNI_Aes256_RoundKeys* encryption_keys,
+ AesNI_Aes256_RoundKeys* decryption_keys)
{
- assert(key_schedule);
- assert(inverted_schedule);
+ assert(encryption_keys);
+ assert(decryption_keys);
- aesni_aes256_derive_decryption_keys_(key_schedule, inverted_schedule);
+ aesni_aes256_derive_decryption_keys_(encryption_keys, decryption_keys);
}
/**
* \brief Encrypts a 128-bit block using AES-256 in ECB mode of operation.
*
- * \param[in] plain The plaintext to be encrypted.
- * \param[in] key_schedule The AES-256 encryption key schedule. Must not be
- * `NULL`.
+ * \param[in] plaintext The plaintext to be encrypted.
+ * \param[in] encryption_keys The AES-256 encryption round keys. Must not be `NULL`.
+ *
* \return The encrypted 128-bit ciphertext.
*/
static __inline AesNI_Block128 __fastcall aesni_aes256_encrypt_block_ecb(
- AesNI_Block128 plain,
- const AesNI_Aes256_RoundKeys* key_schedule)
+ AesNI_Block128 plaintext,
+ const AesNI_Aes256_RoundKeys* encryption_keys)
{
- assert(key_schedule);
+ assert(encryption_keys);
- return aesni_aes256_encrypt_block_(plain, key_schedule);
+ return aesni_aes256_encrypt_block_(plaintext, encryption_keys);
}
/**
* \brief Decrypts a 128-bit block using AES-256 in ECB mode of operation.
*
- * \param[in] cipher The ciphertext to be decrypted.
- * \param[in] inverted_schedule The AES-256 decryption key schedule. Must not
- * be `NULL`.
+ * \param[in] ciphertext The ciphertext to be decrypted.
+ * \param[in] decryption_keys The AES-256 decryption round keys. Must not be `NULL`.
+ *
* \return The decrypted 128-bit plaintext.
*/
static __inline AesNI_Block128 __fastcall aesni_aes256_decrypt_block_ecb(
- AesNI_Block128 cipher,
- const AesNI_Aes256_RoundKeys* inverted_schedule)
+ AesNI_Block128 ciphertext,
+ const AesNI_Aes256_RoundKeys* decryption_keys)
{
- assert(inverted_schedule);
+ assert(decryption_keys);
- return aesni_aes256_decrypt_block_(cipher, inverted_schedule);
+ return aesni_aes256_decrypt_block_(ciphertext, decryption_keys);
}
/**
* \brief Encrypts a 128-bit block using AES-256 in CBC mode of operation.
*
- * \param[in] plain The plaintext to be encrypted.
- * \param[in] key_schedule The AES-256 encryption key schedule. Must not be
- * `NULL`.
+ * \param[in] plaintext The plaintext to be encrypted.
+ * \param[in] encryption_keys The AES-256 encryption round keys. Must not be `NULL`.
* \param[in] init_vector The CBC initialization vector.
- * \param[out] next_init_vector The next CBC initialization vector to be used
- * as the initialization vector for the next call. Must not be `NULL`.
+ * \param[out] next_init_vector The initialization vector to be used for the next call. Must not be `NULL`.
+ *
* \return The encrypted 128-bit ciphertext.
*/
static __inline AesNI_Block128 __fastcall aesni_aes256_encrypt_block_cbc(
- AesNI_Block128 plain,
- const AesNI_Aes256_RoundKeys* key_schedule,
+ AesNI_Block128 plaintext,
+ const AesNI_Aes256_RoundKeys* encryption_keys,
AesNI_Block128 init_vector,
AesNI_Block128* next_init_vector)
{
- assert(key_schedule);
+ assert(encryption_keys);
assert(next_init_vector);
- AesNI_Block128 cipher = aesni_aes256_encrypt_block_(
- aesni_xor_block128(plain, init_vector),
- key_schedule);
- *next_init_vector = cipher;
- return cipher;
+ AesNI_Block128 ciphertext = aesni_aes256_encrypt_block_(aesni_xor_block128(plaintext, init_vector), encryption_keys);
+ *next_init_vector = ciphertext;
+ return ciphertext;
}
/**
* \brief Decrypts a 128-bit block using AES-256 in CBC mode of operation.
*
- * \param[in] cipher The ciphertext to be decrypted.
- * \param[in] inverted_schedule The AES-256 decryption key schedule. Must not
- * be `NULL`.
+ * \param[in] ciphertext The ciphertext to be decrypted.
+ * \param[in] decryption_keys The AES-256 decryption round keys. Must not be `NULL`.
* \param[in] init_vector The CBC initialization vector.
- * \param[out] next_init_vector The next CBC initialization vector to be used
- * as the initialization vector for the next call. Must not be `NULL`.
+ * \param[out] next_init_vector The initialization vector to be used for the next call. Must not be `NULL`.
+ *
* \return The decrypted 128-bit plaintext.
*/
static __inline AesNI_Block128 __fastcall aesni_aes256_decrypt_block_cbc(
- AesNI_Block128 cipher,
- const AesNI_Aes256_RoundKeys* inverted_schedule,
+ AesNI_Block128 ciphertext,
+ const AesNI_Aes256_RoundKeys* decryption_keys,
AesNI_Block128 init_vector,
AesNI_Block128* next_init_vector)
{
- assert(inverted_schedule);
+ assert(decryption_keys);
assert(next_init_vector);
- AesNI_Block128 plain = aesni_xor_block128(
- aesni_aes256_decrypt_block_(cipher, inverted_schedule),
- init_vector);
- *next_init_vector = cipher;
- return plain;
+ AesNI_Block128 plaintext = aesni_xor_block128(aesni_aes256_decrypt_block_(ciphertext, decryption_keys), init_vector);
+ *next_init_vector = ciphertext;
+ return plaintext;
}
/**
* \brief Encrypts a 128-bit block using AES-256 in CFB mode of operation.
*
- * \param[in] plain The plaintext to be encrypted.
- * \param[in] key_schedule The AES-256 encryption key schedule. Must not be
- * `NULL`.
+ * \param[in] plaintext The plaintext to be encrypted.
+ * \param[in] encryption_keys The AES-256 encryption round keys. Must not be `NULL`.
* \param[in] init_vector The CFB initialization vector.
- * \param[out] next_init_vector The next CFB initialization vector to be used
- * as the initialization vector for the next call. Must not be `NULL`.
+ * \param[out] next_init_vector The initialization vector to be used for the next call. Must not be `NULL`.
+ *
* \return The encrypted 128-bit ciphertext.
*/
static __inline AesNI_Block128 __fastcall aesni_aes256_encrypt_block_cfb(
- AesNI_Block128 plain,
- const AesNI_Aes256_RoundKeys* key_schedule,
+ AesNI_Block128 plaintext,
+ const AesNI_Aes256_RoundKeys* encryption_keys,
AesNI_Block128 init_vector,
AesNI_Block128* next_init_vector)
{
- assert(key_schedule);
+ assert(encryption_keys);
assert(next_init_vector);
- AesNI_Block128 cipher = aesni_xor_block128(
- aesni_aes256_encrypt_block_(init_vector, key_schedule),
- plain);
- *next_init_vector = cipher;
- return cipher;
+ AesNI_Block128 ciphertext = aesni_xor_block128(aesni_aes256_encrypt_block_(init_vector, encryption_keys), plaintext);
+ *next_init_vector = ciphertext;
+ return ciphertext;
}
/**
* \brief Decrypts a 128-bit block using AES-256 in CFB mode of operation.
*
- * \param[in] cipher The ciphertext to be decrypted.
- * \param[in] key_schedule The AES-256 **encryption** key schedule. Must not be
- * `NULL`.
+ * \param[in] ciphertext The ciphertext to be decrypted.
+ * \param[in] encryption_keys The AES-256 **encryption** round keys. Must not be `NULL`.
* \param[in] init_vector The CFB initialization vector.
- * \param[out] next_init_vector The next CFB initialization vector to be used
- * as the initialization vector for the next call. Must not be `NULL`.
+ * \param[out] next_init_vector The initialization vector to be used for the next call. Must not be `NULL`.
+ *
* \return The decrypted 128-bit plaintext.
*/
static __inline AesNI_Block128 __fastcall aesni_aes256_decrypt_block_cfb(
- AesNI_Block128 cipher,
- const AesNI_Aes256_RoundKeys* key_schedule,
+ AesNI_Block128 ciphertext,
+ const AesNI_Aes256_RoundKeys* encryption_keys,
AesNI_Block128 init_vector,
AesNI_Block128* next_init_vector)
{
- assert(key_schedule);
+ assert(encryption_keys);
assert(next_init_vector);
- AesNI_Block128 plain = aesni_xor_block128(
- aesni_aes256_encrypt_block_(init_vector, key_schedule),
- cipher);
- *next_init_vector = cipher;
- return plain;
+ AesNI_Block128 plaintext = aesni_xor_block128(aesni_aes256_encrypt_block_(init_vector, encryption_keys), ciphertext);
+ *next_init_vector = ciphertext;
+ return plaintext;
}
/**
* \brief Encrypts a 128-bit block using AES-256 in OFB mode of operation.
*
- * \param[in] plain The plaintext to be encrypted.
- * \param[in] key_schedule The AES-256 encryption key schedule. Must not be
- * `NULL`.
+ * \param[in] plaintext The plaintext to be encrypted.
+ * \param[in] encryption_keys The AES-256 encryption round keys. Must not be `NULL`.
* \param[in] init_vector The OFB initialization vector.
- * \param[out] next_init_vector The next OFB initialization vector to be used
- * as the initialization vector for the next call. Must not be `NULL`.
+ * \param[out] next_init_vector The initialization vector to be used for the next call. Must not be `NULL`.
+ *
* \return The encrypted 128-bit ciphertext.
*/
static __inline AesNI_Block128 __fastcall aesni_aes256_encrypt_block_ofb(
- AesNI_Block128 plain,
- const AesNI_Aes256_RoundKeys* key_schedule,
+ AesNI_Block128 plaintext,
+ const AesNI_Aes256_RoundKeys* encryption_keys,
AesNI_Block128 init_vector,
AesNI_Block128* next_init_vector)
{
- assert(key_schedule);
+ assert(encryption_keys);
assert(next_init_vector);
- AesNI_Block128 tmp = aesni_aes256_encrypt_block_(init_vector, key_schedule);
+ AesNI_Block128 tmp = aesni_aes256_encrypt_block_(init_vector, encryption_keys);
*next_init_vector = tmp;
- return aesni_xor_block128(tmp, plain);
+ return aesni_xor_block128(tmp, plaintext);
}
/**
* \brief Decrypts a 128-bit block using AES-256 in OFB mode of operation.
*
- * \param[in] cipher The ciphertext to be decrypted.
- * \param[in] key_schedule The AES-256 **encryption** key schedule. Must not be
- * `NULL`.
+ * \param[in] ciphertext The ciphertext to be decrypted.
+ * \param[in] encryption_keys The AES-256 **encryption** round keys. Must not be `NULL`.
* \param[in] init_vector The OFB initialization vector.
- * \param[out] next_init_vector The next OFB initialization vector to be used
- * as the initialization vector for the next call. Must not be `NULL`.
+ * \param[out] next_init_vector The initialization vector to be used for the next call. Must not be `NULL`.
+ *
* \return The decrypted 128-bit plaintext.
*/
static __inline AesNI_Block128 __fastcall aesni_aes256_decrypt_block_ofb(
- AesNI_Block128 cipher,
- const AesNI_Aes256_RoundKeys* key_schedule,
+ AesNI_Block128 ciphertext,
+ const AesNI_Aes256_RoundKeys* encryption_keys,
AesNI_Block128 init_vector,
AesNI_Block128* next_init_vector)
{
- assert(key_schedule);
+ assert(encryption_keys);
assert(next_init_vector);
- AesNI_Block128 tmp = aesni_aes256_encrypt_block_(init_vector, key_schedule);
+ AesNI_Block128 tmp = aesni_aes256_encrypt_block_(init_vector, encryption_keys);
*next_init_vector = tmp;
- return aesni_xor_block128(tmp, cipher);
+ return aesni_xor_block128(tmp, ciphertext);
}
/**
* \brief Encrypts a 128-bit block using AES-256 in CTR mode of operation.
*
- * \param[in] plain The plaintext to be encrypted.
- * \param[in] key_schedule The AES-256 encryption key schedule. Must not be
- * `NULL`.
+ * \param[in] plaintext The plaintext to be encrypted.
+ * \param[in] encryption_keys The AES-256 encryption round keys. Must not be `NULL`.
* \param[in] init_vector The CTR initialization vector.
- * \param[in] counter The counter, typically incremented between consecutive
- * calls.
+ * \param[in] counter The counter, typically incremented between consecutive calls.
+ *
* \return The encrypted 128-bit ciphertext.
*/
static __inline AesNI_Block128 __fastcall aesni_aes256_encrypt_block_ctr(
- AesNI_Block128 plain,
- const AesNI_Aes256_RoundKeys* key_schedule,
+ AesNI_Block128 plaintext,
+ const AesNI_Aes256_RoundKeys* encryption_keys,
AesNI_Block128 init_vector,
int counter)
{
- assert(key_schedule);
+ assert(encryption_keys);
- init_vector = aesni_be2le128(_mm_add_epi32(
- aesni_le2be128(init_vector),
- aesni_make_block128(0, 0, 0, counter)));
+ init_vector = aesni_le2be128(init_vector);
+ init_vector = _mm_add_epi32(init_vector, aesni_make_block128(0, 0, 0, counter));
+ init_vector = aesni_be2le128(init_vector);
- return aesni_xor_block128(
- plain,
- aesni_aes256_encrypt_block_(init_vector, key_schedule));
+ return aesni_xor_block128(plaintext, aesni_aes256_encrypt_block_(init_vector, encryption_keys));
}
/**
* \brief Decrypts a 128-bit block using AES-256 in CTR mode of operation.
*
- * \param[in] cipher The ciphertext to be decrypted.
- * \param[in] key_schedule The AES-256 **encryption** key schedule. Must not be
- * `NULL`.
+ * \param[in] ciphertext The ciphertext to be decrypted.
+ * \param[in] encryption_keys The AES-256 **encryption** round keys. Must not be `NULL`.
* \param[in] init_vector The CTR initialization vector.
- * \param[in] counter The counter, typically incremented between consecutive
- * calls.
+ * \param[in] counter The counter, typically incremented between consecutive calls.
+ *
* \return The decrypted 128-bit plaintext.
*/
static __inline AesNI_Block128 __fastcall aesni_aes256_decrypt_block_ctr(
- AesNI_Block128 cipher,
- const AesNI_Aes256_RoundKeys* key_schedule,
+ AesNI_Block128 ciphertext,
+ const AesNI_Aes256_RoundKeys* encryption_keys,
AesNI_Block128 init_vector,
int counter)
{
- assert(key_schedule);
+ assert(encryption_keys);
- init_vector = aesni_be2le128(_mm_add_epi32(
- aesni_le2be128(init_vector),
- aesni_make_block128(0, 0, 0, counter)));
+ init_vector = aesni_le2be128(init_vector);
+ init_vector = _mm_add_epi32(init_vector, aesni_make_block128(0, 0, 0, counter));
+ init_vector = aesni_be2le128(init_vector);
- return aesni_xor_block128(
- cipher,
- aesni_aes256_encrypt_block_(init_vector, key_schedule));
+ return aesni_xor_block128(ciphertext, aesni_aes256_encrypt_block_(init_vector, encryption_keys));
}
#ifdef __cplusplus
diff --git a/include/aesni/buffer.h b/include/aesni/buffer.h
index d153c1b..489c206 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_Aes128_RoundKeys* key_schedule,
+ AesNI_Aes128_RoundKeys* encryption_keys,
AesNI_ErrorDetails* err_details);
AesNI_StatusCode aesni_decrypt_buffer_ecb128(
const void* src,
size_t src_size,
void* dest,
size_t* dest_size,
- AesNI_Aes128_RoundKeys* inverted_schedule,
+ AesNI_Aes128_RoundKeys* decryption_keys,
AesNI_ErrorDetails* err_details);
#ifdef __cplusplus
diff --git a/src/asm/aes128.asm b/src/asm/aes128.asm
index 03a9ace..70d2010 100644
--- a/src/asm/aes128.asm
+++ b/src/asm/aes128.asm
@@ -167,7 +167,7 @@ aes128_keygen_assist:
ret
@aesni_aes128_expand_key_@20 endp
-@aesni_aes128_derive_decryption_keys_raw@8 proc
+@aesni_aes128_derive_decryption_keys_@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_aes128_derive_decryption_keys_raw@8 endp
+@aesni_aes128_derive_decryption_keys_@8 endp
end
diff --git a/src/asm/aes256.asm b/src/asm/aes256.asm
index f1c3eaf..9f1e735 100644
--- a/src/asm/aes256.asm
+++ b/src/asm/aes256.asm
@@ -241,7 +241,7 @@ aes256_keygen_assist:
ret
@aesni_aes256_expand_key_@36 endp
-@aesni_aes256_derive_decryption_keys_raw@8 proc
+@aesni_aes256_derive_decryption_keys_@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_aes256_derive_decryption_keys_raw@8 endp
+@aesni_aes256_derive_decryption_keys_@8 endp
end
diff --git a/src/buffer.c b/src/buffer.c
index 983c5cf..80120db 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_Aes128_RoundKeys* key_schedule,
+ AesNI_Aes128_RoundKeys* encryption_keys,
AesNI_ErrorDetails* err_details)
{
if (dest_size == NULL)
@@ -32,15 +32,15 @@ AesNI_StatusCode aesni_encrypt_buffer_ecb128(
return AESNI_SUCCESS;
if (src == NULL)
return aesni_make_null_argument_error(err_details, "src");
- if (key_schedule == NULL)
- return aesni_make_null_argument_error(err_details, "key_schedule");
+ if (encryption_keys == NULL)
+ return aesni_make_null_argument_error(err_details, "encryption_keys");
const size_t src_len = src_size / 16;
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_aes128_encrypt_block_ecb(plaintext, key_schedule);
+ AesNI_Block128 ciphertext = aesni_aes128_encrypt_block_ecb(plaintext, encryption_keys);
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_aes128_encrypt_block_ecb(plaintext, key_schedule);
+ AesNI_Block128 ciphertext = aesni_aes128_encrypt_block_ecb(plaintext, encryption_keys);
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_Aes128_RoundKeys* inverted_schedule,
+ AesNI_Aes128_RoundKeys* decryption_keys,
AesNI_ErrorDetails* err_details)
{
if (dest_size == NULL)
@@ -92,20 +92,20 @@ AesNI_StatusCode aesni_decrypt_buffer_ecb128(
return 0;
if (src == NULL)
return aesni_make_null_argument_error(err_details, "src");
- if (inverted_schedule == NULL)
- return aesni_make_null_argument_error(err_details, "inverted_schedule");
+ if (decryption_keys == NULL)
+ return aesni_make_null_argument_error(err_details, "decryption_keys");
const size_t src_len = src_size / 16;
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_aes128_decrypt_block_ecb(ciphertext, inverted_schedule);
+ AesNI_Block128 plaintext = aesni_aes128_decrypt_block_ecb(ciphertext, decryption_keys);
aesni_store_block128(dest, plaintext);
}
AesNI_Block128 ciphertext = aesni_load_block128(src);
- AesNI_Block128 plaintext = aesni_aes128_decrypt_block_ecb(ciphertext, inverted_schedule);
+ AesNI_Block128 plaintext = aesni_aes128_decrypt_block_ecb(ciphertext, decryption_keys);
unsigned char padding[16];
aesni_store_block128(padding, plaintext);
diff --git a/src/c/aes128.c b/src/c/aes128.c
index 49ebc4a..8f2da44 100644
--- a/src/c/aes128.c
+++ b/src/c/aes128.c
@@ -12,37 +12,37 @@
#include <wmmintrin.h>
AesNI_Block128 __fastcall aesni_aes128_encrypt_block_(
- AesNI_Block128 plain,
- const AesNI_Aes128_RoundKeys* key_schedule)
+ AesNI_Block128 plaintext,
+ const AesNI_Aes128_RoundKeys* encryption_keys)
{
- plain = _mm_xor_si128(plain, key_schedule->keys[0]);
- plain = _mm_aesenc_si128(plain, key_schedule->keys[1]);
- plain = _mm_aesenc_si128(plain, key_schedule->keys[2]);
- plain = _mm_aesenc_si128(plain, key_schedule->keys[3]);
- plain = _mm_aesenc_si128(plain, key_schedule->keys[4]);
- plain = _mm_aesenc_si128(plain, key_schedule->keys[5]);
- plain = _mm_aesenc_si128(plain, key_schedule->keys[6]);
- plain = _mm_aesenc_si128(plain, key_schedule->keys[7]);
- plain = _mm_aesenc_si128(plain, key_schedule->keys[8]);
- plain = _mm_aesenc_si128(plain, key_schedule->keys[9]);
- return _mm_aesenclast_si128(plain, key_schedule->keys[10]);
+ plaintext = _mm_xor_si128(plaintext, encryption_keys->keys[0]);
+ plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[1]);
+ plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[2]);
+ plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[3]);
+ plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[4]);
+ plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[5]);
+ plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[6]);
+ plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[7]);
+ plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[8]);
+ plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[9]);
+ return _mm_aesenclast_si128(plaintext, encryption_keys->keys[10]);
}
AesNI_Block128 __fastcall aesni_aes128_decrypt_block_(
- AesNI_Block128 cipher,
- const AesNI_Aes128_RoundKeys* inverted_schedule)
+ AesNI_Block128 ciphertext,
+ const AesNI_Aes128_RoundKeys* decryption_keys)
{
- cipher = _mm_xor_si128(cipher, inverted_schedule->keys[0]);
- cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[1]);
- cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[2]);
- cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[3]);
- cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[4]);
- cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[5]);
- cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[6]);
- cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[7]);
- cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[8]);
- cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[9]);
- return _mm_aesdeclast_si128(cipher, inverted_schedule->keys[10]);
+ ciphertext = _mm_xor_si128(ciphertext, decryption_keys->keys[0]);
+ ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[1]);
+ ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[2]);
+ ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[3]);
+ ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[4]);
+ ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[5]);
+ ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[6]);
+ ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[7]);
+ ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[8]);
+ ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[9]);
+ return _mm_aesdeclast_si128(ciphertext, decryption_keys->keys[10]);
}
static AesNI_Block128 __fastcall aesni_aes128_expand_key_assist(
@@ -66,34 +66,34 @@ static AesNI_Block128 __fastcall aesni_aes128_expand_key_assist(
void __fastcall aesni_aes128_expand_key_(
AesNI_Block128 key,
- AesNI_Aes128_RoundKeys* key_schedule)
+ AesNI_Aes128_RoundKeys* encryption_keys)
{
- AesNI_Block128 prev = key_schedule->keys[0] = key;
- 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));
+ AesNI_Block128 prev = encryption_keys->keys[0] = key;
+ prev = encryption_keys->keys[1] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x01));
+ prev = encryption_keys->keys[2] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x02));
+ prev = encryption_keys->keys[3] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x04));
+ prev = encryption_keys->keys[4] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x08));
+ prev = encryption_keys->keys[5] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x10));
+ prev = encryption_keys->keys[6] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x20));
+ prev = encryption_keys->keys[7] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x40));
+ prev = encryption_keys->keys[8] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x80));
+ prev = encryption_keys->keys[9] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x1b));
+ prev = encryption_keys->keys[10] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x36));
}
void __fastcall aesni_aes128_derive_decryption_keys_(
- const AesNI_Aes128_RoundKeys* key_schedule,
- AesNI_Aes128_RoundKeys* inverted_schedule)
+ const AesNI_Aes128_RoundKeys* encryption_keys,
+ AesNI_Aes128_RoundKeys* decryption_keys)
{
- inverted_schedule->keys[0] = key_schedule->keys[10];
- inverted_schedule->keys[1] = _mm_aesimc_si128(key_schedule->keys[9]);
- inverted_schedule->keys[2] = _mm_aesimc_si128(key_schedule->keys[8]);
- inverted_schedule->keys[3] = _mm_aesimc_si128(key_schedule->keys[7]);
- inverted_schedule->keys[4] = _mm_aesimc_si128(key_schedule->keys[6]);
- inverted_schedule->keys[5] = _mm_aesimc_si128(key_schedule->keys[5]);
- inverted_schedule->keys[6] = _mm_aesimc_si128(key_schedule->keys[4]);
- inverted_schedule->keys[7] = _mm_aesimc_si128(key_schedule->keys[3]);
- inverted_schedule->keys[8] = _mm_aesimc_si128(key_schedule->keys[2]);
- inverted_schedule->keys[9] = _mm_aesimc_si128(key_schedule->keys[1]);
- inverted_schedule->keys[10] = key_schedule->keys[0];
+ decryption_keys->keys[0] = encryption_keys->keys[10];
+ decryption_keys->keys[1] = _mm_aesimc_si128(encryption_keys->keys[9]);
+ decryption_keys->keys[2] = _mm_aesimc_si128(encryption_keys->keys[8]);
+ decryption_keys->keys[3] = _mm_aesimc_si128(encryption_keys->keys[7]);
+ decryption_keys->keys[4] = _mm_aesimc_si128(encryption_keys->keys[6]);
+ decryption_keys->keys[5] = _mm_aesimc_si128(encryption_keys->keys[5]);
+ decryption_keys->keys[6] = _mm_aesimc_si128(encryption_keys->keys[4]);
+ decryption_keys->keys[7] = _mm_aesimc_si128(encryption_keys->keys[3]);
+ decryption_keys->keys[8] = _mm_aesimc_si128(encryption_keys->keys[2]);
+ decryption_keys->keys[9] = _mm_aesimc_si128(encryption_keys->keys[1]);
+ decryption_keys->keys[10] = encryption_keys->keys[0];
}
diff --git a/src/c/aes192.c b/src/c/aes192.c
index d6ecea1..6e97637 100644
--- a/src/c/aes192.c
+++ b/src/c/aes192.c
@@ -12,41 +12,41 @@
#include <wmmintrin.h>
AesNI_Block128 __fastcall aesni_aes192_encrypt_block_(
- AesNI_Block128 plain,
- const AesNI_Aes192_RoundKeys* key_schedule)
+ AesNI_Block128 plaintext,
+ const AesNI_Aes192_RoundKeys* encryption_keys)
{
- plain = _mm_xor_si128(plain, key_schedule->keys[0]);
- plain = _mm_aesenc_si128(plain, key_schedule->keys[1]);
- plain = _mm_aesenc_si128(plain, key_schedule->keys[2]);
- plain = _mm_aesenc_si128(plain, key_schedule->keys[3]);
- plain = _mm_aesenc_si128(plain, key_schedule->keys[4]);
- plain = _mm_aesenc_si128(plain, key_schedule->keys[5]);
- plain = _mm_aesenc_si128(plain, key_schedule->keys[6]);
- plain = _mm_aesenc_si128(plain, key_schedule->keys[7]);
- plain = _mm_aesenc_si128(plain, key_schedule->keys[8]);
- plain = _mm_aesenc_si128(plain, key_schedule->keys[9]);
- plain = _mm_aesenc_si128(plain, key_schedule->keys[10]);
- plain = _mm_aesenc_si128(plain, key_schedule->keys[11]);
- return _mm_aesenclast_si128(plain, key_schedule->keys[12]);
+ plaintext = _mm_xor_si128(plaintext, encryption_keys->keys[0]);
+ plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[1]);
+ plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[2]);
+ plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[3]);
+ plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[4]);
+ plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[5]);
+ plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[6]);
+ plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[7]);
+ plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[8]);
+ plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[9]);
+ plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[10]);
+ plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[11]);
+ return _mm_aesenclast_si128(plaintext, encryption_keys->keys[12]);
}
AesNI_Block128 __fastcall aesni_aes192_decrypt_block_(
- AesNI_Block128 cipher,
- const AesNI_Aes192_RoundKeys* inverted_schedule)
+ AesNI_Block128 ciphertext,
+ const AesNI_Aes192_RoundKeys* decryption_keys)
{
- cipher = _mm_xor_si128(cipher, inverted_schedule->keys[0]);
- cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[1]);
- cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[2]);
- cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[3]);
- cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[4]);
- cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[5]);
- cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[6]);
- cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[7]);
- cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[8]);
- cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[9]);
- cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[10]);
- cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[11]);
- return _mm_aesdeclast_si128(cipher, inverted_schedule->keys[12]);
+ ciphertext = _mm_xor_si128(ciphertext, decryption_keys->keys[0]);
+ ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[1]);
+ ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[2]);
+ ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[3]);
+ ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[4]);
+ ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[5]);
+ ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[6]);
+ ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[7]);
+ ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[8]);
+ ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[9]);
+ ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[10]);
+ ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[11]);
+ return _mm_aesdeclast_si128(ciphertext, decryption_keys->keys[12]);
}
static void __fastcall aesni_aes192_expand_key_assist(
@@ -77,58 +77,58 @@ static void __fastcall aesni_aes192_expand_key_assist(
void __fastcall aesni_aes192_expand_key_(
AesNI_Block128 key_lo,
AesNI_Block128 key_hi,
- AesNI_Aes192_RoundKeys* key_schedule)
+ AesNI_Aes192_RoundKeys* encryption_keys)
{
- key_schedule->keys[0] = key_lo;
- key_schedule->keys[1] = key_hi;
+ encryption_keys->keys[0] = key_lo;
+ encryption_keys->keys[1] = key_hi;
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));
+ encryption_keys->keys[1] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(encryption_keys->keys[1]), _mm_castsi128_pd(key_lo), 0));
+ encryption_keys->keys[2] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(key_lo), _mm_castsi128_pd(key_hi), 1));
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;
+ encryption_keys->keys[3] = key_lo;
+ encryption_keys->keys[4] = key_hi;
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));
+ encryption_keys->keys[4] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(encryption_keys->keys[4]), _mm_castsi128_pd(key_lo), 0));
+ encryption_keys->keys[5] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(key_lo), _mm_castsi128_pd(key_hi), 1));
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;
+ encryption_keys->keys[6] = key_lo;
+ encryption_keys->keys[7] = key_hi;
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));
+ encryption_keys->keys[7] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(encryption_keys->keys[7]), _mm_castsi128_pd(key_lo), 0));
+ encryption_keys->keys[8] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(key_lo), _mm_castsi128_pd(key_hi), 1));
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;
+ encryption_keys->keys[9] = key_lo;
+ encryption_keys->keys[10] = key_hi;
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));
+ encryption_keys->keys[10] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(encryption_keys->keys[10]), _mm_castsi128_pd(key_lo), 0));
+ encryption_keys->keys[11] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(key_lo), _mm_castsi128_pd(key_hi), 1));
aesni_aes192_expand_key_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x80));
- key_schedule->keys[12] = key_lo;
+ encryption_keys->keys[12] = key_lo;
}
void __fastcall aesni_aes192_derive_decryption_keys_(
- const AesNI_Aes192_RoundKeys* key_schedule,
- AesNI_Aes192_RoundKeys* inverted_schedule)
+ const AesNI_Aes192_RoundKeys* encryption_keys,
+ AesNI_Aes192_RoundKeys* decryption_keys)
{
- inverted_schedule->keys[0] = key_schedule->keys[12];
- inverted_schedule->keys[1] = _mm_aesimc_si128(key_schedule->keys[11]);
- inverted_schedule->keys[2] = _mm_aesimc_si128(key_schedule->keys[10]);
- inverted_schedule->keys[3] = _mm_aesimc_si128(key_schedule->keys[9]);
- inverted_schedule->keys[4] = _mm_aesimc_si128(key_schedule->keys[8]);
- inverted_schedule->keys[5] = _mm_aesimc_si128(key_schedule->keys[7]);
- inverted_schedule->keys[6] = _mm_aesimc_si128(key_schedule->keys[6]);
- inverted_schedule->keys[7] = _mm_aesimc_si128(key_schedule->keys[5]);
- inverted_schedule->keys[8] = _mm_aesimc_si128(key_schedule->keys[4]);
- inverted_schedule->keys[9] = _mm_aesimc_si128(key_schedule->keys[3]);
- inverted_schedule->keys[10] = _mm_aesimc_si128(key_schedule->keys[2]);
- inverted_schedule->keys[11] = _mm_aesimc_si128(key_schedule->keys[1]);
- inverted_schedule->keys[12] = key_schedule->keys[0];
+ decryption_keys->keys[0] = encryption_keys->keys[12];
+ decryption_keys->keys[1] = _mm_aesimc_si128(encryption_keys->keys[11]);
+ decryption_keys->keys[2] = _mm_aesimc_si128(encryption_keys->keys[10]);
+ decryption_keys->keys[3] = _mm_aesimc_si128(encryption_keys->keys[9]);
+ decryption_keys->keys[4] = _mm_aesimc_si128(encryption_keys->keys[8]);
+ decryption_keys->keys[5] = _mm_aesimc_si128(encryption_keys->keys[7]);
+ decryption_keys->keys[6] = _mm_aesimc_si128(encryption_keys->keys[6]);
+ decryption_keys->keys[7] = _mm_aesimc_si128(encryption_keys->keys[5]);
+ decryption_keys->keys[8] = _mm_aesimc_si128(encryption_keys->keys[4]);
+ decryption_keys->keys[9] = _mm_aesimc_si128(encryption_keys->keys[3]);
+ decryption_keys->keys[10] = _mm_aesimc_si128(encryption_keys->keys[2]);
+ decryption_keys->keys[11] = _mm_aesimc_si128(encryption_keys->keys[1]);
+ decryption_keys->keys[12] = encryption_keys->keys[0];
}
diff --git a/src/c/aes256.c b/src/c/aes256.c
index 05e643e..820010d 100644
--- a/src/c/aes256.c
+++ b/src/c/aes256.c
@@ -12,45 +12,45 @@
#include <wmmintrin.h>
AesNI_Block128 __fastcall aesni_aes256_encrypt_block_(
- AesNI_Block128 plain,
- const AesNI_Aes256_RoundKeys* key_schedule)
+ AesNI_Block128 plaintext,
+ const AesNI_Aes256_RoundKeys* encryption_keys)
{
- plain = _mm_xor_si128(plain, key_schedule->keys[0]);
- plain = _mm_aesenc_si128(plain, key_schedule->keys[1]);
- plain = _mm_aesenc_si128(plain, key_schedule->keys[2]);
- plain = _mm_aesenc_si128(plain, key_schedule->keys[3]);
- plain = _mm_aesenc_si128(plain, key_schedule->keys[4]);
- plain = _mm_aesenc_si128(plain, key_schedule->keys[5]);
- plain = _mm_aesenc_si128(plain, key_schedule->keys[6]);
- plain = _mm_aesenc_si128(plain, key_schedule->keys[7]);
- plain = _mm_aesenc_si128(plain, key_schedule->keys[8]);
- plain = _mm_aesenc_si128(plain, key_schedule->keys[9]);
- plain = _mm_aesenc_si128(plain, key_schedule->keys[10]);
- plain = _mm_aesenc_si128(plain, key_schedule->keys[11]);
- plain = _mm_aesenc_si128(plain, key_schedule->keys[12]);
- plain = _mm_aesenc_si128(plain, key_schedule->keys[13]);
- return _mm_aesenclast_si128(plain, key_schedule->keys[14]);
+ plaintext = _mm_xor_si128(plaintext, encryption_keys->keys[0]);
+ plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[1]);
+ plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[2]);
+ plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[3]);
+ plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[4]);
+ plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[5]);
+ plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[6]);
+ plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[7]);
+ plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[8]);
+ plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[9]);
+ plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[10]);
+ plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[11]);
+ plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[12]);
+ plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[13]);
+ return _mm_aesenclast_si128(plaintext, encryption_keys->keys[14]);
}
AesNI_Block128 __fastcall aesni_aes256_decrypt_block_(
- AesNI_Block128 cipher,
- const AesNI_Aes256_RoundKeys* inverted_schedule)
+ AesNI_Block128 ciphertext,
+ const AesNI_Aes256_RoundKeys* decryption_keys)
{
- cipher = _mm_xor_si128(cipher, inverted_schedule->keys[0]);
- cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[1]);
- cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[2]);
- cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[3]);
- cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[4]);
- cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[5]);
- cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[6]);
- cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[7]);
- cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[8]);
- cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[9]);
- cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[10]);
- cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[11]);
- cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[12]);
- cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[13]);
- return _mm_aesdeclast_si128(cipher, inverted_schedule->keys[14]);
+ ciphertext = _mm_xor_si128(ciphertext, decryption_keys->keys[0]);
+ ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[1]);
+ ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[2]);
+ ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[3]);
+ ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[4]);
+ ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[5]);
+ ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[6]);
+ ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[7]);
+ ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[8]);
+ ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[9]);
+ ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[10]);
+ ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[11]);
+ ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[12]);
+ ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[13]);
+ return _mm_aesdeclast_si128(ciphertext, decryption_keys->keys[14]);
}
static AesNI_Block128 __fastcall aesni_aes256_expand_key_assist(
@@ -79,84 +79,84 @@ static AesNI_Block128 __fastcall aesni_aes256_expand_key_assist(
void __fastcall aesni_aes256_expand_key_(
AesNI_Block128 key_lo,
AesNI_Block128 key_hi,
- AesNI_Aes256_RoundKeys* key_schedule)
+ AesNI_Aes256_RoundKeys* encryption_keys)
{
AesNI_Block128 prev_lo, prev_hi;
AesNI_Block128 hwgen;
- prev_lo = key_schedule->keys[0] = key_lo;
- prev_hi = key_schedule->keys[1] = key_hi;
+ prev_lo = encryption_keys->keys[0] = key_lo;
+ prev_hi = encryption_keys->keys[1] = key_hi;
hwgen = _mm_aeskeygenassist_si128(prev_hi, 0x01);
hwgen = _mm_shuffle_epi32(hwgen, 0xff);
- key_schedule->keys[2] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
+ encryption_keys->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] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
+ encryption_keys->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] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
+ encryption_keys->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] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
+ encryption_keys->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] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
+ encryption_keys->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] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
+ encryption_keys->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] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
+ encryption_keys->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] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
+ encryption_keys->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] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
+ encryption_keys->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] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
+ encryption_keys->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] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
+ encryption_keys->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] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
+ encryption_keys->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] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
+ encryption_keys->keys[14] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
}
void __fastcall aesni_aes256_derive_decryption_keys_(
- const AesNI_Aes256_RoundKeys* key_schedule,
- AesNI_Aes256_RoundKeys* inverted_schedule)
+ const AesNI_Aes256_RoundKeys* encryption_keys,
+ AesNI_Aes256_RoundKeys* decryption_keys)
{
- inverted_schedule->keys[0] = key_schedule->keys[14];
- inverted_schedule->keys[1] = _mm_aesimc_si128(key_schedule->keys[13]);
- inverted_schedule->keys[2] = _mm_aesimc_si128(key_schedule->keys[12]);
- inverted_schedule->keys[3] = _mm_aesimc_si128(key_schedule->keys[11]);
- inverted_schedule->keys[4] = _mm_aesimc_si128(key_schedule->keys[10]);
- inverted_schedule->keys[5] = _mm_aesimc_si128(key_schedule->keys[9]);
- inverted_schedule->keys[6] = _mm_aesimc_si128(key_schedule->keys[8]);
- inverted_schedule->keys[7] = _mm_aesimc_si128(key_schedule->keys[7]);
- inverted_schedule->keys[8] = _mm_aesimc_si128(key_schedule->keys[6]);
- inverted_schedule->keys[9] = _mm_aesimc_si128(key_schedule->keys[5]);
- inverted_schedule->keys[10] = _mm_aesimc_si128(key_schedule->keys[4]);
- inverted_schedule->keys[11] = _mm_aesimc_si128(key_schedule->keys[3]);
- inverted_schedule->keys[12] = _mm_aesimc_si128(key_schedule->keys[2]);
- inverted_schedule->keys[13] = _mm_aesimc_si128(key_schedule->keys[1]);
- inverted_schedule->keys[14] = key_schedule->keys[0];
+ decryption_keys->keys[0] = encryption_keys->keys[14];
+ decryption_keys->keys[1] = _mm_aesimc_si128(encryption_keys->keys[13]);
+ decryption_keys->keys[2] = _mm_aesimc_si128(encryption_keys->keys[12]);
+ decryption_keys->keys[3] = _mm_aesimc_si128(encryption_keys->keys[11]);
+ decryption_keys->keys[4] = _mm_aesimc_si128(encryption_keys->keys[10]);
+ decryption_keys->keys[5] = _mm_aesimc_si128(encryption_keys->keys[9]);
+ decryption_keys->keys[6] = _mm_aesimc_si128(encryption_keys->keys[8]);
+ decryption_keys->keys[7] = _mm_aesimc_si128(encryption_keys->keys[7]);
+ decryption_keys->keys[8] = _mm_aesimc_si128(encryption_keys->keys[6]);
+ decryption_keys->keys[9] = _mm_aesimc_si128(encryption_keys->keys[5]);
+ decryption_keys->keys[10] = _mm_aesimc_si128(encryption_keys->keys[4]);
+ decryption_keys->keys[11] = _mm_aesimc_si128(encryption_keys->keys[3]);
+ decryption_keys->keys[12] = _mm_aesimc_si128(encryption_keys->keys[2]);
+ decryption_keys->keys[13] = _mm_aesimc_si128(encryption_keys->keys[1]);
+ decryption_keys->keys[14] = encryption_keys->keys[0];
}
diff --git a/test/aes128cbc_decrypt_block.c b/test/aes128cbc_decrypt_block.c
index 73586eb..b286e64 100644
--- a/test/aes128cbc_decrypt_block.c
+++ b/test/aes128cbc_decrypt_block.c
@@ -22,8 +22,8 @@ int main(int argc, char** argv)
{
for (--argc, ++argv; argc > -1; --argc, ++argv)
{
- AesNI_Block128 plain, key, cipher, iv;
- AesNI_Aes128_RoundKeys key_schedule, inverted_schedule;
+ AesNI_Block128 plaintext, key, ciphertext, iv;
+ AesNI_Aes128_RoundKeys encryption_keys, decryption_keys;
if (argc < 2)
exit_with_usage();
@@ -40,21 +40,21 @@ int main(int argc, char** argv)
exit_with_usage();
}
- aesni_aes128_expand_key(key, &key_schedule);
- aesni_aes128_derive_decryption_keys(&key_schedule, &inverted_schedule);
+ aesni_aes128_expand_key(key, &encryption_keys);
+ aesni_aes128_derive_decryption_keys(&encryption_keys, &decryption_keys);
for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
{
if (strcmp("--", *argv) == 0)
break;
- if (aesni_is_error(aesni_parse_block128(&cipher, *argv, NULL)))
+ if (aesni_is_error(aesni_parse_block128(&ciphertext, *argv, NULL)))
{
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- plain = aesni_aes128_decrypt_block_cbc(cipher, &inverted_schedule, iv, &iv);
- aesni_print_block128(&plain, NULL);
+ plaintext = aesni_aes128_decrypt_block_cbc(ciphertext, &decryption_keys, iv, &iv);
+ aesni_print_block128(&plaintext, NULL);
}
}
diff --git a/test/aes128cbc_encrypt_block.c b/test/aes128cbc_encrypt_block.c
index dfdd7d3..15348de 100644
--- a/test/aes128cbc_encrypt_block.c
+++ b/test/aes128cbc_encrypt_block.c
@@ -22,8 +22,8 @@ int main(int argc, char** argv)
{
for (--argc, ++argv; argc > -1; --argc, ++argv)
{
- AesNI_Block128 plain, key, cipher, iv;
- AesNI_Aes128_RoundKeys key_schedule;
+ AesNI_Block128 plaintext, key, ciphertext, iv;
+ AesNI_Aes128_RoundKeys encryption_keys;
if (argc < 2)
exit_with_usage();
@@ -40,20 +40,20 @@ int main(int argc, char** argv)
exit_with_usage();
}
- aesni_aes128_expand_key(key, &key_schedule);
+ aesni_aes128_expand_key(key, &encryption_keys);
for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
{
if (strcmp("--", *argv) == 0)
break;
- if (aesni_is_error(aesni_parse_block128(&plain, *argv, NULL)))
+ if (aesni_is_error(aesni_parse_block128(&plaintext, *argv, NULL)))
{
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- cipher = aesni_aes128_encrypt_block_cbc(plain, &key_schedule, iv, &iv);
- aesni_print_block128(&cipher, NULL);
+ ciphertext = aesni_aes128_encrypt_block_cbc(plaintext, &encryption_keys, iv, &iv);
+ aesni_print_block128(&ciphertext, NULL);
}
}
diff --git a/test/aes128cfb_decrypt_block.c b/test/aes128cfb_decrypt_block.c
index a78f276..a6d4f72 100644
--- a/test/aes128cfb_decrypt_block.c
+++ b/test/aes128cfb_decrypt_block.c
@@ -22,8 +22,8 @@ int main(int argc, char** argv)
{
for (--argc, ++argv; argc > -1; --argc, ++argv)
{
- AesNI_Block128 plain, key, cipher, iv;
- AesNI_Aes128_RoundKeys key_schedule;
+ AesNI_Block128 plaintext, key, ciphertext, iv;
+ AesNI_Aes128_RoundKeys encryption_keys;
if (argc < 2)
exit_with_usage();
@@ -40,20 +40,20 @@ int main(int argc, char** argv)
exit_with_usage();
}
- aesni_aes128_expand_key(key, &key_schedule);
+ aesni_aes128_expand_key(key, &encryption_keys);
for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
{
if (strcmp("--", *argv) == 0)
break;
- if (aesni_is_error(aesni_parse_block128(&cipher, *argv, NULL)))
+ if (aesni_is_error(aesni_parse_block128(&ciphertext, *argv, NULL)))
{
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- plain = aesni_aes128_decrypt_block_cfb(cipher, &key_schedule, iv, &iv);
- aesni_print_block128(&plain, NULL);
+ plaintext = aesni_aes128_decrypt_block_cfb(ciphertext, &encryption_keys, iv, &iv);
+ aesni_print_block128(&plaintext, NULL);
}
}
diff --git a/test/aes128cfb_encrypt_block.c b/test/aes128cfb_encrypt_block.c
index 576a2ed..e238048 100644
--- a/test/aes128cfb_encrypt_block.c
+++ b/test/aes128cfb_encrypt_block.c
@@ -22,8 +22,8 @@ int main(int argc, char** argv)
{
for (--argc, ++argv; argc > -1; --argc, ++argv)
{
- AesNI_Block128 plain, key, cipher, iv;
- AesNI_Aes128_RoundKeys key_schedule;
+ AesNI_Block128 plaintext, key, ciphertext, iv;
+ AesNI_Aes128_RoundKeys encryption_keys;
if (argc < 2)
exit_with_usage();
@@ -40,20 +40,20 @@ int main(int argc, char** argv)
exit_with_usage();
}
- aesni_aes128_expand_key(key, &key_schedule);
+ aesni_aes128_expand_key(key, &encryption_keys);
for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
{
if (strcmp("--", *argv) == 0)
break;
- if (aesni_is_error(aesni_parse_block128(&plain, *argv, NULL)))
+ if (aesni_is_error(aesni_parse_block128(&plaintext, *argv, NULL)))
{
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- cipher = aesni_aes128_encrypt_block_cfb(plain, &key_schedule, iv, &iv);
- aesni_print_block128(&cipher, NULL);
+ ciphertext = aesni_aes128_encrypt_block_cfb(plaintext, &encryption_keys, iv, &iv);
+ aesni_print_block128(&ciphertext, NULL);
}
}
diff --git a/test/aes128ctr_decrypt_block.c b/test/aes128ctr_decrypt_block.c
index 940d2f4..a9ed568 100644
--- a/test/aes128ctr_decrypt_block.c
+++ b/test/aes128ctr_decrypt_block.c
@@ -22,8 +22,8 @@ int main(int argc, char** argv)
{
for (--argc, ++argv; argc > -1; --argc, ++argv)
{
- AesNI_Block128 plain, key, cipher, iv;
- AesNI_Aes128_RoundKeys key_schedule;
+ AesNI_Block128 plaintext, key, ciphertext, iv;
+ AesNI_Aes128_RoundKeys encryption_keys;
if (argc < 2)
exit_with_usage();
@@ -40,7 +40,7 @@ int main(int argc, char** argv)
exit_with_usage();
}
- aesni_aes128_expand_key(key, &key_schedule);
+ aesni_aes128_expand_key(key, &encryption_keys);
int ctr = 0;
@@ -49,13 +49,13 @@ int main(int argc, char** argv)
if (strcmp("--", *argv) == 0)
break;
- if (aesni_is_error(aesni_parse_block128(&cipher, *argv, NULL)))
+ if (aesni_is_error(aesni_parse_block128(&ciphertext, *argv, NULL)))
{
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- plain = aesni_aes128_decrypt_block_ctr(cipher, &key_schedule, iv, ctr++);
- aesni_print_block128(&plain, NULL);
+ plaintext = aesni_aes128_decrypt_block_ctr(ciphertext, &encryption_keys, iv, ctr++);
+ aesni_print_block128(&plaintext, NULL);
}
}
diff --git a/test/aes128ctr_encrypt_block.c b/test/aes128ctr_encrypt_block.c
index 32dd216..1541274 100644
--- a/test/aes128ctr_encrypt_block.c
+++ b/test/aes128ctr_encrypt_block.c
@@ -22,8 +22,8 @@ int main(int argc, char** argv)
{
for (--argc, ++argv; argc > -1; --argc, ++argv)
{
- AesNI_Block128 plain, key, cipher, iv;
- AesNI_Aes128_RoundKeys key_schedule;
+ AesNI_Block128 plaintext, key, ciphertext, iv;
+ AesNI_Aes128_RoundKeys encryption_keys;
if (argc < 2)
exit_with_usage();
@@ -40,7 +40,7 @@ int main(int argc, char** argv)
exit_with_usage();
}
- aesni_aes128_expand_key(key, &key_schedule);
+ aesni_aes128_expand_key(key, &encryption_keys);
int ctr = 0;
@@ -49,13 +49,13 @@ int main(int argc, char** argv)
if (strcmp("--", *argv) == 0)
break;
- if (aesni_is_error(aesni_parse_block128(&plain, *argv, NULL)))
+ if (aesni_is_error(aesni_parse_block128(&plaintext, *argv, NULL)))
{
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- cipher = aesni_aes128_encrypt_block_ctr(plain, &key_schedule, iv, ctr++);
- aesni_print_block128(&cipher, NULL);
+ ciphertext = aesni_aes128_encrypt_block_ctr(plaintext, &encryption_keys, iv, ctr++);
+ aesni_print_block128(&ciphertext, NULL);
}
}
diff --git a/test/aes128ecb_decrypt_block.c b/test/aes128ecb_decrypt_block.c
index 5885fb9..809ed67 100644
--- a/test/aes128ecb_decrypt_block.c
+++ b/test/aes128ecb_decrypt_block.c
@@ -22,8 +22,8 @@ int main(int argc, char** argv)
{
for (--argc, ++argv; argc > -1; --argc, ++argv)
{
- AesNI_Block128 plain, key, cipher;
- AesNI_Aes128_RoundKeys key_schedule, inverted_schedule;
+ AesNI_Block128 plaintext, key, ciphertext;
+ AesNI_Aes128_RoundKeys encryption_keys, decryption_keys;
if (argc < 1)
exit_with_usage();
@@ -34,21 +34,21 @@ int main(int argc, char** argv)
exit_with_usage();
}
- aesni_aes128_expand_key(key, &key_schedule);
- aesni_aes128_derive_decryption_keys(&key_schedule, &inverted_schedule);
+ aesni_aes128_expand_key(key, &encryption_keys);
+ aesni_aes128_derive_decryption_keys(&encryption_keys, &decryption_keys);
for (--argc, ++argv; argc > 0; --argc, ++argv)
{
if (strcmp("--", *argv) == 0)
break;
- if (aesni_is_error(aesni_parse_block128(&cipher, *argv, NULL)))
+ if (aesni_is_error(aesni_parse_block128(&ciphertext, *argv, NULL)))
{
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- plain = aesni_aes128_decrypt_block_ecb(cipher, &inverted_schedule);
- aesni_print_block128(&plain, NULL);
+ plaintext = aesni_aes128_decrypt_block_ecb(ciphertext, &decryption_keys);
+ aesni_print_block128(&plaintext, NULL);
}
}
diff --git a/test/aes128ecb_encrypt_block.c b/test/aes128ecb_encrypt_block.c
index 040d47d..1c73e90 100644
--- a/test/aes128ecb_encrypt_block.c
+++ b/test/aes128ecb_encrypt_block.c
@@ -22,8 +22,8 @@ int main(int argc, char** argv)
{
for (--argc, ++argv; argc > -1; --argc, ++argv)
{
- AesNI_Block128 plain, key, cipher;
- AesNI_Aes128_RoundKeys key_schedule;
+ AesNI_Block128 plaintext, key, ciphertext;
+ AesNI_Aes128_RoundKeys encryption_keys;
if (argc < 1)
exit_with_usage();
@@ -34,20 +34,20 @@ int main(int argc, char** argv)
exit_with_usage();
}
- aesni_aes128_expand_key(key, &key_schedule);
+ aesni_aes128_expand_key(key, &encryption_keys);
for (--argc, ++argv; argc > 0; --argc, ++argv)
{
if (strcmp("--", *argv) == 0)
break;
- if (aesni_is_error(aesni_parse_block128(&plain, *argv, NULL)))
+ if (aesni_is_error(aesni_parse_block128(&plaintext, *argv, NULL)))
{
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- cipher = aesni_aes128_encrypt_block_ecb(plain, &key_schedule);
- aesni_print_block128(&cipher, NULL);
+ ciphertext = aesni_aes128_encrypt_block_ecb(plaintext, &encryption_keys);
+ aesni_print_block128(&ciphertext, NULL);
}
}
diff --git a/test/aes128ofb_decrypt_block.c b/test/aes128ofb_decrypt_block.c
index 16f148d..e230451 100644
--- a/test/aes128ofb_decrypt_block.c
+++ b/test/aes128ofb_decrypt_block.c
@@ -22,8 +22,8 @@ int main(int argc, char** argv)
{
for (--argc, ++argv; argc > -1; --argc, ++argv)
{
- AesNI_Block128 plain, key, cipher, iv;
- AesNI_Aes128_RoundKeys key_schedule;
+ AesNI_Block128 plaintext, key, ciphertext, iv;
+ AesNI_Aes128_RoundKeys encryption_keys;
if (argc < 2)
exit_with_usage();
@@ -40,20 +40,20 @@ int main(int argc, char** argv)
exit_with_usage();
}
- aesni_aes128_expand_key(key, &key_schedule);
+ aesni_aes128_expand_key(key, &encryption_keys);
for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
{
if (strcmp("--", *argv) == 0)
break;
- if (aesni_is_error(aesni_parse_block128(&cipher, *argv, NULL)))
+ if (aesni_is_error(aesni_parse_block128(&ciphertext, *argv, NULL)))
{
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- plain = aesni_aes128_decrypt_block_ofb(cipher, &key_schedule, iv, &iv);
- aesni_print_block128(&plain, NULL);
+ plaintext = aesni_aes128_decrypt_block_ofb(ciphertext, &encryption_keys, iv, &iv);
+ aesni_print_block128(&plaintext, NULL);
}
}
diff --git a/test/aes128ofb_encrypt_block.c b/test/aes128ofb_encrypt_block.c
index 4532cc8..3911cf7 100644
--- a/test/aes128ofb_encrypt_block.c
+++ b/test/aes128ofb_encrypt_block.c
@@ -22,8 +22,8 @@ int main(int argc, char** argv)
{
for (--argc, ++argv; argc > -1; --argc, ++argv)
{
- AesNI_Block128 plain, key, cipher, iv;
- AesNI_Aes128_RoundKeys key_schedule;
+ AesNI_Block128 plaintext, key, ciphertext, iv;
+ AesNI_Aes128_RoundKeys encryption_keys;
if (argc < 2)
exit_with_usage();
@@ -40,20 +40,20 @@ int main(int argc, char** argv)
exit_with_usage();
}
- aesni_aes128_expand_key(key, &key_schedule);
+ aesni_aes128_expand_key(key, &encryption_keys);
for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
{
if (strcmp("--", *argv) == 0)
break;
- if (aesni_is_error(aesni_parse_block128(&plain, *argv, NULL)))
+ if (aesni_is_error(aesni_parse_block128(&plaintext, *argv, NULL)))
{
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- cipher = aesni_aes128_encrypt_block_ofb(plain, &key_schedule, iv, &iv);
- aesni_print_block128(&cipher, NULL);
+ ciphertext = aesni_aes128_encrypt_block_ofb(plaintext, &encryption_keys, iv, &iv);
+ aesni_print_block128(&ciphertext, NULL);
}
}
diff --git a/test/aes192cbc_decrypt_block.c b/test/aes192cbc_decrypt_block.c
index 9d5e1d6..fc72cf2 100644
--- a/test/aes192cbc_decrypt_block.c
+++ b/test/aes192cbc_decrypt_block.c
@@ -22,9 +22,9 @@ int main(int argc, char** argv)
{
for (--argc, ++argv; argc > -1; --argc, ++argv)
{
- AesNI_Block128 plain, cipher, iv;
+ AesNI_Block128 plaintext, ciphertext, iv;
AesNI_Block192 key;
- AesNI_Aes192_RoundKeys key_schedule, inverted_schedule;
+ AesNI_Aes192_RoundKeys encryption_keys, decryption_keys;
if (argc < 2)
exit_with_usage();
@@ -41,21 +41,21 @@ int main(int argc, char** argv)
exit_with_usage();
}
- aesni_aes192_expand_key(&key, &key_schedule);
- aesni_aes192_derive_decryption_keys(&key_schedule, &inverted_schedule);
+ aesni_aes192_expand_key(&key, &encryption_keys);
+ aesni_aes192_derive_decryption_keys(&encryption_keys, &decryption_keys);
for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
{
if (strcmp("--", *argv) == 0)
break;
- if (aesni_is_error(aesni_parse_block128(&cipher, *argv, NULL)))
+ if (aesni_is_error(aesni_parse_block128(&ciphertext, *argv, NULL)))
{
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- plain = aesni_aes192_decrypt_block_cbc(cipher, &inverted_schedule, iv, &iv);
- aesni_print_block128(&plain, NULL);
+ plaintext = aesni_aes192_decrypt_block_cbc(ciphertext, &decryption_keys, iv, &iv);
+ aesni_print_block128(&plaintext, NULL);
}
}
diff --git a/test/aes192cbc_encrypt_block.c b/test/aes192cbc_encrypt_block.c
index d562ae5..8df44e2 100644
--- a/test/aes192cbc_encrypt_block.c
+++ b/test/aes192cbc_encrypt_block.c
@@ -22,9 +22,9 @@ int main(int argc, char** argv)
{
for (--argc, ++argv; argc > -1; --argc, ++argv)
{
- AesNI_Block128 plain, cipher, iv;
+ AesNI_Block128 plaintext, ciphertext, iv;
AesNI_Block192 key;
- AesNI_Aes192_RoundKeys key_schedule;
+ AesNI_Aes192_RoundKeys encryption_keys;
if (argc < 2)
exit_with_usage();
@@ -41,20 +41,20 @@ int main(int argc, char** argv)
exit_with_usage();
}
- aesni_aes192_expand_key(&key, &key_schedule);
+ aesni_aes192_expand_key(&key, &encryption_keys);
for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
{
if (strcmp("--", *argv) == 0)
break;
- if (aesni_is_error(aesni_parse_block128(&plain, *argv, NULL)))
+ if (aesni_is_error(aesni_parse_block128(&plaintext, *argv, NULL)))
{
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- cipher = aesni_aes192_encrypt_block_cbc(plain, &key_schedule, iv, &iv);
- aesni_print_block128(&cipher, NULL);
+ ciphertext = aesni_aes192_encrypt_block_cbc(plaintext, &encryption_keys, iv, &iv);
+ aesni_print_block128(&ciphertext, NULL);
}
}
diff --git a/test/aes192cfb_decrypt_block.c b/test/aes192cfb_decrypt_block.c
index b5703d1..8143972 100644
--- a/test/aes192cfb_decrypt_block.c
+++ b/test/aes192cfb_decrypt_block.c
@@ -22,9 +22,9 @@ int main(int argc, char** argv)
{
for (--argc, ++argv; argc > -1; --argc, ++argv)
{
- AesNI_Block128 plain, cipher, iv;
+ AesNI_Block128 plaintext, ciphertext, iv;
AesNI_Block192 key;
- AesNI_Aes192_RoundKeys key_schedule;
+ AesNI_Aes192_RoundKeys encryption_keys;
if (argc < 2)
exit_with_usage();
@@ -41,20 +41,20 @@ int main(int argc, char** argv)
exit_with_usage();
}
- aesni_aes192_expand_key(&key, &key_schedule);
+ aesni_aes192_expand_key(&key, &encryption_keys);
for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
{
if (strcmp("--", *argv) == 0)
break;
- if (aesni_is_error(aesni_parse_block128(&cipher, *argv, NULL)))
+ if (aesni_is_error(aesni_parse_block128(&ciphertext, *argv, NULL)))
{
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- plain = aesni_aes192_decrypt_block_cfb(cipher, &key_schedule, iv, &iv);
- aesni_print_block128(&plain, NULL);
+ plaintext = aesni_aes192_decrypt_block_cfb(ciphertext, &encryption_keys, iv, &iv);
+ aesni_print_block128(&plaintext, NULL);
}
}
diff --git a/test/aes192cfb_encrypt_block.c b/test/aes192cfb_encrypt_block.c
index a23aa72..40214d8 100644
--- a/test/aes192cfb_encrypt_block.c
+++ b/test/aes192cfb_encrypt_block.c
@@ -22,9 +22,9 @@ int main(int argc, char** argv)
{
for (--argc, ++argv; argc > -1; --argc, ++argv)
{
- AesNI_Block128 plain, cipher, iv;
+ AesNI_Block128 plaintext, ciphertext, iv;
AesNI_Block192 key;
- AesNI_Aes192_RoundKeys key_schedule;
+ AesNI_Aes192_RoundKeys encryption_keys;
if (argc < 2)
exit_with_usage();
@@ -41,20 +41,20 @@ int main(int argc, char** argv)
exit_with_usage();
}
- aesni_aes192_expand_key(&key, &key_schedule);
+ aesni_aes192_expand_key(&key, &encryption_keys);
for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
{
if (strcmp("--", *argv) == 0)
break;
- if (aesni_is_error(aesni_parse_block128(&plain, *argv, NULL)))
+ if (aesni_is_error(aesni_parse_block128(&plaintext, *argv, NULL)))
{
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- cipher = aesni_aes192_encrypt_block_cfb(plain, &key_schedule, iv, &iv);
- aesni_print_block128(&cipher, NULL);
+ ciphertext = aesni_aes192_encrypt_block_cfb(plaintext, &encryption_keys, iv, &iv);
+ aesni_print_block128(&ciphertext, NULL);
}
}
diff --git a/test/aes192ctr_decrypt_block.c b/test/aes192ctr_decrypt_block.c
index 14e91d9..2f88bcd 100644
--- a/test/aes192ctr_decrypt_block.c
+++ b/test/aes192ctr_decrypt_block.c
@@ -22,9 +22,9 @@ int main(int argc, char** argv)
{
for (--argc, ++argv; argc > -1; --argc, ++argv)
{
- AesNI_Block128 plain, cipher, iv;
+ AesNI_Block128 plaintext, ciphertext, iv;
AesNI_Block192 key;
- AesNI_Aes192_RoundKeys key_schedule;
+ AesNI_Aes192_RoundKeys encryption_keys;
if (argc < 2)
exit_with_usage();
@@ -41,7 +41,7 @@ int main(int argc, char** argv)
exit_with_usage();
}
- aesni_aes192_expand_key(&key, &key_schedule);
+ aesni_aes192_expand_key(&key, &encryption_keys);
int ctr = 0;
@@ -50,13 +50,13 @@ int main(int argc, char** argv)
if (strcmp("--", *argv) == 0)
break;
- if (aesni_is_error(aesni_parse_block128(&cipher, *argv, NULL)))
+ if (aesni_is_error(aesni_parse_block128(&ciphertext, *argv, NULL)))
{
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- plain = aesni_aes192_decrypt_block_ctr(cipher, &key_schedule, iv, ctr++);
- aesni_print_block128(&plain, NULL);
+ plaintext = aesni_aes192_decrypt_block_ctr(ciphertext, &encryption_keys, iv, ctr++);
+ aesni_print_block128(&plaintext, NULL);
}
}
diff --git a/test/aes192ctr_encrypt_block.c b/test/aes192ctr_encrypt_block.c
index e613d87..3052ea3 100644
--- a/test/aes192ctr_encrypt_block.c
+++ b/test/aes192ctr_encrypt_block.c
@@ -22,9 +22,9 @@ int main(int argc, char** argv)
{
for (--argc, ++argv; argc > -1; --argc, ++argv)
{
- AesNI_Block128 plain, cipher, iv;
+ AesNI_Block128 plaintext, ciphertext, iv;
AesNI_Block192 key;
- AesNI_Aes192_RoundKeys key_schedule;
+ AesNI_Aes192_RoundKeys encryption_keys;
if (argc < 2)
exit_with_usage();
@@ -41,7 +41,7 @@ int main(int argc, char** argv)
exit_with_usage();
}
- aesni_aes192_expand_key(&key, &key_schedule);
+ aesni_aes192_expand_key(&key, &encryption_keys);
int ctr = 0;
@@ -50,13 +50,13 @@ int main(int argc, char** argv)
if (strcmp("--", *argv) == 0)
break;
- if (aesni_is_error(aesni_parse_block128(&plain, *argv, NULL)))
+ if (aesni_is_error(aesni_parse_block128(&plaintext, *argv, NULL)))
{
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- cipher = aesni_aes192_encrypt_block_ctr(plain, &key_schedule, iv, ctr++);
- aesni_print_block128(&cipher, NULL);
+ ciphertext = aesni_aes192_encrypt_block_ctr(plaintext, &encryption_keys, iv, ctr++);
+ aesni_print_block128(&ciphertext, NULL);
}
}
diff --git a/test/aes192ecb_decrypt_block.c b/test/aes192ecb_decrypt_block.c
index 39689e9..70c19f4 100644
--- a/test/aes192ecb_decrypt_block.c
+++ b/test/aes192ecb_decrypt_block.c
@@ -22,9 +22,9 @@ int main(int argc, char** argv)
{
for (--argc, ++argv; argc > -1; --argc, ++argv)
{
- AesNI_Block128 plain, cipher;
+ AesNI_Block128 plaintext, ciphertext;
AesNI_Block192 key;
- AesNI_Aes192_RoundKeys key_schedule, inverted_schedule;
+ AesNI_Aes192_RoundKeys encryption_keys, decryption_keys;
if (argc < 1)
exit_with_usage();
@@ -35,21 +35,21 @@ int main(int argc, char** argv)
exit_with_usage();
}
- aesni_aes192_expand_key(&key, &key_schedule);
- aesni_aes192_derive_decryption_keys(&key_schedule, &inverted_schedule);
+ aesni_aes192_expand_key(&key, &encryption_keys);
+ aesni_aes192_derive_decryption_keys(&encryption_keys, &decryption_keys);
for (--argc, ++argv; argc > 0; --argc, ++argv)
{
if (strcmp("--", *argv) == 0)
break;
- if (aesni_is_error(aesni_parse_block128(&cipher, *argv, NULL)))
+ if (aesni_is_error(aesni_parse_block128(&ciphertext, *argv, NULL)))
{
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- plain = aesni_aes192_decrypt_block_ecb(cipher, &inverted_schedule);
- aesni_print_block128(&plain, NULL);
+ plaintext = aesni_aes192_decrypt_block_ecb(ciphertext, &decryption_keys);
+ aesni_print_block128(&plaintext, NULL);
}
}
diff --git a/test/aes192ecb_encrypt_block.c b/test/aes192ecb_encrypt_block.c
index 167ffd4..b8eb7b2 100644
--- a/test/aes192ecb_encrypt_block.c
+++ b/test/aes192ecb_encrypt_block.c
@@ -22,9 +22,9 @@ int main(int argc, char** argv)
{
for (--argc, ++argv; argc > -1; --argc, ++argv)
{
- AesNI_Block128 plain, cipher;
+ AesNI_Block128 plaintext, ciphertext;
AesNI_Block192 key;
- AesNI_Aes192_RoundKeys key_schedule;
+ AesNI_Aes192_RoundKeys encryption_keys;
if (argc < 1)
exit_with_usage();
@@ -35,20 +35,20 @@ int main(int argc, char** argv)
exit_with_usage();
}
- aesni_aes192_expand_key(&key, &key_schedule);
+ aesni_aes192_expand_key(&key, &encryption_keys);
for (--argc, ++argv; argc > 0; --argc, ++argv)
{
if (strcmp("--", *argv) == 0)
break;
- if (aesni_is_error(aesni_parse_block128(&plain, *argv, NULL)))
+ if (aesni_is_error(aesni_parse_block128(&plaintext, *argv, NULL)))
{
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- cipher = aesni_aes192_encrypt_block_ecb(plain, &key_schedule);
- aesni_print_block128(&cipher, NULL);
+ ciphertext = aesni_aes192_encrypt_block_ecb(plaintext, &encryption_keys);
+ aesni_print_block128(&ciphertext, NULL);
}
}
diff --git a/test/aes192ofb_decrypt_block.c b/test/aes192ofb_decrypt_block.c
index 4dd5fbb..6e1adcb 100644
--- a/test/aes192ofb_decrypt_block.c
+++ b/test/aes192ofb_decrypt_block.c
@@ -22,9 +22,9 @@ int main(int argc, char** argv)
{
for (--argc, ++argv; argc > -1; --argc, ++argv)
{
- AesNI_Block128 plain, cipher, iv;
+ AesNI_Block128 plaintext, ciphertext, iv;
AesNI_Block192 key;
- AesNI_Aes192_RoundKeys key_schedule;
+ AesNI_Aes192_RoundKeys encryption_keys;
if (argc < 2)
exit_with_usage();
@@ -41,20 +41,20 @@ int main(int argc, char** argv)
exit_with_usage();
}
- aesni_aes192_expand_key(&key, &key_schedule);
+ aesni_aes192_expand_key(&key, &encryption_keys);
for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
{
if (strcmp("--", *argv) == 0)
break;
- if (aesni_is_error(aesni_parse_block128(&cipher, *argv, NULL)))
+ if (aesni_is_error(aesni_parse_block128(&ciphertext, *argv, NULL)))
{
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- plain = aesni_aes192_decrypt_block_ofb(cipher, &key_schedule, iv, &iv);
- aesni_print_block128(&plain, NULL);
+ plaintext = aesni_aes192_decrypt_block_ofb(ciphertext, &encryption_keys, iv, &iv);
+ aesni_print_block128(&plaintext, NULL);
}
}
diff --git a/test/aes192ofb_encrypt_block.c b/test/aes192ofb_encrypt_block.c
index 2a45b79..0ece731 100644
--- a/test/aes192ofb_encrypt_block.c
+++ b/test/aes192ofb_encrypt_block.c
@@ -22,9 +22,9 @@ int main(int argc, char** argv)
{
for (--argc, ++argv; argc > -1; --argc, ++argv)
{
- AesNI_Block128 plain, cipher, iv;
+ AesNI_Block128 plaintext, ciphertext, iv;
AesNI_Block192 key;
- AesNI_Aes192_RoundKeys key_schedule;
+ AesNI_Aes192_RoundKeys encryption_keys;
if (argc < 2)
exit_with_usage();
@@ -41,20 +41,20 @@ int main(int argc, char** argv)
exit_with_usage();
}
- aesni_aes192_expand_key(&key, &key_schedule);
+ aesni_aes192_expand_key(&key, &encryption_keys);
for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
{
if (strcmp("--", *argv) == 0)
break;
- if (aesni_is_error(aesni_parse_block128(&plain, *argv, NULL)))
+ if (aesni_is_error(aesni_parse_block128(&plaintext, *argv, NULL)))
{
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- cipher = aesni_aes192_encrypt_block_ofb(plain, &key_schedule, iv, &iv);
- aesni_print_block128(&cipher, NULL);
+ ciphertext = aesni_aes192_encrypt_block_ofb(plaintext, &encryption_keys, iv, &iv);
+ aesni_print_block128(&ciphertext, NULL);
}
}
diff --git a/test/aes256cbc_decrypt_block.c b/test/aes256cbc_decrypt_block.c
index 7cfd85a..c65d5e5 100644
--- a/test/aes256cbc_decrypt_block.c
+++ b/test/aes256cbc_decrypt_block.c
@@ -22,9 +22,9 @@ int main(int argc, char** argv)
{
for (--argc, ++argv; argc > -1; --argc, ++argv)
{
- AesNI_Block128 plain, cipher, iv;
+ AesNI_Block128 plaintext, ciphertext, iv;
AesNI_Block256 key;
- AesNI_Aes256_RoundKeys key_schedule, inverted_schedule;
+ AesNI_Aes256_RoundKeys encryption_keys, decryption_keys;
if (argc < 2)
exit_with_usage();
@@ -41,21 +41,21 @@ int main(int argc, char** argv)
exit_with_usage();
}
- aesni_aes256_expand_key(&key, &key_schedule);
- aesni_aes256_derive_decryption_keys(&key_schedule, &inverted_schedule);
+ aesni_aes256_expand_key(&key, &encryption_keys);
+ aesni_aes256_derive_decryption_keys(&encryption_keys, &decryption_keys);
for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
{
if (strcmp("--", *argv) == 0)
break;
- if (aesni_is_error(aesni_parse_block128(&cipher, *argv, NULL)))
+ if (aesni_is_error(aesni_parse_block128(&ciphertext, *argv, NULL)))
{
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- plain = aesni_aes256_decrypt_block_cbc(cipher, &inverted_schedule, iv, &iv);
- aesni_print_block128(&plain, NULL);
+ plaintext = aesni_aes256_decrypt_block_cbc(ciphertext, &decryption_keys, iv, &iv);
+ aesni_print_block128(&plaintext, NULL);
}
}
diff --git a/test/aes256cbc_encrypt_block.c b/test/aes256cbc_encrypt_block.c
index 9c0c24b..76c3b4e 100644
--- a/test/aes256cbc_encrypt_block.c
+++ b/test/aes256cbc_encrypt_block.c
@@ -22,9 +22,9 @@ int main(int argc, char** argv)
{
for (--argc, ++argv; argc > -1; --argc, ++argv)
{
- AesNI_Block128 plain, cipher, iv;
+ AesNI_Block128 plaintext, ciphertext, iv;
AesNI_Block256 key;
- AesNI_Aes256_RoundKeys key_schedule;
+ AesNI_Aes256_RoundKeys encryption_keys;
if (argc < 2)
exit_with_usage();
@@ -41,20 +41,20 @@ int main(int argc, char** argv)
exit_with_usage();
}
- aesni_aes256_expand_key(&key, &key_schedule);
+ aesni_aes256_expand_key(&key, &encryption_keys);
for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
{
if (strcmp("--", *argv) == 0)
break;
- if (aesni_is_error(aesni_parse_block128(&plain, *argv, NULL)))
+ if (aesni_is_error(aesni_parse_block128(&plaintext, *argv, NULL)))
{
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- cipher = aesni_aes256_encrypt_block_cbc(plain, &key_schedule, iv, &iv);
- aesni_print_block128(&cipher, NULL);
+ ciphertext = aesni_aes256_encrypt_block_cbc(plaintext, &encryption_keys, iv, &iv);
+ aesni_print_block128(&ciphertext, NULL);
}
}
diff --git a/test/aes256cfb_decrypt_block.c b/test/aes256cfb_decrypt_block.c
index 3f8f696..7c356a6 100644
--- a/test/aes256cfb_decrypt_block.c
+++ b/test/aes256cfb_decrypt_block.c
@@ -22,9 +22,9 @@ int main(int argc, char** argv)
{
for (--argc, ++argv; argc > -1; --argc, ++argv)
{
- AesNI_Block128 plain, cipher, iv;
+ AesNI_Block128 plaintext, ciphertext, iv;
AesNI_Block256 key;
- AesNI_Aes256_RoundKeys key_schedule;
+ AesNI_Aes256_RoundKeys encryption_keys;
if (argc < 2)
exit_with_usage();
@@ -41,20 +41,20 @@ int main(int argc, char** argv)
exit_with_usage();
}
- aesni_aes256_expand_key(&key, &key_schedule);
+ aesni_aes256_expand_key(&key, &encryption_keys);
for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
{
if (strcmp("--", *argv) == 0)
break;
- if (aesni_is_error(aesni_parse_block128(&cipher, *argv, NULL)))
+ if (aesni_is_error(aesni_parse_block128(&ciphertext, *argv, NULL)))
{
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- plain = aesni_aes256_decrypt_block_cfb(cipher, &key_schedule, iv, &iv);
- aesni_print_block128(&plain, NULL);
+ plaintext = aesni_aes256_decrypt_block_cfb(ciphertext, &encryption_keys, iv, &iv);
+ aesni_print_block128(&plaintext, NULL);
}
}
diff --git a/test/aes256cfb_encrypt_block.c b/test/aes256cfb_encrypt_block.c
index aca05a8..7d95658 100644
--- a/test/aes256cfb_encrypt_block.c
+++ b/test/aes256cfb_encrypt_block.c
@@ -22,9 +22,9 @@ int main(int argc, char** argv)
{
for (--argc, ++argv; argc > -1; --argc, ++argv)
{
- AesNI_Block128 plain, cipher, iv;
+ AesNI_Block128 plaintext, ciphertext, iv;
AesNI_Block256 key;
- AesNI_Aes256_RoundKeys key_schedule;
+ AesNI_Aes256_RoundKeys encryption_keys;
if (argc < 2)
exit_with_usage();
@@ -41,20 +41,20 @@ int main(int argc, char** argv)
exit_with_usage();
}
- aesni_aes256_expand_key(&key, &key_schedule);
+ aesni_aes256_expand_key(&key, &encryption_keys);
for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
{
if (strcmp("--", *argv) == 0)
break;
- if (aesni_is_error(aesni_parse_block128(&plain, *argv, NULL)))
+ if (aesni_is_error(aesni_parse_block128(&plaintext, *argv, NULL)))
{
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- cipher = aesni_aes256_encrypt_block_cfb(plain, &key_schedule, iv, &iv);
- aesni_print_block128(&cipher, NULL);
+ ciphertext = aesni_aes256_encrypt_block_cfb(plaintext, &encryption_keys, iv, &iv);
+ aesni_print_block128(&ciphertext, NULL);
}
}
diff --git a/test/aes256ctr_decrypt_block.c b/test/aes256ctr_decrypt_block.c
index 8255a11..71f9854 100644
--- a/test/aes256ctr_decrypt_block.c
+++ b/test/aes256ctr_decrypt_block.c
@@ -22,9 +22,9 @@ int main(int argc, char** argv)
{
for (--argc, ++argv; argc > -1; --argc, ++argv)
{
- AesNI_Block128 plain, cipher, iv;
+ AesNI_Block128 plaintext, ciphertext, iv;
AesNI_Block256 key;
- AesNI_Aes256_RoundKeys key_schedule;
+ AesNI_Aes256_RoundKeys encryption_keys;
if (argc < 2)
exit_with_usage();
@@ -41,7 +41,7 @@ int main(int argc, char** argv)
exit_with_usage();
}
- aesni_aes256_expand_key(&key, &key_schedule);
+ aesni_aes256_expand_key(&key, &encryption_keys);
int ctr = 0;
@@ -50,13 +50,13 @@ int main(int argc, char** argv)
if (strcmp("--", *argv) == 0)
break;
- if (aesni_is_error(aesni_parse_block128(&cipher, *argv, NULL)))
+ if (aesni_is_error(aesni_parse_block128(&ciphertext, *argv, NULL)))
{
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- plain = aesni_aes256_decrypt_block_ctr(cipher, &key_schedule, iv, ctr++);
- aesni_print_block128(&plain, NULL);
+ plaintext = aesni_aes256_decrypt_block_ctr(ciphertext, &encryption_keys, iv, ctr++);
+ aesni_print_block128(&plaintext, NULL);
}
}
diff --git a/test/aes256ctr_encrypt_block.c b/test/aes256ctr_encrypt_block.c
index 580c6e7..c0452f1 100644
--- a/test/aes256ctr_encrypt_block.c
+++ b/test/aes256ctr_encrypt_block.c
@@ -22,9 +22,9 @@ int main(int argc, char** argv)
{
for (--argc, ++argv; argc > -1; --argc, ++argv)
{
- AesNI_Block128 plain, cipher, iv;
+ AesNI_Block128 plaintext, ciphertext, iv;
AesNI_Block256 key;
- AesNI_Aes256_RoundKeys key_schedule;
+ AesNI_Aes256_RoundKeys encryption_keys;
if (argc < 2)
exit_with_usage();
@@ -41,7 +41,7 @@ int main(int argc, char** argv)
exit_with_usage();
}
- aesni_aes256_expand_key(&key, &key_schedule);
+ aesni_aes256_expand_key(&key, &encryption_keys);
int ctr = 0;
@@ -50,13 +50,13 @@ int main(int argc, char** argv)
if (strcmp("--", *argv) == 0)
break;
- if (aesni_is_error(aesni_parse_block128(&plain, *argv, NULL)))
+ if (aesni_is_error(aesni_parse_block128(&plaintext, *argv, NULL)))
{
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- cipher = aesni_aes256_encrypt_block_ctr(plain, &key_schedule, iv, ctr++);
- aesni_print_block128(&cipher, NULL);
+ ciphertext = aesni_aes256_encrypt_block_ctr(plaintext, &encryption_keys, iv, ctr++);
+ aesni_print_block128(&ciphertext, NULL);
}
}
diff --git a/test/aes256ecb_decrypt_block.c b/test/aes256ecb_decrypt_block.c
index f4b38c5..c1f84b9 100644
--- a/test/aes256ecb_decrypt_block.c
+++ b/test/aes256ecb_decrypt_block.c
@@ -22,9 +22,9 @@ int main(int argc, char** argv)
{
for (--argc, ++argv; argc > -1; --argc, ++argv)
{
- AesNI_Block128 plain, cipher;
+ AesNI_Block128 plaintext, ciphertext;
AesNI_Block256 key;
- AesNI_Aes256_RoundKeys key_schedule, inverted_schedule;
+ AesNI_Aes256_RoundKeys encryption_keys, decryption_keys;
if (argc < 1)
exit_with_usage();
@@ -35,21 +35,21 @@ int main(int argc, char** argv)
exit_with_usage();
}
- aesni_aes256_expand_key(&key, &key_schedule);
- aesni_aes256_derive_decryption_keys(&key_schedule, &inverted_schedule);
+ aesni_aes256_expand_key(&key, &encryption_keys);
+ aesni_aes256_derive_decryption_keys(&encryption_keys, &decryption_keys);
for (--argc, ++argv; argc > 0; --argc, ++argv)
{
if (strcmp("--", *argv) == 0)
break;
- if (aesni_is_error(aesni_parse_block128(&cipher, *argv, NULL)))
+ if (aesni_is_error(aesni_parse_block128(&ciphertext, *argv, NULL)))
{
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- plain = aesni_aes256_decrypt_block_ecb(cipher, &inverted_schedule);
- aesni_print_block128(&plain, NULL);
+ plaintext = aesni_aes256_decrypt_block_ecb(ciphertext, &decryption_keys);
+ aesni_print_block128(&plaintext, NULL);
}
}
diff --git a/test/aes256ecb_encrypt_block.c b/test/aes256ecb_encrypt_block.c
index 7752383..f12f1a2 100644
--- a/test/aes256ecb_encrypt_block.c
+++ b/test/aes256ecb_encrypt_block.c
@@ -22,9 +22,9 @@ int main(int argc, char** argv)
{
for (--argc, ++argv; argc > -1; --argc, ++argv)
{
- AesNI_Block128 plain, cipher;
+ AesNI_Block128 plaintext, ciphertext;
AesNI_Block256 key;
- AesNI_Aes256_RoundKeys key_schedule;
+ AesNI_Aes256_RoundKeys encryption_keys;
if (argc < 1)
exit_with_usage();
@@ -35,20 +35,20 @@ int main(int argc, char** argv)
exit_with_usage();
}
- aesni_aes256_expand_key(&key, &key_schedule);
+ aesni_aes256_expand_key(&key, &encryption_keys);
for (--argc, ++argv; argc > 0; --argc, ++argv)
{
if (strcmp("--", *argv) == 0)
break;
- if (aesni_is_error(aesni_parse_block128(&plain, *argv, NULL)))
+ if (aesni_is_error(aesni_parse_block128(&plaintext, *argv, NULL)))
{
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- cipher = aesni_aes256_encrypt_block_ecb(plain, &key_schedule);
- aesni_print_block128(&cipher, NULL);
+ ciphertext = aesni_aes256_encrypt_block_ecb(plaintext, &encryption_keys);
+ aesni_print_block128(&ciphertext, NULL);
}
}
diff --git a/test/aes256ofb_decrypt_block.c b/test/aes256ofb_decrypt_block.c
index b1c533d..dfd29bc 100644
--- a/test/aes256ofb_decrypt_block.c
+++ b/test/aes256ofb_decrypt_block.c
@@ -22,9 +22,9 @@ int main(int argc, char** argv)
{
for (--argc, ++argv; argc > -1; --argc, ++argv)
{
- AesNI_Block128 plain, cipher, iv;
+ AesNI_Block128 plaintext, ciphertext, iv;
AesNI_Block256 key;
- AesNI_Aes256_RoundKeys key_schedule;
+ AesNI_Aes256_RoundKeys encryption_keys;
if (argc < 2)
exit_with_usage();
@@ -41,20 +41,20 @@ int main(int argc, char** argv)
exit_with_usage();
}
- aesni_aes256_expand_key(&key, &key_schedule);
+ aesni_aes256_expand_key(&key, &encryption_keys);
for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
{
if (strcmp("--", *argv) == 0)
break;
- if (aesni_is_error(aesni_parse_block128(&cipher, *argv, NULL)))
+ if (aesni_is_error(aesni_parse_block128(&ciphertext, *argv, NULL)))
{
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- plain = aesni_aes256_decrypt_block_ofb(cipher, &key_schedule, iv, &iv);
- aesni_print_block128(&plain, NULL);
+ plaintext = aesni_aes256_decrypt_block_ofb(ciphertext, &encryption_keys, iv, &iv);
+ aesni_print_block128(&plaintext, NULL);
}
}
diff --git a/test/aes256ofb_encrypt_block.c b/test/aes256ofb_encrypt_block.c
index 975a653..7d65671 100644
--- a/test/aes256ofb_encrypt_block.c
+++ b/test/aes256ofb_encrypt_block.c
@@ -22,9 +22,9 @@ int main(int argc, char** argv)
{
for (--argc, ++argv; argc > -1; --argc, ++argv)
{
- AesNI_Block128 plain, cipher, iv;
+ AesNI_Block128 plaintext, ciphertext, iv;
AesNI_Block256 key;
- AesNI_Aes256_RoundKeys key_schedule;
+ AesNI_Aes256_RoundKeys encryption_keys;
if (argc < 2)
exit_with_usage();
@@ -41,20 +41,20 @@ int main(int argc, char** argv)
exit_with_usage();
}
- aesni_aes256_expand_key(&key, &key_schedule);
+ aesni_aes256_expand_key(&key, &encryption_keys);
for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
{
if (strcmp("--", *argv) == 0)
break;
- if (aesni_is_error(aesni_parse_block128(&plain, *argv, NULL)))
+ if (aesni_is_error(aesni_parse_block128(&plaintext, *argv, NULL)))
{
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- cipher = aesni_aes256_encrypt_block_ofb(plain, &key_schedule, iv, &iv);
- aesni_print_block128(&cipher, NULL);
+ ciphertext = aesni_aes256_encrypt_block_ofb(plaintext, &encryption_keys, iv, &iv);
+ aesni_print_block128(&ciphertext, NULL);
}
}
diff --git a/utils/aes128ecb_decrypt_file.cpp b/utils/aes128ecb_decrypt_file.cpp
index b2abe8f..0f88144 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_Aes128_RoundKeys key_schedule, inverted_schedule;
+ AesNI_Aes128_RoundKeys encryption_keys, decryption_keys;
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_aes128_expand_key(key, &key_schedule);
- aesni_aes128_derive_decryption_keys(&key_schedule, &inverted_schedule);
+ aesni_aes128_expand_key(key, &encryption_keys);
+ aesni_aes128_derive_decryption_keys(&encryption_keys, &decryption_keys);
std::size_t dest_size;
@@ -70,7 +70,7 @@ int main(int argc, char** argv)
src_size,
NULL,
&dest_size,
- &inverted_schedule,
+ &decryption_keys,
aesni::ErrorDetailsThrowsInDestructor());
std::vector<char> dest_buf;
@@ -81,7 +81,7 @@ int main(int argc, char** argv)
src_size,
dest_buf.data(),
&dest_size,
- &inverted_schedule,
+ &decryption_keys,
aesni::ErrorDetailsThrowsInDestructor());
std::ofstream dest_ofs;
diff --git a/utils/aes128ecb_encrypt_file.cpp b/utils/aes128ecb_encrypt_file.cpp
index 05863c2..c7fef82 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_Aes128_RoundKeys key_schedule;
+ AesNI_Aes128_RoundKeys encryption_keys;
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_aes128_expand_key(key, &key_schedule);
+ aesni_aes128_expand_key(key, &encryption_keys);
std::size_t dest_size;
@@ -69,7 +69,7 @@ int main(int argc, char** argv)
src_size,
NULL,
&dest_size,
- &key_schedule,
+ &encryption_keys,
aesni::ErrorDetailsThrowsInDestructor());
std::vector<char> dest_buf;
@@ -80,7 +80,7 @@ int main(int argc, char** argv)
src_size,
dest_buf.data(),
&dest_size,
- &key_schedule,
+ &encryption_keys,
aesni::ErrorDetailsThrowsInDestructor());
std::ofstream dest_ofs;