aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/cxx/include/aesnixx/mode.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'cxx/include/aesnixx/mode.hpp')
-rw-r--r--cxx/include/aesnixx/mode.hpp108
1 files changed, 108 insertions, 0 deletions
diff --git a/cxx/include/aesnixx/mode.hpp b/cxx/include/aesnixx/mode.hpp
index a0af051..e19dbbd 100644
--- a/cxx/include/aesnixx/mode.hpp
+++ b/cxx/include/aesnixx/mode.hpp
@@ -45,4 +45,112 @@ namespace aesni
{
return mode != AESNI_ECB && mode != AESNI_CBC;
}
+
+#define AESNIXX_ENCRYPT_BLOCK_ECB(prefix) \
+ template <> \
+ inline void encrypt_block<AESNI_## prefix, AESNI_ECB>( \
+ const typename Types<AESNI_## prefix>::Block& plaintext, \
+ const typename Types<AESNI_## prefix>::RoundKeys& encryption_keys, \
+ typename Types<AESNI_## prefix>::Block& ciphertext) \
+ { \
+ ciphertext = aesni_## prefix ##_encrypt_block_ECB(plaintext, &encryption_keys); \
+ }
+
+#define AESNIXX_DECRYPT_BLOCK_ECB(prefix) \
+ template <> \
+ inline void decrypt_block<AESNI_## prefix, AESNI_ECB>( \
+ const typename Types<AESNI_## prefix>::Block& ciphertext, \
+ const typename Types<AESNI_## prefix>::RoundKeys& decryption_keys, \
+ typename Types<AESNI_## prefix>::Block& plaintext) \
+ { \
+ plaintext = aesni_## prefix ##_decrypt_block_ECB(ciphertext, &decryption_keys); \
+ }
+
+#define AESNIXX_ENCRYPT_BLOCK_CBC(prefix) \
+ template <> \
+ inline void encrypt_block<AESNI_## prefix, AESNI_CBC>( \
+ const typename Types<AESNI_## prefix>::Block& plaintext, \
+ const typename Types<AESNI_## prefix>::RoundKeys& encryption_keys, \
+ typename Types<AESNI_## prefix>::Block& iv, \
+ typename Types<AESNI_## prefix>::Block& ciphertext) \
+ { \
+ ciphertext = aesni_## prefix ##_encrypt_block_CBC(plaintext, &encryption_keys, iv, &iv); \
+ }
+
+#define AESNIXX_DECRYPT_BLOCK_CBC(prefix) \
+ template <> \
+ inline void decrypt_block<AESNI_## prefix, AESNI_CBC>( \
+ const typename Types<AESNI_## prefix>::Block& ciphertext, \
+ const typename Types<AESNI_## prefix>::RoundKeys& decryption_keys, \
+ typename Types<AESNI_## prefix>::Block& iv, \
+ typename Types<AESNI_## prefix>::Block& plaintext) \
+ { \
+ plaintext = aesni_## prefix ##_decrypt_block_CBC(ciphertext, &decryption_keys, iv, &iv); \
+ }
+
+#define AESNIXX_ENCRYPT_BLOCK_CFB(prefix) \
+ template <> \
+ inline void encrypt_block<AESNI_## prefix, AESNI_CFB>( \
+ const typename Types<AESNI_## prefix>::Block& plaintext, \
+ const typename Types<AESNI_## prefix>::RoundKeys& encryption_keys, \
+ typename Types<AESNI_## prefix>::Block& iv, \
+ typename Types<AESNI_## prefix>::Block& ciphertext) \
+ { \
+ ciphertext = aesni_## prefix ##_encrypt_block_CFB(plaintext, &encryption_keys, iv, &iv); \
+ }
+
+#define AESNIXX_DECRYPT_BLOCK_CFB(prefix) \
+ template <> \
+ inline void decrypt_block<AESNI_## prefix, AESNI_CFB>( \
+ const typename Types<AESNI_## prefix>::Block& ciphertext, \
+ const typename Types<AESNI_## prefix>::RoundKeys& encryption_keys, \
+ typename Types<AESNI_## prefix>::Block& iv, \
+ typename Types<AESNI_## prefix>::Block& plaintext) \
+ { \
+ plaintext = aesni_## prefix ##_decrypt_block_CFB(ciphertext, &encryption_keys, iv, &iv); \
+ }
+
+#define AESNIXX_ENCRYPT_BLOCK_OFB(prefix) \
+ template <> \
+ inline void encrypt_block<AESNI_## prefix, AESNI_OFB>( \
+ const typename Types<AESNI_## prefix>::Block& plaintext, \
+ const typename Types<AESNI_## prefix>::RoundKeys& encryption_keys, \
+ typename Types<AESNI_## prefix>::Block& iv, \
+ typename Types<AESNI_## prefix>::Block& ciphertext) \
+ { \
+ ciphertext = aesni_## prefix ##_encrypt_block_OFB(plaintext, &encryption_keys, iv, &iv); \
+ }
+
+#define AESNIXX_DECRYPT_BLOCK_OFB(prefix) \
+ template <> \
+ inline void decrypt_block<AESNI_## prefix, AESNI_OFB>( \
+ const typename Types<AESNI_## prefix>::Block& ciphertext, \
+ const typename Types<AESNI_## prefix>::RoundKeys& encryption_keys, \
+ typename Types<AESNI_## prefix>::Block& iv, \
+ typename Types<AESNI_## prefix>::Block& plaintext) \
+ { \
+ plaintext = aesni_## prefix ##_decrypt_block_OFB(ciphertext, &encryption_keys, iv, &iv); \
+ }
+
+#define AESNIXX_ENCRYPT_BLOCK_CTR(prefix) \
+ template <> \
+ inline void encrypt_block<AESNI_## prefix, AESNI_CTR>( \
+ const typename Types<AESNI_## prefix>::Block& plaintext, \
+ const typename Types<AESNI_## prefix>::RoundKeys& encryption_keys, \
+ typename Types<AESNI_## prefix>::Block& iv, \
+ typename Types<AESNI_## prefix>::Block& ciphertext) \
+ { \
+ ciphertext = aesni_## prefix ##_encrypt_block_CTR(plaintext, &encryption_keys, iv, &iv); \
+ }
+
+#define AESNIXX_DECRYPT_BLOCK_CTR(prefix) \
+ template <> \
+ inline void decrypt_block<AESNI_## prefix, AESNI_CTR>( \
+ const typename Types<AESNI_## prefix>::Block& ciphertext, \
+ const typename Types<AESNI_## prefix>::RoundKeys& encryption_keys, \
+ typename Types<AESNI_## prefix>::Block& iv, \
+ typename Types<AESNI_## prefix>::Block& plaintext) \
+ { \
+ plaintext = aesni_## prefix ##_decrypt_block_CTR(ciphertext, &encryption_keys, iv, &iv); \
+ }
}