-#define foreach_openssl_evp_op \
- _(cbc, DES_CBC, EVP_des_cbc) \
- _(cbc, 3DES_CBC, EVP_des_ede3_cbc) \
- _(cbc, AES_128_CBC, EVP_aes_128_cbc) \
- _(cbc, AES_192_CBC, EVP_aes_192_cbc) \
- _(cbc, AES_256_CBC, EVP_aes_256_cbc) \
- _(gcm, AES_128_GCM, EVP_aes_128_gcm) \
- _(gcm, AES_192_GCM, EVP_aes_192_gcm) \
- _(gcm, AES_256_GCM, EVP_aes_256_gcm) \
- _(cbc, AES_128_CTR, EVP_aes_128_ctr) \
- _(cbc, AES_192_CTR, EVP_aes_192_ctr) \
- _(cbc, AES_256_CTR, EVP_aes_256_ctr) \
+#define foreach_openssl_aes_evp_op \
+ _ (cbc, DES_CBC, EVP_des_cbc, 8) \
+ _ (cbc, 3DES_CBC, EVP_des_ede3_cbc, 8) \
+ _ (cbc, AES_128_CBC, EVP_aes_128_cbc, 16) \
+ _ (cbc, AES_192_CBC, EVP_aes_192_cbc, 16) \
+ _ (cbc, AES_256_CBC, EVP_aes_256_cbc, 16) \
+ _ (gcm, AES_128_GCM, EVP_aes_128_gcm, 8) \
+ _ (gcm, AES_192_GCM, EVP_aes_192_gcm, 8) \
+ _ (gcm, AES_256_GCM, EVP_aes_256_gcm, 8) \
+ _ (cbc, AES_128_CTR, EVP_aes_128_ctr, 8) \
+ _ (cbc, AES_192_CTR, EVP_aes_192_ctr, 8) \
+ _ (cbc, AES_256_CTR, EVP_aes_256_ctr, 8)
+
+#define foreach_openssl_chacha20_evp_op \
+ _ (chacha20_poly1305, CHACHA20_POLY1305, EVP_chacha20_poly1305, 8)
+
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+#define foreach_openssl_evp_op foreach_openssl_aes_evp_op \
+ foreach_openssl_chacha20_evp_op
+#else
+#define foreach_openssl_evp_op foreach_openssl_aes_evp_op
+#endif
+
+#ifndef EVP_CTRL_AEAD_GET_TAG
+#define EVP_CTRL_AEAD_GET_TAG EVP_CTRL_GCM_GET_TAG
+#endif
+
+#ifndef EVP_CTRL_AEAD_SET_TAG
+#define EVP_CTRL_AEAD_SET_TAG EVP_CTRL_GCM_SET_TAG
+#endif