Export configuration (protocols, options, curves, algorithms, capabilities)

This commit is contained in:
Bruno Silvestre 2017-06-16 22:50:27 -03:00
parent fc757e1fd0
commit 0b99832ec7
4 changed files with 29 additions and 4 deletions

View File

@ -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

View File

@ -24,7 +24,7 @@
#include "context.h"
#include "options.h"
#ifndef OPENSSL_NO_ECDH
#ifndef OPENSSL_NO_EC
#include <openssl/ec.h>
#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

View File

@ -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

View File

@ -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