Skip to content

Commit 0060e0b

Browse files
committed
src/openssl.c: add compat for pre 1.1.0
1 parent a272fe7 commit 0060e0b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/openssl.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11923,7 +11923,14 @@ static int cipher_init(lua_State *L, _Bool encrypt) {
1192311923

1192411924
iv = luaL_optlstring(L, 3, NULL, &n);
1192511925
/* Set the IV length before init */
11926+
#if defined EVP_CTRL_AEAD_SET_IVLEN
1192611927
if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_IVLEN, n, NULL) <= 0) {
11928+
#elif defined EVP_CTRL_GCM_SET_IVLEN
11929+
/* https://github.com/openssl/openssl/issues/8330#issuecomment-516838331 */
11930+
if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, n, NULL) <= 0) {
11931+
#else
11932+
{
11933+
#endif
1192711934
/* wasn't able to set IV len; check if it's already correct */
1192811935
m = (size_t)EVP_CIPHER_CTX_iv_length(ctx);
1192911936
luaL_argcheck(L, n == m, 3, lua_pushfstring(L, "%d: invalid IV length (should be %d)", (int)n, (int)m));

0 commit comments

Comments
 (0)