aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatarLibravatar daurnimator <quae@daurnimator.com> 2022-07-11 15:34:31 +1000
committerLibravatarLibravatar daurnimator <quae@daurnimator.com> 2022-07-11 15:34:31 +1000
commit0060e0b6b28f60415cc3f218898bf9ba9c6d32ce (patch)
tree1870f15d9c18f7789ff32ddeb6d1582b33baf058
parenta272fe7408d02c98120f6c697113ee5579f4cc25 (diff)
downloadluaossl-0060e0b6b28f60415cc3f218898bf9ba9c6d32ce.tar.gz
luaossl-0060e0b6b28f60415cc3f218898bf9ba9c6d32ce.tar.bz2
luaossl-0060e0b6b28f60415cc3f218898bf9ba9c6d32ce.zip
src/openssl.c: add compat for pre 1.1.0
-rw-r--r--src/openssl.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/openssl.c b/src/openssl.c
index c8c7677..1d1164e 100644
--- a/src/openssl.c
+++ b/src/openssl.c
@@ -11923,7 +11923,14 @@ static int cipher_init(lua_State *L, _Bool encrypt) {
iv = luaL_optlstring(L, 3, NULL, &n);
/* Set the IV length before init */
+#if defined EVP_CTRL_AEAD_SET_IVLEN
if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_IVLEN, n, NULL) <= 0) {
+#elif defined EVP_CTRL_GCM_SET_IVLEN
+ /* https://github.com/openssl/openssl/issues/8330#issuecomment-516838331 */
+ if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, n, NULL) <= 0) {
+#else
+ {
+#endif
/* wasn't able to set IV len; check if it's already correct */
m = (size_t)EVP_CIPHER_CTX_iv_length(ctx);
luaL_argcheck(L, n == m, 3, lua_pushfstring(L, "%d: invalid IV length (should be %d)", (int)n, (int)m));