aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatarLibravatar daurnimator <quae@daurnimator.com> 2017-10-26 17:52:30 +1100
committerLibravatarLibravatar daurnimator <quae@daurnimator.com> 2017-10-26 17:52:30 +1100
commitdee73c581f25525fdd3e1d05e7736161ad7e1702 (patch)
treec8d2be1680403e9ab0496749b7b6f5bb7cae508b /src
parent1b899c92e0dc535cbbb195f48c8ac64446e993c1 (diff)
downloadluaossl-dee73c581f25525fdd3e1d05e7736161ad7e1702.tar.gz
luaossl-dee73c581f25525fdd3e1d05e7736161ad7e1702.tar.bz2
luaossl-dee73c581f25525fdd3e1d05e7736161ad7e1702.zip
src/openssl.c: Bind SSL_SESSION_get_master_key as ssl:getMasterKey()
Diffstat (limited to 'src')
-rw-r--r--src/openssl.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/openssl.c b/src/openssl.c
index 5ff80fe..0633edd 100644
--- a/src/openssl.c
+++ b/src/openssl.c
@@ -8919,6 +8919,28 @@ static int ssl_getClientRandom(lua_State *L) {
} /* ssl_getClientRandom() */
+static int ssl_getMasterKey(lua_State *L) {
+ SSL *ssl = checksimple(L, 1, SSL_CLASS);
+ SSL_SESSION *session;
+ luaL_Buffer B;
+ size_t len;
+ unsigned char *out;
+
+ session = SSL_get0_session(ssl);
+ if (!session) {
+ lua_pushnil(L);
+ return 1;
+ }
+
+ len = SSL_SESSION_get_master_key(session, NULL, 0);
+ out = (unsigned char*)luaL_buffinitsize(L, &B, len);
+ len = SSL_SESSION_get_master_key(session, out, len);
+ luaL_pushresultsize(&B, len);
+
+ return 1;
+} /* ssl_getMasterKey() */
+
+
static int ssl_getClientVersion(lua_State *L) {
SSL *ssl = checksimple(L, 1, SSL_CLASS);
int format = luaL_checkoption(L, 2, "d", (const char *[]){ "d", ".", "f", NULL });
@@ -9104,6 +9126,7 @@ static const auxL_Reg ssl_methods[] = {
{ "setHostName", &ssl_setHostName },
{ "getVersion", &ssl_getVersion },
{ "getClientRandom", &ssl_getClientRandom },
+ { "getMasterKey", &ssl_getMasterKey },
{ "getClientVersion", &ssl_getClientVersion },
#if HAVE_SSL_GET0_ALPN_SELECTED
{ "getAlpnSelected", &ssl_getAlpnSelected },