From c26513f4f75fa7b6d8354a62ead096d117970640 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 20 Aug 2019 22:00:57 +0200 Subject: [PATCH] Special case listing of TLS 1.3 EC curves (fixes #146) --- src/ec.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/ec.c b/src/ec.c index 1dafb2d..73b09d7 100644 --- a/src/ec.c +++ b/src/ec.c @@ -56,25 +56,24 @@ void lsec_load_curves(lua_State *L) lua_pushnumber(L, curves[i].nid); lua_rawset(L, -3); break; -#ifdef NID_X25519 - case NID_X25519: - lua_pushstring(L, "X25519"); - lua_pushnumber(L, curves[i].nid); - lua_rawset(L, -3); - break; -#endif -#ifdef NID_X448 - case NID_X448: - lua_pushstring(L, "X448"); - lua_pushnumber(L, curves[i].nid); - lua_rawset(L, -3); - break; -#endif } } free(curves); } + /* These are special so are manually added here */ +#ifdef NID_X25519 + lua_pushstring(L, "X25519"); + lua_pushnumber(L, NID_X25519); + lua_rawset(L, -3); +#endif + +#ifdef NID_X448 + lua_pushstring(L, "X448"); + lua_pushnumber(L, NID_X448); + lua_rawset(L, -3); +#endif + lua_rawset(L, LUA_REGISTRYINDEX); }