From 0b99832ec78e59d3321601f691cd14f56e97aa82 Mon Sep 17 00:00:00 2001 From: Bruno Silvestre Date: Fri, 16 Jun 2017 22:50:27 -0300 Subject: [PATCH] Export configuration (protocols, options, curves, algorithms, capabilities) --- src/Makefile | 4 +++- src/context.c | 6 +++--- src/ec.c | 22 ++++++++++++++++++++++ src/ec.h | 1 + 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/Makefile b/src/Makefile index 920dda6..9be2f14 100644 --- a/src/Makefile +++ b/src/Makefile @@ -5,6 +5,7 @@ OBJS= \ x509.o \ context.o \ ssl.o \ + config.o \ ec.o LIBS=-lssl -lcrypto -lluasocket @@ -56,7 +57,8 @@ clean: cd luasocket && $(MAKE) clean rm -f $(OBJS) $(CMOD) +ec.o: ec.c ec.h x509.o: x509.c x509.h compat.h context.o: context.c context.h ec.h compat.h ssl.o: ssl.c ssl.h context.h x509.h compat.h -ec.o: ec.c ec.h +config.o: config.c ec.h options.h compat.h diff --git a/src/context.c b/src/context.c index 88229ab..760355e 100644 --- a/src/context.c +++ b/src/context.c @@ -24,7 +24,7 @@ #include "context.h" #include "options.h" -#ifndef OPENSSL_NO_ECDH +#ifndef OPENSSL_NO_EC #include #include "ec.h" #endif @@ -549,11 +549,11 @@ static int set_dhparam(lua_State *L) /** * Set elliptic curve. */ -#ifdef OPENSSL_NO_ECDH +#ifdef OPENSSL_NO_EC static int set_curve(lua_State *L) { lua_pushboolean(L, 0); - lua_pushstring(L, "OpenSSL does not support ECDH"); + lua_pushstring(L, "OpenSSL does not support EC"); return 2; } #else diff --git a/src/ec.c b/src/ec.c index 3f53494..065866a 100644 --- a/src/ec.c +++ b/src/ec.c @@ -47,6 +47,23 @@ void lsec_load_curves(lua_State *L) lua_rawset(L, LUA_REGISTRYINDEX); } +void lsec_get_curves(lua_State *L) +{ + lua_newtable(L); + + lua_pushstring(L, "SSL:EC:CURVES"); + lua_rawget(L, LUA_REGISTRYINDEX); + + lua_pushnil(L); + while (lua_next(L, -2) != 0) { + lua_pop(L, 1); + lua_pushvalue(L, -1); + lua_pushboolean(L, 1); + lua_rawset(L, -5); + } + lua_pop(L, 1); +} + #else void lsec_load_curves(lua_State *L) @@ -54,4 +71,9 @@ void lsec_load_curves(lua_State *L) // do nothing } +void lsec_get_curves(lua_State *L) +{ + lua_newtable(L); +} + #endif diff --git a/src/ec.h b/src/ec.h index 6453adb..cbef80a 100644 --- a/src/ec.h +++ b/src/ec.h @@ -15,6 +15,7 @@ EC_KEY *lsec_find_ec_key(lua_State *L, const char *str); #endif +void lsec_get_curves(lua_State *L); void lsec_load_curves(lua_State *L); #endif