diff options
author | daurnimator <quae@daurnimator.com> | 2017-04-03 11:01:54 +1000 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2017-04-03 13:27:11 +1000 |
commit | 8d91ac802732222ba1b775712543601137d2bf20 (patch) | |
tree | 8a6fe937064b08d5ae780980a1addd61fc937144 /src | |
parent | f2f0f09caef1925a4ff731a6feed35b8f355b169 (diff) | |
download | luaossl-8d91ac802732222ba1b775712543601137d2bf20.tar.gz luaossl-8d91ac802732222ba1b775712543601137d2bf20.tar.bz2 luaossl-8d91ac802732222ba1b775712543601137d2bf20.zip |
openssl.ssl.context: Add ctx:setCurvesList
Diffstat (limited to 'src')
-rw-r--r-- | src/openssl.c | 22 | ||||
-rw-r--r-- | src/openssl.ssl.context.lua | 14 |
2 files changed, 36 insertions, 0 deletions
diff --git a/src/openssl.c b/src/openssl.c index fa7dd79..d679d92 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -254,6 +254,10 @@ #define HAVE_SSL_CTX_GET0_PARAM OPENSSL_PREREQ(1,0,2) #endif +#ifndef HAVE_SSL_CTX_SET_CURVES_LIST +#define HAVE_SSL_CTX_SET_CURVES_LIST (OPENSSL_PREREQ(1,0,2) || LIBRESSL_PREREQ(2,5,1)) +#endif + #ifndef HAVE_SSL_CTX_SET_ALPN_PROTOS #define HAVE_SSL_CTX_SET_ALPN_PROTOS (OPENSSL_PREREQ(1,0,2) || LIBRESSL_PREREQ(2,1,3)) #endif @@ -7746,6 +7750,21 @@ 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 + + static int sx_setEphemeralKey(lua_State *L) { SSL_CTX *ctx = checksimple(L, 1, SSL_CTX_CLASS); EVP_PKEY *key = checksimple(L, 2, PKEY_CLASS); @@ -7941,6 +7960,9 @@ static const auxL_Reg sx_methods[] = { { "setCertificate", &sx_setCertificate }, { "setPrivateKey", &sx_setPrivateKey }, { "setCipherList", &sx_setCipherList }, +#if HAVE_SSL_CTX_SET_CURVES_LIST + { "setCurvesList", &sx_setCurvesList }, +#endif { "setEphemeralKey", &sx_setEphemeralKey }, #if HAVE_SSL_CTX_SET_ALPN_PROTOS { "setAlpnProtos", &sx_setAlpnProtos }, diff --git a/src/openssl.ssl.context.lua b/src/openssl.ssl.context.lua index 2098b54..3263fb1 100644 --- a/src/openssl.ssl.context.lua +++ b/src/openssl.ssl.context.lua @@ -13,4 +13,18 @@ local setCipherList; setCipherList = ctx.interpose("setCipherList", function (se return setCipherList(self, ciphers) end) +-- Allow passing a vararg of curves, or an array +local setCurvesList = ctx.interpose("setCurvesList", nil) +if setCurvesList then + ctx.interpose("setCurvesList", function (self, curves, ...) + if (...) then + local curves_t = pack(curves, ...) + curves = table.concat(curves_t, ":", 1, curves_t.n) + elseif type(curves) == "table" then + curves = table.concat(curves, ":") + end + return setCurvesList(self, curves) + end) +end + return ctx |