From c0c334e88bffc74a97b1316d0c55cedd4b041ccb Mon Sep 17 00:00:00 2001 From: daurnimator Date: Tue, 30 Oct 2018 18:09:13 +1100 Subject: Add openssl.extensionSupported() --- src/openssl.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src') diff --git a/src/openssl.c b/src/openssl.c index d8d9e01..6b6d5cd 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -351,6 +351,10 @@ #define HAVE_SSL_CTX_USE_SERVERINFO_FILE OPENSSL_PREREQ(1,0,2) #endif +#ifndef HAVE_SSL_EXTENSION_SUPPORTED +#define HAVE_SSL_EXTENSION_SUPPORTED OPENSSL_PREREQ(1,0,2) +#endif + #ifndef HAVE_SSL_GET0_ALPN_SELECTED #define HAVE_SSL_GET0_ALPN_SELECTED HAVE_SSL_CTX_SET_ALPN_PROTOS #endif @@ -2456,8 +2460,23 @@ static int ossl_version(lua_State *L) { return 1; } /* ossl_version() */ + +#if HAVE_SSL_EXTENSION_SUPPORTED +static int ossl_extensionSupported(lua_State *L) { + unsigned int ext_type = auxL_checkunsigned(L, 1); + + lua_pushboolean(L, SSL_extension_supported(ext_type)); + + return 1; +} /* ossl_extensionSupported() */ +#endif + + static const auxL_Reg ossl_globals[] = { { "version", &ossl_version }, +#if HAVE_SSL_EXTENSION_SUPPORTED + { "extensionSupported", &ossl_extensionSupported }, +#endif { NULL, NULL }, }; -- cgit v1.2.3-59-g8ed1b