summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-04-03 11:01:54 +1000
committerdaurnimator <quae@daurnimator.com>2017-04-03 13:27:11 +1000
commit8d91ac802732222ba1b775712543601137d2bf20 (patch)
tree8a6fe937064b08d5ae780980a1addd61fc937144
parentf2f0f09caef1925a4ff731a6feed35b8f355b169 (diff)
downloadluaossl-8d91ac802732222ba1b775712543601137d2bf20.tar.gz
luaossl-8d91ac802732222ba1b775712543601137d2bf20.tar.bz2
luaossl-8d91ac802732222ba1b775712543601137d2bf20.zip
openssl.ssl.context: Add ctx:setCurvesList
-rw-r--r--doc/luaossl.tex6
-rw-r--r--src/openssl.c22
-rw-r--r--src/openssl.ssl.context.lua14
3 files changed, 42 insertions, 0 deletions
diff --git a/doc/luaossl.tex b/doc/luaossl.tex
index 7db7463..72f4d06 100644
--- a/doc/luaossl.tex
+++ b/doc/luaossl.tex
@@ -883,6 +883,12 @@ Sets the private key \module{openssl.pkey} object $key$ for use during SSL conne
883 883
884Sets the allowed public key and private key algorithm(s). The string format is documented in the \href{http://www.openssl.org/docs/apps/ciphers.html#CIPHER_LIST_FORMAT}{OpenSSL ciphers(1) utility documentation}. 884Sets the allowed public key and private key algorithm(s). The string format is documented in the \href{http://www.openssl.org/docs/apps/ciphers.html#CIPHER_LIST_FORMAT}{OpenSSL ciphers(1) utility documentation}.
885 885
886\subsubsection[\fn{context:setCurvesList}]{\fn{context:setCurvesList($string$ [, ...])}}
887
888Sets the supported curves. The string format is a list of colon separated curve names similar to \texttt{ctx:setCipherList(...)}. A list of supported curves can be found by running \texttt{openssl ecparam -list\_curves}.
889
890\emph{Only supported since OpenSSL 1.0.2.}
891
886\subsubsection[\fn{context:setEphemeralKey}]{\fn{context:setEphemeralKey($key$)}} 892\subsubsection[\fn{context:setEphemeralKey}]{\fn{context:setEphemeralKey($key$)}}
887 893
888Sets \module{openssl.pkey} object $key$ as the ephemeral key during key exchanges which use that particular key type. Typically $key$ will be either a Diffie-Hellman or Elliptic Curve key. 894Sets \module{openssl.pkey} object $key$ as the ephemeral key during key exchanges which use that particular key type. Typically $key$ will be either a Diffie-Hellman or Elliptic Curve key.
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 @@
254#define HAVE_SSL_CTX_GET0_PARAM OPENSSL_PREREQ(1,0,2) 254#define HAVE_SSL_CTX_GET0_PARAM OPENSSL_PREREQ(1,0,2)
255#endif 255#endif
256 256
257#ifndef HAVE_SSL_CTX_SET_CURVES_LIST
258#define HAVE_SSL_CTX_SET_CURVES_LIST (OPENSSL_PREREQ(1,0,2) || LIBRESSL_PREREQ(2,5,1))
259#endif
260
257#ifndef HAVE_SSL_CTX_SET_ALPN_PROTOS 261#ifndef HAVE_SSL_CTX_SET_ALPN_PROTOS
258#define HAVE_SSL_CTX_SET_ALPN_PROTOS (OPENSSL_PREREQ(1,0,2) || LIBRESSL_PREREQ(2,1,3)) 262#define HAVE_SSL_CTX_SET_ALPN_PROTOS (OPENSSL_PREREQ(1,0,2) || LIBRESSL_PREREQ(2,1,3))
259#endif 263#endif
@@ -7746,6 +7750,21 @@ static int sx_setCipherList(lua_State *L) {
7746} /* sx_setCipherList() */ 7750} /* sx_setCipherList() */
7747 7751
7748 7752
7753#if HAVE_SSL_CTX_SET_CURVES_LIST
7754static int sx_setCurvesList(lua_State *L) {
7755 SSL_CTX *ctx = checksimple(L, 1, SSL_CTX_CLASS);
7756 const char *curves = luaL_checkstring(L, 2);
7757
7758 if (!SSL_CTX_set1_curves_list(ctx, curves))
7759 return auxL_error(L, auxL_EOPENSSL, "ssl.context:setCurvesList");
7760
7761 lua_pushboolean(L, 1);
7762
7763 return 1;
7764} /* sx_setCurvesList() */
7765#endif
7766
7767
7749static int sx_setEphemeralKey(lua_State *L) { 7768static int sx_setEphemeralKey(lua_State *L) {
7750 SSL_CTX *ctx = checksimple(L, 1, SSL_CTX_CLASS); 7769 SSL_CTX *ctx = checksimple(L, 1, SSL_CTX_CLASS);
7751 EVP_PKEY *key = checksimple(L, 2, PKEY_CLASS); 7770 EVP_PKEY *key = checksimple(L, 2, PKEY_CLASS);
@@ -7941,6 +7960,9 @@ static const auxL_Reg sx_methods[] = {
7941 { "setCertificate", &sx_setCertificate }, 7960 { "setCertificate", &sx_setCertificate },
7942 { "setPrivateKey", &sx_setPrivateKey }, 7961 { "setPrivateKey", &sx_setPrivateKey },
7943 { "setCipherList", &sx_setCipherList }, 7962 { "setCipherList", &sx_setCipherList },
7963#if HAVE_SSL_CTX_SET_CURVES_LIST
7964 { "setCurvesList", &sx_setCurvesList },
7965#endif
7944 { "setEphemeralKey", &sx_setEphemeralKey }, 7966 { "setEphemeralKey", &sx_setEphemeralKey },
7945#if HAVE_SSL_CTX_SET_ALPN_PROTOS 7967#if HAVE_SSL_CTX_SET_ALPN_PROTOS
7946 { "setAlpnProtos", &sx_setAlpnProtos }, 7968 { "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
13 return setCipherList(self, ciphers) 13 return setCipherList(self, ciphers)
14end) 14end)
15 15
16-- Allow passing a vararg of curves, or an array
17local setCurvesList = ctx.interpose("setCurvesList", nil)
18if setCurvesList then
19 ctx.interpose("setCurvesList", function (self, curves, ...)
20 if (...) then
21 local curves_t = pack(curves, ...)
22 curves = table.concat(curves_t, ":", 1, curves_t.n)
23 elseif type(curves) == "table" then
24 curves = table.concat(curves, ":")
25 end
26 return setCurvesList(self, curves)
27 end)
28end
29
16return ctx 30return ctx