diff options
Diffstat (limited to 'src/openssl.c')
-rw-r--r-- | src/openssl.c | 94 |
1 files changed, 61 insertions, 33 deletions
diff --git a/src/openssl.c b/src/openssl.c index 790b153..620ef4e 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -355,6 +355,21 @@ #define HAVE_SSL_CTX_SET_CURVES_LIST (OPENSSL_PREREQ(1,0,2) || LIBRESSL_PREREQ(2,5,1)) #endif +#ifndef HAVE_SSL_CTX_SET_GROUPS_LIST +#if OPENSSL_PREREQ(1,1,1) +#define HAVE_SSL_CTX_SET_GROUPS_LIST 1 +#elif HAVE_SSL_CTX_SET_CURVES_LIST +#define SSL_CTX_set1_groups_list SSL_CTX_set1_curves_list +#define HAVE_SSL_CTX_SET_GROUPS_LIST 1 +#else +#define HAVE_SSL_CTX_SET_GROUPS_LIST 0 +#endif +#endif + +#ifndef HAVE_SSL_CTX_SET_GROUPS_LIST +#define HAVE_SSL_CTX_SET_GROUPS_LIST OPENSSL_PREREQ(1,1,1) +#endif + #ifndef HAVE_SSL_CTX_SET_ECDH_AUTO #define HAVE_SSL_CTX_SET_ECDH_AUTO ((OPENSSL_PREREQ(1,0,2) && !OPENSSL_PREREQ(1,1,0)) || LIBRESSL_PREREQ(2,1,2)) #endif @@ -455,6 +470,17 @@ #define HAVE_SSL_SET_CURVES_LIST (OPENSSL_PREREQ(1,0,2) || LIBRESSL_PREREQ(2,5,1)) #endif +#ifndef HAVE_SSL_SET_GROUPS_LIST +#if OPENSSL_PREREQ(1,1,1) +#define HAVE_SSL_SET_GROUPS_LIST 1 +#elif HAVE_SSL_SET_CURVES_LIST +#define SSL_set1_groups_list SSL_set1_curves_list +#define HAVE_SSL_SET_GROUPS_LIST 1 +#else +#define HAVE_SSL_SET_GROUPS_LIST 0 +#endif +#endif + #ifndef HAVE_SSL_SET1_CHAIN #define HAVE_SSL_SET1_CHAIN OPENSSL_PREREQ(1,0,2) #endif @@ -9521,21 +9547,6 @@ static int sx_setCipherList(lua_State *L) { } /* sx_setCipherList() */ -#if HAVE_SSL_CTX_SET_CURVES_LIST -static int sx_setCurvesList(lua_State *L) { - SSL_CTX *ctx = checksimple(L, 1, SSL_CTX_CLASS); - const char *curves = luaL_checkstring(L, 2); - - if (!SSL_CTX_set1_curves_list(ctx, curves)) - return auxL_error(L, auxL_EOPENSSL, "ssl.context:setCurvesList"); - - lua_pushboolean(L, 1); - - return 1; -} /* sx_setCurvesList() */ -#endif - - #if HAVE_SSL_CTX_SET_CIPHERSUITES static int sx_setCipherSuites(lua_State *L) { SSL_CTX *ctx = checksimple(L, 1, SSL_CTX_CLASS); @@ -9596,6 +9607,21 @@ static int sx_setEphemeralKey(lua_State *L) { } /* sx_setEphemeralKey() */ +#if HAVE_SSL_CTX_SET_GROUPS_LIST +static int sx_setGroups(lua_State *L) { + SSL_CTX *ctx = checksimple(L, 1, SSL_CTX_CLASS); + const char *list = luaL_checkstring(L, 2); + + if (!SSL_CTX_set1_groups_list(ctx, list)) + return auxL_error(L, auxL_EOPENSSL, "ssl.context:setGroups"); + + lua_pushboolean(L, 1); + + return 1; +} /* sx_setGroups() */ +#endif + + #if HAVE_SSL_CTX_SET_ALPN_PROTOS static int sx_setAlpnProtos(lua_State *L) { SSL_CTX *ctx = checksimple(L, 1, SSL_CTX_CLASS); @@ -10262,13 +10288,14 @@ static const auxL_Reg sx_methods[] = { #endif { "setPrivateKey", &sx_setPrivateKey }, { "setCipherList", &sx_setCipherList }, -#if HAVE_SSL_CTX_SET_CURVES_LIST - { "setCurvesList", &sx_setCurvesList }, -#endif #if HAVE_SSL_CTX_SET_CIPHERSUITES { "setCipherSuites", &sx_setCipherSuites }, #endif { "setEphemeralKey", &sx_setEphemeralKey }, +#if HAVE_SSL_CTX_SET_GROUPS_LIST + { "setCurvesList", &sx_setGroups }, /* old alias */ + { "setGroups", &sx_setGroups }, +#endif #if HAVE_SSL_CTX_SET_ALPN_PROTOS { "setAlpnProtos", &sx_setAlpnProtos }, #endif @@ -10869,33 +10896,33 @@ static int ssl_setCipherList(lua_State *L) { } /* ssl_setCipherList() */ -#if HAVE_SSL_SET_CURVES_LIST -static int ssl_setCurvesList(lua_State *L) { +#if HAVE_SSL_SET_CIPHERSUITES +static int ssl_setCipherSuites(lua_State *L) { SSL *ssl = checksimple(L, 1, SSL_CLASS); - const char *curves = luaL_checkstring(L, 2); + const char *ciphers = luaL_checkstring(L, 2); - if (!SSL_set1_curves_list(ssl, curves)) - return auxL_error(L, auxL_EOPENSSL, "ssl:setCurvesList"); + if (!SSL_set_ciphersuites(ssl, ciphers)) + return auxL_error(L, auxL_EOPENSSL, "ssl:setCipherSuites"); lua_pushboolean(L, 1); return 1; -} /* ssl_setCurvesList() */ +} /* ssl_setCipherSuites() */ #endif -#if HAVE_SSL_SET_CIPHERSUITES -static int ssl_setCipherSuites(lua_State *L) { +#if HAVE_SSL_SET_GROUPS_LIST +static int ssl_setGroups(lua_State *L) { SSL *ssl = checksimple(L, 1, SSL_CLASS); - const char *ciphers = luaL_checkstring(L, 2); + const char *list = luaL_checkstring(L, 2); - if (!SSL_set_ciphersuites(ssl, ciphers)) - return auxL_error(L, auxL_EOPENSSL, "ssl:setCipherSuites"); + if (!SSL_set1_groups_list(ssl, list)) + return auxL_error(L, auxL_EOPENSSL, "ssl:setGroups"); lua_pushboolean(L, 1); return 1; -} /* ssl_setCipherSuites() */ +} /* ssl_setGroups() */ #endif @@ -11194,12 +11221,13 @@ static const auxL_Reg ssl_methods[] = { { "getPeerChain", &ssl_getPeerChain }, { "getCipherInfo", &ssl_getCipherInfo }, { "setCipherList", &ssl_setCipherList }, -#if HAVE_SSL_SET_CURVES_LIST - { "setCurvesList", &ssl_setCurvesList }, -#endif #if HAVE_SSL_SET_CIPHERSUITES { "setCipherSuites", &ssl_setCipherSuites }, #endif +#if HAVE_SSL_SET_GROUPS_LIST + { "setCurvesList", &ssl_setGroups }, /* old alias */ + { "setGroups", &ssl_setGroups }, +#endif { "getHostName", &ssl_getHostName }, { "setHostName", &ssl_setHostName }, { "getVersion", &ssl_getVersion }, |