diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2015-06-15 02:55:10 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2015-06-15 02:55:10 +0300 |
commit | 2d67b793e64f6ed4e2e6a7c56441b9bc019e2659 (patch) | |
tree | abc83a07b5905eec76041b3aad686c5d4117bea7 /include/aesni | |
parent | error handling refactoring + more docs (diff) | |
download | aes-tools-2d67b793e64f6ed4e2e6a7c56441b9bc019e2659.tar.gz aes-tools-2d67b793e64f6ed4e2e6a7c56441b9bc019e2659.zip |
code style
Diffstat (limited to 'include/aesni')
-rw-r--r-- | include/aesni/all.h | 5 | ||||
-rw-r--r-- | include/aesni/block.h | 310 | ||||
-rw-r--r-- | include/aesni/buffer.h | 1 | ||||
-rw-r--r-- | include/aesni/data.h | 30 | ||||
-rw-r--r-- | include/aesni/error.h | 5 | ||||
-rw-r--r-- | include/aesni/raw.h | 56 |
6 files changed, 270 insertions, 137 deletions
diff --git a/include/aesni/all.h b/include/aesni/all.h index 6f00fb7..350e4dd 100644 --- a/include/aesni/all.h +++ b/include/aesni/all.h @@ -4,8 +4,9 @@ * \date 2015 * \copyright This file is licensed under the terms of the MIT License. * See LICENSE.txt for details. - * \brief Include this file to use libaesni. - * Includes all of the other libaesni's header files. + * + * \brief Include this file to use the library. Includes all the other header + * files. */ #pragma once diff --git a/include/aesni/block.h b/include/aesni/block.h index a2a4b1b..47697af 100644 --- a/include/aesni/block.h +++ b/include/aesni/block.h @@ -4,6 +4,7 @@ * \date 2015 * \copyright This file is licensed under the terms of the MIT License. * See LICENSE.txt for details. + * * \brief Declares 128-bit block encryption/decryption functions. */ @@ -61,7 +62,8 @@ extern "C" * \brief Expands a key schedule for AES-128 encryption. * * \param[in] key The AES-128 key. - * \param[out] key_schedule The AES-128 encryption key schedule. Must not be `NULL`. + * \param[out] key_schedule The AES-128 encryption key schedule. Must not be + * `NULL`. */ static __inline void __fastcall aesni_expand_key_schedule128( AesNI_Block128 key, @@ -73,10 +75,12 @@ static __inline void __fastcall aesni_expand_key_schedule128( } /** - * \brief "Reverses" a key schedule for AES-128 "equivalent inverse cipher" decryption. + * \brief "Inverts" an AES-128 key schedule to prepare for decryption. * - * \param[in] key_schedule The AES-128 encryption key schedule. Must not be `NULL`. - * \param[out] inverted_schedule The AES-128 decryption key schedule. Must not be `NULL`. + * \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`. */ static __inline void __fastcall aesni_invert_key_schedule128( AesNI_KeySchedule128* key_schedule, @@ -92,7 +96,8 @@ static __inline void __fastcall aesni_invert_key_schedule128( * \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 schedule. Must not be `NULL`. + * \param[in] key_schedule The AES-128 encryption key schedule. Must not be + * `NULL`. * \return The encrypted 128-bit ciphertext. */ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_ecb128( @@ -108,7 +113,8 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_ecb128( * \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 ("reversed") key schedule. Must not be `NULL`. + * \param[in] inverted_schedule The AES-128 decryption key schedule. Must not + * be `NULL`. * \return The decrypted 128-bit plaintext. */ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_ecb128( @@ -124,9 +130,11 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_ecb128( * \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] key_schedule The AES-128 encryption key schedule. 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 next CBC initialization vector to be used + * as the initialization vector for the next call. Must not be `NULL`. * \return The encrypted 128-bit ciphertext. */ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_cbc128( @@ -138,7 +146,9 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_cbc128( assert(key_schedule); assert(next_init_vector); - AesNI_Block128 cipher = aesni_raw_encrypt_block128(_mm_xor_si128(plain, init_vector), key_schedule); + AesNI_Block128 cipher = aesni_raw_encrypt_block128( + _mm_xor_si128(plain, init_vector), + key_schedule); *next_init_vector = cipher; return cipher; } @@ -147,9 +157,11 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_cbc128( * \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 (reversed) key schedule. Must not be `NULL`. + * \param[in] inverted_schedule The AES-128 decryption key schedule. 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 next CBC initialization vector to be used + * as the initialization vector for the next call. Must not be `NULL`. * \return The decrypted 128-bit plaintext. */ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_cbc128( @@ -161,7 +173,9 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_cbc128( assert(inverted_schedule); assert(next_init_vector); - AesNI_Block128 plain = _mm_xor_si128(aesni_raw_decrypt_block128(cipher, inverted_schedule), init_vector); + AesNI_Block128 plain = _mm_xor_si128( + aesni_raw_decrypt_block128(cipher, inverted_schedule), + init_vector); *next_init_vector = cipher; return plain; } @@ -170,9 +184,11 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_cbc128( * \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 schedule. Must not be `NULL`. + * \param[in] key_schedule The AES-128 encryption key schedule. 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 next CFB initialization vector to be used + * as the initialization vector for the next call. Must not be `NULL`. * \return The encrypted 128-bit ciphertext. */ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_cfb128( @@ -184,7 +200,9 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_cfb128( assert(key_schedule); assert(next_init_vector); - AesNI_Block128 cipher = _mm_xor_si128(aesni_raw_encrypt_block128(init_vector, key_schedule), plain); + AesNI_Block128 cipher = _mm_xor_si128( + aesni_raw_encrypt_block128(init_vector, key_schedule), + plain); *next_init_vector = cipher; return cipher; } @@ -193,9 +211,11 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_cfb128( * \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] key_schedule The AES-128 **encryption** key schedule. 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 next CFB initialization vector to be used + * as the initialization vector for the next call. Must not be `NULL`. * \return The decrypted 128-bit plaintext. */ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_cfb128( @@ -207,7 +227,9 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_cfb128( assert(key_schedule); assert(next_init_vector); - AesNI_Block128 plain = _mm_xor_si128(aesni_raw_encrypt_block128(init_vector, key_schedule), cipher); + AesNI_Block128 plain = _mm_xor_si128( + aesni_raw_encrypt_block128(init_vector, key_schedule), + cipher); *next_init_vector = cipher; return plain; } @@ -216,9 +238,11 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_cfb128( * \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 schedule. Must not be `NULL`. + * \param[in] key_schedule The AES-128 encryption key schedule. 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 next OFB initialization vector to be used + * as the initialization vector for the next call. Must not be `NULL`. * \return The encrypted 128-bit ciphertext. */ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_ofb128( @@ -239,9 +263,11 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_ofb128( * \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] key_schedule The AES-128 **encryption** key schedule. 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 next OFB initialization vector to be used + * as the initialization vector for the next call. Must not be `NULL`. * \return The decrypted 128-bit plaintext. */ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_ofb128( @@ -262,9 +288,11 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_ofb128( * \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] key_schedule The AES-128 encryption key schedule. 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_encrypt_block_ctr128( @@ -275,19 +303,24 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_ctr128( { assert(key_schedule); - 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 _mm_xor_si128(plain, aesni_raw_encrypt_block128(init_vector, key_schedule)); + init_vector = aesni_be2le128(_mm_add_epi32( + aesni_le2be128(init_vector), + aesni_make_block128(0, 0, 0, counter))); + + return _mm_xor_si128( + plain, + aesni_raw_encrypt_block128(init_vector, key_schedule)); } /** * \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] key_schedule The AES-128 **encryption** key schedule. 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_decrypt_block_ctr128( @@ -298,10 +331,13 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_ctr128( { assert(key_schedule); - 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 _mm_xor_si128(cipher, aesni_raw_encrypt_block128(init_vector, key_schedule)); + init_vector = aesni_be2le128(_mm_add_epi32( + aesni_le2be128(init_vector), + aesni_make_block128(0, 0, 0, counter))); + + return _mm_xor_si128( + cipher, + aesni_raw_encrypt_block128(init_vector, key_schedule)); } /** @@ -315,7 +351,8 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_ctr128( * \brief Expands a key schedule for AES-192 encryption. * * \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[out] key_schedule The AES-192 encryption key schedule. Must not be + * `NULL`. */ static __inline void __fastcall aesni_expand_key_schedule192( AesNI_Block192* key, @@ -328,10 +365,12 @@ static __inline void __fastcall aesni_expand_key_schedule192( } /** - * \brief "Reverses" a key schedule for AES-192 "equivalent inverse cipher" decryption. + * \brief "Inverts" an AES-192 key schedule to prepare for decryption. * - * \param[in] key_schedule The AES-192 encryption key schedule. Must not be `NULL`. - * \param[out] inverted_schedule The AES-192 decryption key schedule. Must not be `NULL`. + * \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`. */ static __inline void __fastcall aesni_invert_key_schedule192( AesNI_KeySchedule192* key_schedule, @@ -347,7 +386,8 @@ static __inline void __fastcall aesni_invert_key_schedule192( * \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 schedule. Must not be `NULL`. + * \param[in] key_schedule The AES-192 encryption key schedule. Must not be + * `NULL`. * \return The encrypted 128-bit ciphertext. */ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_ecb192( @@ -363,7 +403,8 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_ecb192( * \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 (reversed) key schedule. Must not be `NULL`. + * \param[in] inverted_schedule The AES-192 decryption key schedule. Must not + * be `NULL`. * \return The decrypted 128-bit plaintext. */ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_ecb192( @@ -379,9 +420,11 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_ecb192( * \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 schedule. Must not be `NULL`. + * \param[in] key_schedule The AES-192 encryption key schedule. 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 next CBC initialization vector to be used + * as the initialization vector for the next call. Must not be `NULL`. * \return The encrypted 128-bit ciphertext. */ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_cbc192( @@ -393,7 +436,9 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_cbc192( assert(key_schedule); assert(next_init_vector); - AesNI_Block128 cipher = aesni_raw_encrypt_block192(_mm_xor_si128(plain, init_vector), key_schedule); + AesNI_Block128 cipher = aesni_raw_encrypt_block192( + _mm_xor_si128(plain, init_vector), + key_schedule); *next_init_vector = cipher; return cipher; } @@ -402,9 +447,11 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_cbc192( * \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 (reversed) key schedule. Must not be `NULL`. + * \param[in] inverted_schedule The AES-192 decryption key schedule. 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 next CBC initialization vector to be used + * as the initialization vector for the next call. Must not be `NULL`. * \return The decrypted 128-bit plaintext. */ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_cbc192( @@ -416,7 +463,9 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_cbc192( assert(inverted_schedule); assert(next_init_vector); - AesNI_Block128 plain = _mm_xor_si128(aesni_raw_decrypt_block192(cipher, inverted_schedule), init_vector); + AesNI_Block128 plain = _mm_xor_si128( + aesni_raw_decrypt_block192(cipher, inverted_schedule), + init_vector); *next_init_vector = cipher; return plain; } @@ -425,9 +474,11 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_cbc192( * \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 schedule. Must not be `NULL`. + * \param[in] key_schedule The AES-192 encryption key schedule. 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 next CFB initialization vector to be used + * as the initialization vector for the next call. Must not be `NULL`. * \return The encrypted 128-bit ciphertext. */ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_cfb192( @@ -439,7 +490,9 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_cfb192( assert(key_schedule); assert(next_init_vector); - AesNI_Block128 cipher = _mm_xor_si128(aesni_raw_encrypt_block192(init_vector, key_schedule), plain); + AesNI_Block128 cipher = _mm_xor_si128( + aesni_raw_encrypt_block192(init_vector, key_schedule), + plain); *next_init_vector = cipher; return cipher; } @@ -448,9 +501,11 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_cfb192( * \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] key_schedule The AES-192 **encryption** key schedule. 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 next CFB initialization vector to be used + * as the initialization vector for the next call. Must not be `NULL`. * \return The decrypted 128-bit plaintext. */ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_cfb192( @@ -462,7 +517,9 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_cfb192( assert(key_schedule); assert(next_init_vector); - AesNI_Block128 plain = _mm_xor_si128(aesni_raw_encrypt_block192(init_vector, key_schedule), cipher); + AesNI_Block128 plain = _mm_xor_si128( + aesni_raw_encrypt_block192(init_vector, key_schedule), + cipher); *next_init_vector = cipher; return plain; } @@ -471,9 +528,11 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_cfb192( * \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 schedule. Must not be `NULL`. + * \param[in] key_schedule The AES-192 encryption key schedule. 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 next OFB initialization vector to be used + * as the initialization vector for the next call. Must not be `NULL`. * \return The encrypted 128-bit ciphertext. */ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_ofb192( @@ -494,9 +553,11 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_ofb192( * \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] key_schedule The AES-192 **encryption** key schedule. 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 next OFB initialization vector to be used + * as the initialization vector for the next call. Must not be `NULL`. * \return The decrypted 128-bit plaintext. */ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_ofb192( @@ -517,9 +578,11 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_ofb192( * \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] key_schedule The AES-192 encryption key schedule. 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_encrypt_block_ctr192( @@ -530,19 +593,24 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_ctr192( { assert(key_schedule); - 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 _mm_xor_si128(plain, aesni_raw_encrypt_block192(init_vector, key_schedule)); + init_vector = aesni_be2le128(_mm_add_epi32( + aesni_le2be128(init_vector), + aesni_make_block128(0, 0, 0, counter))); + + return _mm_xor_si128( + plain, + aesni_raw_encrypt_block192(init_vector, key_schedule)); } /** * \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] key_schedule The AES-192 **encryption** key schedule. 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_decrypt_block_ctr192( @@ -553,10 +621,13 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_ctr192( { assert(key_schedule); - 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 _mm_xor_si128(cipher, aesni_raw_encrypt_block192(init_vector, key_schedule)); + init_vector = aesni_be2le128(_mm_add_epi32( + aesni_le2be128(init_vector), + aesni_make_block128(0, 0, 0, counter))); + + return _mm_xor_si128( + cipher, + aesni_raw_encrypt_block192(init_vector, key_schedule)); } /** @@ -570,7 +641,8 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_ctr192( * \brief Expands a key schedule for AES-256 encryption. * * \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[out] key_schedule The AES-256 encryption key schedule. Must not be + * `NULL`. */ static __inline void __fastcall aesni_expand_key_schedule256( AesNI_Block256* key, @@ -583,10 +655,12 @@ static __inline void __fastcall aesni_expand_key_schedule256( } /** - * \brief "Reverses" a key schedule for AES-256 "equivalent inverse cipher" decryption. + * \brief "Inverts" an AES-256 key schedule to prepare for decryption. * - * \param[in] key_schedule The AES-256 encryption key schedule. Must not be `NULL`. - * \param[out] inverted_schedule The AES-256 decryption key schedule. Must not be `NULL`. + * \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`. */ static __inline void __fastcall aesni_invert_key_schedule256( AesNI_KeySchedule256* key_schedule, @@ -602,7 +676,8 @@ static __inline void __fastcall aesni_invert_key_schedule256( * \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 schedule. Must not be `NULL`. + * \param[in] key_schedule The AES-256 encryption key schedule. Must not be + * `NULL`. * \return The encrypted 128-bit ciphertext. */ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_ecb256( @@ -618,7 +693,8 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_ecb256( * \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 (reversed) key schedule. Must not be `NULL`. + * \param[in] inverted_schedule The AES-256 decryption key schedule. Must not + * be `NULL`. * \return The decrypted 128-bit plaintext. */ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_ecb256( @@ -634,9 +710,11 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_ecb256( * \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 schedule. Must not be `NULL`. + * \param[in] key_schedule The AES-256 encryption key schedule. 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 next CBC initialization vector to be used + * as the initialization vector for the next call. Must not be `NULL`. * \return The encrypted 128-bit ciphertext. */ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_cbc256( @@ -648,7 +726,9 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_cbc256( assert(key_schedule); assert(next_init_vector); - AesNI_Block128 cipher = aesni_raw_encrypt_block256(_mm_xor_si128(plain, init_vector), key_schedule); + AesNI_Block128 cipher = aesni_raw_encrypt_block256( + _mm_xor_si128(plain, init_vector), + key_schedule); *next_init_vector = cipher; return cipher; } @@ -657,9 +737,11 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_cbc256( * \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 (reversed) key schedule. Must not be `NULL`. + * \param[in] inverted_schedule The AES-256 decryption key schedule. 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 next CBC initialization vector to be used + * as the initialization vector for the next call. Must not be `NULL`. * \return The decrypted 128-bit plaintext. */ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_cbc256( @@ -671,7 +753,9 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_cbc256( assert(inverted_schedule); assert(next_init_vector); - AesNI_Block128 plain = _mm_xor_si128(aesni_raw_decrypt_block256(cipher, inverted_schedule), init_vector); + AesNI_Block128 plain = _mm_xor_si128( + aesni_raw_decrypt_block256(cipher, inverted_schedule), + init_vector); *next_init_vector = cipher; return plain; } @@ -680,9 +764,11 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_cbc256( * \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 schedule. Must not be `NULL`. + * \param[in] key_schedule The AES-256 encryption key schedule. 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 next CFB initialization vector to be used + * as the initialization vector for the next call. Must not be `NULL`. * \return The encrypted 128-bit ciphertext. */ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_cfb256( @@ -694,7 +780,9 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_cfb256( assert(key_schedule); assert(next_init_vector); - AesNI_Block128 cipher = _mm_xor_si128(aesni_raw_encrypt_block256(init_vector, key_schedule), plain); + AesNI_Block128 cipher = _mm_xor_si128( + aesni_raw_encrypt_block256(init_vector, key_schedule), + plain); *next_init_vector = cipher; return cipher; } @@ -703,9 +791,11 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_cfb256( * \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] key_schedule The AES-256 **encryption** key schedule. 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 next CFB initialization vector to be used + * as the initialization vector for the next call. Must not be `NULL`. * \return The decrypted 128-bit plaintext. */ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_cfb256( @@ -717,7 +807,9 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_cfb256( assert(key_schedule); assert(next_init_vector); - AesNI_Block128 plain = _mm_xor_si128(aesni_raw_encrypt_block256(init_vector, key_schedule), cipher); + AesNI_Block128 plain = _mm_xor_si128( + aesni_raw_encrypt_block256(init_vector, key_schedule), + cipher); *next_init_vector = cipher; return plain; } @@ -726,9 +818,11 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_cfb256( * \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 schedule. Must not be `NULL`. + * \param[in] key_schedule The AES-256 encryption key schedule. 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 next OFB initialization vector to be used + * as the initialization vector for the next call. Must not be `NULL`. * \return The encrypted 128-bit ciphertext. */ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_ofb256( @@ -749,9 +843,11 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_ofb256( * \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] key_schedule The AES-256 **encryption** key schedule. 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 next OFB initialization vector to be used + * as the initialization vector for the next call. Must not be `NULL`. * \return The decrypted 128-bit plaintext. */ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_ofb256( @@ -772,9 +868,11 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_ofb256( * \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] key_schedule The AES-256 encryption key schedule. 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_encrypt_block_ctr256( @@ -785,19 +883,24 @@ static __inline AesNI_Block128 __fastcall aesni_encrypt_block_ctr256( { assert(key_schedule); - 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 _mm_xor_si128(plain, aesni_raw_encrypt_block256(init_vector, key_schedule)); + init_vector = aesni_be2le128(_mm_add_epi32( + aesni_le2be128(init_vector), + aesni_make_block128(0, 0, 0, counter))); + + return _mm_xor_si128( + plain, + aesni_raw_encrypt_block256(init_vector, key_schedule)); } /** * \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] key_schedule The AES-256 **encryption** key schedule. 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_decrypt_block_ctr256( @@ -808,10 +911,13 @@ static __inline AesNI_Block128 __fastcall aesni_decrypt_block_ctr256( { assert(key_schedule); - 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 _mm_xor_si128(cipher, aesni_raw_encrypt_block256(init_vector, key_schedule)); + init_vector = aesni_be2le128(_mm_add_epi32( + aesni_le2be128(init_vector), + aesni_make_block128(0, 0, 0, counter))); + + return _mm_xor_si128( + cipher, + aesni_raw_encrypt_block256(init_vector, key_schedule)); } /** diff --git a/include/aesni/buffer.h b/include/aesni/buffer.h index fff616f..2e5ecb9 100644 --- a/include/aesni/buffer.h +++ b/include/aesni/buffer.h @@ -4,6 +4,7 @@ * \date 2015 * \copyright This file is licensed under the terms of the MIT License. * See LICENSE.txt for details. + * * \brief Declares variable-length buffer encryption/decryption functions. */ diff --git a/include/aesni/data.h b/include/aesni/data.h index e7cf4ef..8b8162e 100644 --- a/include/aesni/data.h +++ b/include/aesni/data.h @@ -4,8 +4,9 @@ * \date 2015 * \copyright This file is licensed under the terms of the MIT License. * See LICENSE.txt for details. - * \brief Declares necessary data structures (for blocks, keys, etc.) - * and auxiliary I/O functions. + * + * \brief Declares necessary data structures (for blocks, keys, etc.) and + * auxiliary I/O functions. */ #pragma once @@ -44,7 +45,8 @@ static __inline AesNI_Block128 aesni_load_block128(const void* src) /** * \brief Loads a 128-bit block from a 16-byte aligned memory location. * - * \param[in] src The pointer to a 16-byte aligned memory location. Must not be `NULL`. + * \param[in] src The pointer to a 16-byte aligned memory location. Must not be + * `NULL`. * \return The loaded 128-bit block. */ static __inline AesNI_Block128 aseni_load_block128_aligned(const void* src) @@ -67,7 +69,8 @@ static __inline void __fastcall aesni_store_block128( /** * \brief Stores a 128-bit block in a 16-byte aligned memory location. * - * \param[out] dest The pointer to a 16-byte aligned memory location. Must not be `NULL`. + * \param[out] dest The pointer to a 16-byte aligned memory location. Must not + * be `NULL`. * \param[in] block The block to be stored. */ static __inline void __fastcall aesni_store_block128_aligned( @@ -92,7 +95,8 @@ static __inline void __fastcall aesni_store_block128_aligned( * \param[in] lo0 The least significant 4-byte value. * \return The built 128-bit block. */ -static __inline AesNI_Block128 __fastcall aesni_make_block128(int hi3, int hi2, int lo1, int lo0) +static __inline AesNI_Block128 __fastcall aesni_make_block128( + int hi3, int hi2, int lo1, int lo0) { return _mm_set_epi32(hi3, hi2, lo1, lo0); } @@ -102,7 +106,7 @@ static __inline AesNI_Block128 __fastcall aesni_make_block128(int hi3, int hi2, */ typedef struct { - AesNI_Block128 hi; ///< The most significant 64 bits. The higher 64 bits are ignored. + AesNI_Block128 hi; ///< The most significant 64 bits. AesNI_Block128 lo; ///< The least significant 128 bits. } AesNI_Block192; @@ -127,10 +131,11 @@ AesNI_Block192; * \param[in] lo0 The least significant 4-byte value (bits 0--31). * \return The built 192-bit block. */ -static __inline AesNI_Block192 __fastcall aesni_make_block192(int hi5, int hi4, int lo3, int lo2, int lo1, int lo0) +static __inline AesNI_Block192 __fastcall aesni_make_block192( + int hi5, int hi4, int lo3, int lo2, int lo1, int lo0) { AesNI_Block192 result; - result.hi = aesni_make_block128( 0, 0, hi5, hi4); + result.hi = aesni_make_block128(0, 0, hi5, hi4); result.lo = aesni_make_block128(lo3, lo2, lo1, lo0); return result; } @@ -169,7 +174,8 @@ AesNI_Block256; * \param[in] lo0 The 4-byte value to be stored in bits 0--31. * \return The built 256-bit block. */ -static __inline AesNI_Block256 __fastcall aesni_make_block256(int hi7, int hi6, int hi5, int hi4, int lo3, int lo2, int lo1, int lo0) +static __inline AesNI_Block256 __fastcall aesni_make_block256( + int hi7, int hi6, int hi5, int hi4, int lo3, int lo2, int lo1, int lo0) { AesNI_Block256 result; result.hi = aesni_make_block128(hi7, hi6, hi5, hi4); @@ -195,9 +201,11 @@ typedef struct } AesNI_KeySchedule256; -static __inline AesNI_Block128 __fastcall aesni_reverse_byte_order128(AesNI_Block128 block) +static __inline AesNI_Block128 __fastcall aesni_reverse_byte_order128( + AesNI_Block128 block) { - return _mm_shuffle_epi8(block, aesni_make_block128(0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f)); + return _mm_shuffle_epi8(block, aesni_make_block128( + 0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f)); } static __inline AesNI_Block128 __fastcall aesni_le2be128(AesNI_Block128 block) diff --git a/include/aesni/error.h b/include/aesni/error.h index 56a1da1..349ebe4 100644 --- a/include/aesni/error.h +++ b/include/aesni/error.h @@ -4,6 +4,7 @@ * \date 2015 * \copyright This file is licensed under the terms of the MIT License. * See LICENSE.txt for details. + * * \brief Declares error codes, error formatting functions, etc. */ @@ -111,8 +112,8 @@ static __inline AesNI_StatusCode aesni_get_error_code( * \param[out] dest The pointer to the destination string buffer. * \param[in] dest_size The size of the destination buffer, in bytes. * \return If `dest` is NULL, the number of bytes required to store the full - * error message, and the number of characters written (excluding the - * terminating '\0' character) otherwise. + * error message, and the number of characters written (excluding the + * terminating '\0' character) otherwise. */ size_t aesni_format_error( const AesNI_ErrorDetails* err_details, diff --git a/include/aesni/raw.h b/include/aesni/raw.h index 4b35266..fb29ce4 100644 --- a/include/aesni/raw.h +++ b/include/aesni/raw.h @@ -4,8 +4,9 @@ * \date 2015 * \copyright This file is licensed under the terms of the MIT License. * See LICENSE.txt for details. + * * \brief *Don't use.* Declares "raw" 128-bit block encryption/decryption - * functions. + * functions. */ #pragma once @@ -20,7 +21,7 @@ * * * a key schedule "expansion" function to prepare for encryption, * * a 128-bit block encryption function using the key schedule, - * * a key schedule "reversion" function to prepare for decryption, + * * a key schedule "inversion" function to prepare for decryption, * * a 128-bit block decryption function using the "inverted" key schedule. * * The functions, respectively, are: @@ -49,17 +50,20 @@ extern "C" * \brief Expands a key schedule for AES-128 encryption. * * \param[in] key The AES-128 key. - * \param[out] key_schedule The AES-128 encryption key schedule. Must not be `NULL`. + * \param[out] key_schedule The AES-128 encryption key schedule. Must not be + * `NULL`. */ void __fastcall aesni_raw_expand_key_schedule128( AesNI_Block128 key, AesNI_KeySchedule128* key_schedule); /** - * \brief "Reverses" a key schedule for AES-128 "equivalent inverse cipher" decryption. + * \brief "Inverts" an AES-128 key schedule to prepare for decryption. * - * \param[in] key_schedule The AES-128 encryption key schedule. Must not be `NULL`. - * \param[out] inverted_schedule The AES-128 decryption key schedule. Must not be `NULL`. + * \param[in] key_schedule The AES-128 encryption key schedule. Must not be + * `NULL`. + * \param[out] inverted_schedule The AES-128 decryption key schedule. Must not + * be `NULL`. */ void __fastcall aesni_raw_invert_key_schedule128( AesNI_KeySchedule128* key_schedule, @@ -69,7 +73,8 @@ void __fastcall aesni_raw_invert_key_schedule128( * \brief Encrypts a 128-bit block using AES-128. * * \param[in] plain The plaintext to be encrypted. - * \param[in] key_schedule The AES-128 encryption key schedule. Must not be `NULL`. + * \param[in] key_schedule The AES-128 encryption key schedule. Must not be + * `NULL`. * \return The encrypted 128-bit ciphertext. */ AesNI_Block128 __fastcall aesni_raw_encrypt_block128( @@ -80,7 +85,8 @@ AesNI_Block128 __fastcall aesni_raw_encrypt_block128( * \brief Decrypts a 128-bit block using AES-128. * * \param[in] cipher The ciphertext to be decrypted. - * \param[in] inverted_schedule The AES-128 decryption ("reversed") key schedule. Must not be `NULL`. + * \param[in] inverted_schedule The AES-128 decryption key schedule. Must not + * be `NULL`. * \return The decrypted 128-bit plaintext. */ AesNI_Block128 __fastcall aesni_raw_decrypt_block128( @@ -99,7 +105,8 @@ AesNI_Block128 __fastcall aesni_raw_decrypt_block128( * * \param[in] key_lo The least significant part of the AES-192 key. * \param[in] key_hi The most significant part of the AES-192 key. - * \param[out] key_schedule The AES-192 encryption key schedule. Must not be `NULL`. + * \param[out] key_schedule The AES-192 encryption key schedule. Must not be + * `NULL`. */ void __fastcall aesni_raw_expand_key_schedule192( AesNI_Block128 key_lo, @@ -107,10 +114,12 @@ void __fastcall aesni_raw_expand_key_schedule192( AesNI_KeySchedule192* key_schedule); /** - * \brief "Reverses" a key schedule for AES-192 "equivalent inverse cipher" decryption. + * \brief "Inverts" an AES-192 key schedule to prepare for decryption. * - * \param[in] key_schedule The AES-192 encryption key schedule. Must not be `NULL`. - * \param[out] inverted_schedule The AES-192 decryption key schedule. Must not be `NULL`. + * \param[in] key_schedule The AES-192 encryption key schedule. Must not be + * `NULL`. + * \param[out] inverted_schedule The AES-192 decryption key schedule. Must not + * be `NULL`. */ void __fastcall aesni_raw_invert_key_schedule192( AesNI_KeySchedule192* key_schedule, @@ -120,7 +129,8 @@ void __fastcall aesni_raw_invert_key_schedule192( * \brief Encrypts a 128-bit block using AES-192. * * \param[in] plain The plaintext to be encrypted. - * \param[in] key_schedule The AES-192 encryption key schedule. Must not be `NULL`. + * \param[in] key_schedule The AES-192 encryption key schedule. Must not be + * `NULL`. * \return The encrypted 128-bit ciphertext. */ AesNI_Block128 __fastcall aesni_raw_encrypt_block192( @@ -131,7 +141,8 @@ AesNI_Block128 __fastcall aesni_raw_encrypt_block192( * \brief Decrypts a 128-bit block using AES-192. * * \param[in] cipher The ciphertext to be decrypted. - * \param[in] inverted_schedule The AES-192 decryption ("reversed") key schedule. Must not be `NULL`. + * \param[in] inverted_schedule The AES-192 decryption key schedule. Must not + * be `NULL`. * \return The decrypted 128-bit plaintext. */ AesNI_Block128 __fastcall aesni_raw_decrypt_block192( @@ -150,7 +161,8 @@ AesNI_Block128 __fastcall aesni_raw_decrypt_block192( * * \param[in] key_lo The least significant part of the AES-256 key. * \param[in] key_hi The most significant part of the AES-256 key. - * \param[out] key_schedule The AES-256 encryption key schedule. Must not be `NULL`. + * \param[out] key_schedule The AES-256 encryption key schedule. Must not be + * `NULL`. */ void __fastcall aesni_raw_expand_key_schedule256( AesNI_Block128 key_lo, @@ -158,10 +170,12 @@ void __fastcall aesni_raw_expand_key_schedule256( AesNI_KeySchedule256* key_schedule); /** - * \brief "Reverses" a key schedule for AES-256 "equivalent inverse cipher" decryption. + * \brief "Inverts" a AES-256 key schedule to prepare for decryption. * - * \param[in] key_schedule The AES-256 encryption key schedule. Must not be `NULL`. - * \param[out] inverted_schedule The AES-256 decryption key schedule. Must not be `NULL`. + * \param[in] key_schedule The AES-256 encryption key schedule. Must not be + * `NULL`. + * \param[out] inverted_schedule The AES-256 decryption key schedule. Must not + * be `NULL`. */ void __fastcall aesni_raw_invert_key_schedule256( AesNI_KeySchedule256* key_schedule, @@ -171,7 +185,8 @@ void __fastcall aesni_raw_invert_key_schedule256( * \brief Encrypts a 128-bit block using AES-256. * * \param[in] plain The plaintext to be encrypted. - * \param[in] key_schedule The AES-256 encryption key schedule. Must not be `NULL`. + * \param[in] key_schedule The AES-256 encryption key schedule. Must not be + * `NULL`. * \return The encrypted 128-bit ciphertext. */ AesNI_Block128 __fastcall aesni_raw_encrypt_block256( @@ -182,7 +197,8 @@ AesNI_Block128 __fastcall aesni_raw_encrypt_block256( * \brief Decrypts a 128-bit block using AES-256. * * \param[in] cipher The ciphertext to be decrypted. - * \param[in] inverted_schedule The AES-256 decryption ("reversed") key schedule. Must not be `NULL`. + * \param[in] inverted_schedule The AES-256 decryption key schedule. Must not + * be `NULL`. * \return The decrypted 128-bit plaintext. */ AesNI_Block128 __fastcall aesni_raw_decrypt_block256( |