diff --git a/ext/openssl/cipher/aead/aead.c b/ext/openssl/cipher/aead/aead.c index 94fd04b..dc850d2 100644 --- a/ext/openssl/cipher/aead/aead.c +++ b/ext/openssl/cipher/aead/aead.c @@ -1,17 +1,25 @@ #include +#include #include #include VALUE dOSSL; VALUE eCipherError; +#if RUBY_API_VERSION_CODE >= 20200 #define GetCipherInit(obj, ctx) do { \ TypedData_Get_Struct((obj), EVP_CIPHER_CTX, RTYPEDDATA_TYPE(obj), (ctx)); \ } while (0) -#define GetCipher(obj, ctx) do { \ - GetCipherInit((obj), (ctx)); \ - if (!(ctx)) { \ - ossl_raise(rb_eRuntimeError, "Cipher not inititalized!"); \ +#else +#define GetCipherInit(obj, ctx) do { \ + Data_Get_Struct((obj), EVP_CIPHER_CTX, (ctx)); \ +} while (0) +#endif + +#define GetCipher(obj, ctx) do { \ + GetCipherInit((obj), (ctx)); \ + if (!(ctx)) { \ + ossl_raise(rb_eRuntimeError, "Cipher not inititalized!"); \ } \ } while (0)