diff options
Diffstat (limited to '')
-rw-r--r-- | include/aes/mode.h | 158 |
1 files changed, 79 insertions, 79 deletions
diff --git a/include/aes/mode.h b/include/aes/mode.h index 7650ec0..dccfc43 100644 --- a/include/aes/mode.h +++ b/include/aes/mode.h @@ -17,150 +17,150 @@ extern "C" typedef enum { - AESNI_ECB, - AESNI_CBC, - AESNI_CFB, - AESNI_OFB, - AESNI_CTR, + AES_ECB, + AES_CBC, + AES_CFB, + AES_OFB, + AES_CTR, } -AesNI_Mode; +AES_Mode; -#define AESNI_ENCRYPT_BLOCK_ECB(prefix) \ -static __inline AesNI_## prefix ##_Block __fastcall aesni_## prefix ##_encrypt_block_ECB( \ - AesNI_## prefix ##_Block plaintext, \ - const AesNI_## prefix ##_RoundKeys* encryption_keys) \ +#define AES_ENCRYPT_BLOCK_ECB(prefix) \ +static __inline AES_## prefix ##_Block __fastcall aes_## prefix ##_encrypt_block_ECB( \ + AES_## prefix ##_Block plaintext, \ + const AES_## prefix ##_RoundKeys* encryption_keys) \ { \ assert(encryption_keys); \ \ - return aesni_## prefix ##_encrypt_block_(plaintext, encryption_keys); \ + return aes_## prefix ##_encrypt_block_(plaintext, encryption_keys); \ } -#define AESNI_DECRYPT_BLOCK_ECB(prefix) \ -static __inline AesNI_## prefix ##_Block __fastcall aesni_## prefix ##_decrypt_block_ECB( \ - AesNI_## prefix ##_Block ciphertext, \ - const AesNI_## prefix ##_RoundKeys* decryption_keys) \ +#define AES_DECRYPT_BLOCK_ECB(prefix) \ +static __inline AES_## prefix ##_Block __fastcall aes_## prefix ##_decrypt_block_ECB( \ + AES_## prefix ##_Block ciphertext, \ + const AES_## prefix ##_RoundKeys* decryption_keys) \ { \ assert(decryption_keys); \ \ - return aesni_## prefix ##_decrypt_block_(ciphertext, decryption_keys); \ + return aes_## prefix ##_decrypt_block_(ciphertext, decryption_keys); \ } -#define AESNI_ENCRYPT_BLOCK_CBC(prefix) \ -static __inline AesNI_## prefix ##_Block __fastcall aesni_## prefix ##_encrypt_block_CBC( \ - AesNI_## prefix ##_Block plaintext, \ - const AesNI_## prefix ##_RoundKeys* encryption_keys, \ - AesNI_## prefix ##_Block init_vector, \ - AesNI_## prefix ##_Block* next_init_vector) \ +#define AES_ENCRYPT_BLOCK_CBC(prefix) \ +static __inline AES_## prefix ##_Block __fastcall aes_## prefix ##_encrypt_block_CBC( \ + AES_## prefix ##_Block plaintext, \ + const AES_## prefix ##_RoundKeys* encryption_keys, \ + AES_## prefix ##_Block init_vector, \ + AES_## prefix ##_Block* next_init_vector) \ { \ assert(encryption_keys); \ assert(next_init_vector); \ \ - return *next_init_vector = aesni_## prefix ##_encrypt_block_( \ - aesni_## prefix ##_xor_blocks(plaintext, init_vector), encryption_keys); \ + return *next_init_vector = aes_## prefix ##_encrypt_block_( \ + aes_## prefix ##_xor_blocks(plaintext, init_vector), encryption_keys); \ } -#define AESNI_DECRYPT_BLOCK_CBC(prefix) \ -static __inline AesNI_## prefix ##_Block __fastcall aesni_## prefix ##_decrypt_block_CBC( \ - AesNI_## prefix ##_Block ciphertext, \ - const AesNI_## prefix ##_RoundKeys* decryption_keys, \ - AesNI_## prefix ##_Block init_vector, \ - AesNI_## prefix ##_Block* next_init_vector) \ +#define AES_DECRYPT_BLOCK_CBC(prefix) \ +static __inline AES_## prefix ##_Block __fastcall aes_## prefix ##_decrypt_block_CBC( \ + AES_## prefix ##_Block ciphertext, \ + const AES_## prefix ##_RoundKeys* decryption_keys, \ + AES_## prefix ##_Block init_vector, \ + AES_## prefix ##_Block* next_init_vector) \ { \ assert(decryption_keys); \ assert(next_init_vector); \ \ - AesNI_## prefix ##_Block plaintext = aesni_## prefix ##_xor_blocks( \ - aesni_## prefix ##_decrypt_block_(ciphertext, decryption_keys), init_vector); \ + AES_## prefix ##_Block plaintext = aes_## prefix ##_xor_blocks( \ + aes_## prefix ##_decrypt_block_(ciphertext, decryption_keys), init_vector); \ *next_init_vector = ciphertext; \ return plaintext; \ } -#define AESNI_ENCRYPT_BLOCK_CFB(prefix) \ -static __inline AesNI_## prefix ##_Block __fastcall aesni_## prefix ##_encrypt_block_CFB( \ - AesNI_## prefix ##_Block plaintext, \ - const AesNI_## prefix ##_RoundKeys* encryption_keys, \ - AesNI_## prefix ##_Block init_vector, \ - AesNI_## prefix ##_Block* next_init_vector) \ +#define AES_ENCRYPT_BLOCK_CFB(prefix) \ +static __inline AES_## prefix ##_Block __fastcall aes_## prefix ##_encrypt_block_CFB( \ + AES_## prefix ##_Block plaintext, \ + const AES_## prefix ##_RoundKeys* encryption_keys, \ + AES_## prefix ##_Block init_vector, \ + AES_## prefix ##_Block* next_init_vector) \ { \ assert(encryption_keys); \ assert(next_init_vector); \ \ - return *next_init_vector = aesni_## prefix ##_xor_blocks( \ - aesni_## prefix ##_encrypt_block_(init_vector, encryption_keys), plaintext); \ + return *next_init_vector = aes_## prefix ##_xor_blocks( \ + aes_## prefix ##_encrypt_block_(init_vector, encryption_keys), plaintext); \ } -#define AESNI_DECRYPT_BLOCK_CFB(prefix) \ -static __inline AesNI_## prefix ##_Block __fastcall aesni_## prefix ##_decrypt_block_CFB( \ - AesNI_## prefix ##_Block ciphertext, \ - const AesNI_## prefix ##_RoundKeys* encryption_keys, \ - AesNI_## prefix ##_Block init_vector, \ - AesNI_## prefix ##_Block* next_init_vector) \ +#define AES_DECRYPT_BLOCK_CFB(prefix) \ +static __inline AES_## prefix ##_Block __fastcall aes_## prefix ##_decrypt_block_CFB( \ + AES_## prefix ##_Block ciphertext, \ + const AES_## prefix ##_RoundKeys* encryption_keys, \ + AES_## prefix ##_Block init_vector, \ + AES_## prefix ##_Block* next_init_vector) \ { \ assert(encryption_keys); \ assert(next_init_vector); \ \ - AesNI_## prefix ##_Block plaintext = aesni_## prefix ##_xor_blocks( \ - aesni_## prefix ##_encrypt_block_(init_vector, encryption_keys), ciphertext); \ + AES_## prefix ##_Block plaintext = aes_## prefix ##_xor_blocks( \ + aes_## prefix ##_encrypt_block_(init_vector, encryption_keys), ciphertext); \ *next_init_vector = ciphertext; \ return plaintext; \ } -#define AESNI_ENCRYPT_BLOCK_OFB(prefix) \ -static __inline AesNI_## prefix ##_Block __fastcall aesni_## prefix ##_encrypt_block_OFB( \ - AesNI_## prefix ##_Block plaintext, \ - const AesNI_## prefix ##_RoundKeys* encryption_keys, \ - AesNI_## prefix ##_Block init_vector, \ - AesNI_## prefix ##_Block* next_init_vector) \ +#define AES_ENCRYPT_BLOCK_OFB(prefix) \ +static __inline AES_## prefix ##_Block __fastcall aes_## prefix ##_encrypt_block_OFB( \ + AES_## prefix ##_Block plaintext, \ + const AES_## prefix ##_RoundKeys* encryption_keys, \ + AES_## prefix ##_Block init_vector, \ + AES_## prefix ##_Block* next_init_vector) \ { \ assert(encryption_keys); \ assert(next_init_vector); \ \ - AesNI_## prefix ##_Block tmp = aesni_## prefix ##_encrypt_block_(init_vector, encryption_keys); \ + AES_## prefix ##_Block tmp = aes_## prefix ##_encrypt_block_(init_vector, encryption_keys); \ *next_init_vector = tmp; \ - return aesni_## prefix ##_xor_blocks(tmp, plaintext); \ + return aes_## prefix ##_xor_blocks(tmp, plaintext); \ } -#define AESNI_DECRYPT_BLOCK_OFB(prefix) \ -static __inline AesNI_## prefix ##_Block __fastcall aesni_## prefix ##_decrypt_block_OFB( \ - AesNI_## prefix ##_Block ciphertext, \ - const AesNI_## prefix ##_RoundKeys* encryption_keys, \ - AesNI_## prefix ##_Block init_vector, \ - AesNI_## prefix ##_Block* next_init_vector) \ +#define AES_DECRYPT_BLOCK_OFB(prefix) \ +static __inline AES_## prefix ##_Block __fastcall aes_## prefix ##_decrypt_block_OFB( \ + AES_## prefix ##_Block ciphertext, \ + const AES_## prefix ##_RoundKeys* encryption_keys, \ + AES_## prefix ##_Block init_vector, \ + AES_## prefix ##_Block* next_init_vector) \ { \ assert(encryption_keys); \ assert(next_init_vector); \ \ - return aesni_## prefix ##_encrypt_block_OFB( \ + return aes_## prefix ##_encrypt_block_OFB( \ ciphertext, encryption_keys, init_vector, next_init_vector); \ } -#define AESNI_ENCRYPT_BLOCK_CTR(prefix) \ -static __inline AesNI_## prefix ##_Block __fastcall aesni_## prefix ##_encrypt_block_CTR( \ - AesNI_## prefix ##_Block plaintext, \ - const AesNI_## prefix ##_RoundKeys* encryption_keys, \ - AesNI_## prefix ##_Block init_vector, \ - AesNI_## prefix ##_Block* next_init_vector) \ +#define AES_ENCRYPT_BLOCK_CTR(prefix) \ +static __inline AES_## prefix ##_Block __fastcall aes_## prefix ##_encrypt_block_CTR( \ + AES_## prefix ##_Block plaintext, \ + const AES_## prefix ##_RoundKeys* encryption_keys, \ + AES_## prefix ##_Block init_vector, \ + AES_## prefix ##_Block* next_init_vector) \ { \ assert(encryption_keys); \ assert(next_init_vector); \ \ - AesNI_## prefix ##_Block ciphertext = aesni_## prefix ##_xor_blocks( \ - plaintext, aesni_## prefix ##_encrypt_block_(init_vector, encryption_keys)); \ - *next_init_vector = aesni_## prefix ##_inc_block(init_vector); \ + AES_## prefix ##_Block ciphertext = aes_## prefix ##_xor_blocks( \ + plaintext, aes_## prefix ##_encrypt_block_(init_vector, encryption_keys)); \ + *next_init_vector = aes_## prefix ##_inc_block(init_vector); \ return ciphertext; \ } -#define AESNI_DECRYPT_BLOCK_CTR(prefix) \ -static __inline AesNI_## prefix ##_Block __fastcall aesni_## prefix ##_decrypt_block_CTR( \ - AesNI_## prefix ##_Block ciphertext, \ - const AesNI_## prefix ##_RoundKeys* encryption_keys, \ - AesNI_## prefix ##_Block init_vector, \ - AesNI_## prefix ##_Block* next_init_vector) \ +#define AES_DECRYPT_BLOCK_CTR(prefix) \ +static __inline AES_## prefix ##_Block __fastcall aes_## prefix ##_decrypt_block_CTR( \ + AES_## prefix ##_Block ciphertext, \ + const AES_## prefix ##_RoundKeys* encryption_keys, \ + AES_## prefix ##_Block init_vector, \ + AES_## prefix ##_Block* next_init_vector) \ { \ assert(encryption_keys); \ assert(next_init_vector); \ \ - return aesni_## prefix ##_encrypt_block_CTR( \ + return aes_## prefix ##_encrypt_block_CTR( \ ciphertext, encryption_keys, init_vector, next_init_vector); \ } |