Lines Matching refs:luastate

61 static int GetCertNotBefore(lua_State *luastate, const Flow *f, int direction)  in GetCertNotBefore()  argument
65 return LuaCallbackError(luastate, "error: no app layer state"); in GetCertNotBefore()
77 return LuaCallbackError(luastate, "error: no certificate NotBefore"); in GetCertNotBefore()
79 int r = LuaPushInteger(luastate, connp->cert0_not_before); in GetCertNotBefore()
84 static int TlsGetCertNotBefore(lua_State *luastate) in TlsGetCertNotBefore() argument
88 if (!(LuaStateNeedProto(luastate, ALPROTO_TLS))) in TlsGetCertNotBefore()
89 return LuaCallbackError(luastate, "error: protocol not tls"); in TlsGetCertNotBefore()
91 int direction = LuaStateGetDirection(luastate); in TlsGetCertNotBefore()
93 Flow *f = LuaStateGetFlow(luastate); in TlsGetCertNotBefore()
95 return LuaCallbackError(luastate, "internal error: no flow"); in TlsGetCertNotBefore()
97 r = GetCertNotBefore(luastate, f, direction); in TlsGetCertNotBefore()
102 static int GetCertNotAfter(lua_State *luastate, const Flow *f, int direction) in GetCertNotAfter() argument
106 return LuaCallbackError(luastate, "error: no app layer state"); in GetCertNotAfter()
118 return LuaCallbackError(luastate, "error: no certificate NotAfter"); in GetCertNotAfter()
120 int r = LuaPushInteger(luastate, connp->cert0_not_after); in GetCertNotAfter()
125 static int TlsGetCertNotAfter(lua_State *luastate) in TlsGetCertNotAfter() argument
129 if (!(LuaStateNeedProto(luastate, ALPROTO_TLS))) in TlsGetCertNotAfter()
130 return LuaCallbackError(luastate, "error: protocol not tls"); in TlsGetCertNotAfter()
132 int direction = LuaStateGetDirection(luastate); in TlsGetCertNotAfter()
134 Flow *f = LuaStateGetFlow(luastate); in TlsGetCertNotAfter()
136 return LuaCallbackError(luastate, "internal error: no flow"); in TlsGetCertNotAfter()
138 r = GetCertNotAfter(luastate, f, direction); in TlsGetCertNotAfter()
143 static int GetCertInfo(lua_State *luastate, const Flow *f, int direction) in GetCertInfo() argument
147 return LuaCallbackError(luastate, "error: no app layer state"); in GetCertInfo()
159 return LuaCallbackError(luastate, "error: no cert"); in GetCertInfo()
165 int r = LuaPushStringBuffer(luastate, (uint8_t *)ssl_version, strlen(ssl_version)); in GetCertInfo()
166 … r += LuaPushStringBuffer(luastate, (uint8_t *)connp->cert0_subject, strlen(connp->cert0_subject)); in GetCertInfo()
167 …r += LuaPushStringBuffer(luastate, (uint8_t *)connp->cert0_issuerdn, strlen(connp->cert0_issuerdn)… in GetCertInfo()
168 …r += LuaPushStringBuffer(luastate, (uint8_t *)connp->cert0_fingerprint, strlen(connp->cert0_finger… in GetCertInfo()
172 static int TlsGetCertInfo(lua_State *luastate) in TlsGetCertInfo() argument
176 if (!(LuaStateNeedProto(luastate, ALPROTO_TLS))) in TlsGetCertInfo()
177 return LuaCallbackError(luastate, "error: protocol not tls"); in TlsGetCertInfo()
179 int direction = LuaStateGetDirection(luastate); in TlsGetCertInfo()
181 Flow *f = LuaStateGetFlow(luastate); in TlsGetCertInfo()
183 return LuaCallbackError(luastate, "internal error: no flow"); in TlsGetCertInfo()
185 r = GetCertInfo(luastate, f, direction); in TlsGetCertInfo()
190 static int GetAgreedVersion(lua_State *luastate, const Flow *f) in GetAgreedVersion() argument
194 return LuaCallbackError(luastate, "error: no app layer state"); in GetAgreedVersion()
201 return LuaPushStringBuffer(luastate, (uint8_t *)ssl_version, in GetAgreedVersion()
205 static int TlsGetVersion(lua_State *luastate) in TlsGetVersion() argument
209 if (!(LuaStateNeedProto(luastate, ALPROTO_TLS))) in TlsGetVersion()
210 return LuaCallbackError(luastate, "error: protocol not tls"); in TlsGetVersion()
212 Flow *f = LuaStateGetFlow(luastate); in TlsGetVersion()
214 return LuaCallbackError(luastate, "internal error: no flow"); in TlsGetVersion()
216 r = GetAgreedVersion(luastate, f); in TlsGetVersion()
221 static int GetSNI(lua_State *luastate, const Flow *f) in GetSNI() argument
225 return LuaCallbackError(luastate, "error: no app layer state"); in GetSNI()
230 return LuaCallbackError(luastate, "error: no server name indication"); in GetSNI()
232 return LuaPushStringBuffer(luastate, (uint8_t *)ssl_state->client_connp.sni, in GetSNI()
236 static int TlsGetSNI(lua_State *luastate) in TlsGetSNI() argument
240 if (!(LuaStateNeedProto(luastate, ALPROTO_TLS))) in TlsGetSNI()
241 return LuaCallbackError(luastate, "error: protocol not tls"); in TlsGetSNI()
243 Flow *f = LuaStateGetFlow(luastate); in TlsGetSNI()
245 return LuaCallbackError(luastate, "internal error: no flow"); in TlsGetSNI()
247 r = GetSNI(luastate, f); in TlsGetSNI()
252 static int GetCertSerial(lua_State *luastate, const Flow *f) in GetCertSerial() argument
256 return LuaCallbackError(luastate, "error: no app layer state"); in GetCertSerial()
261 return LuaCallbackError(luastate, "error: no certificate serial"); in GetCertSerial()
263 return LuaPushStringBuffer(luastate, in GetCertSerial()
268 static int TlsGetCertSerial(lua_State *luastate) in TlsGetCertSerial() argument
272 if (!(LuaStateNeedProto(luastate, ALPROTO_TLS))) in TlsGetCertSerial()
273 return LuaCallbackError(luastate, "error: protocol not tls"); in TlsGetCertSerial()
275 Flow *f = LuaStateGetFlow(luastate); in TlsGetCertSerial()
277 return LuaCallbackError(luastate, "internal error: no flow"); in TlsGetCertSerial()
279 r = GetCertSerial(luastate, f); in TlsGetCertSerial()
284 static int GetCertChain(lua_State *luastate, const Flow *f, int direction) in GetCertChain() argument
288 return LuaCallbackError(luastate, "error: no app layer state"); in GetCertChain()
300 lua_newtable(luastate); in GetCertChain()
304 lua_pushinteger(luastate, u++); in GetCertChain()
306 lua_newtable(luastate); in GetCertChain()
308 lua_pushstring(luastate, "length"); in GetCertChain()
309 lua_pushinteger(luastate, cert->cert_len); in GetCertChain()
310 lua_settable(luastate, -3); in GetCertChain()
312 lua_pushstring(luastate, "data"); in GetCertChain()
313 LuaPushStringBuffer(luastate, cert->cert_data, cert->cert_len); in GetCertChain()
315 lua_settable(luastate, -3); in GetCertChain()
316 lua_settable(luastate, -3); in GetCertChain()
322 static int TlsGetCertChain(lua_State *luastate) in TlsGetCertChain() argument
326 if (!(LuaStateNeedProto(luastate, ALPROTO_TLS))) in TlsGetCertChain()
327 return LuaCallbackError(luastate, "error: protocol not tls"); in TlsGetCertChain()
329 int direction = LuaStateGetDirection(luastate); in TlsGetCertChain()
331 Flow *f = LuaStateGetFlow(luastate); in TlsGetCertChain()
333 return LuaCallbackError(luastate, "internal error: no flow"); in TlsGetCertChain()
335 r = GetCertChain(luastate, f, direction); in TlsGetCertChain()
341 int LuaRegisterTlsFunctions(lua_State *luastate) in LuaRegisterTlsFunctions() argument
344 lua_pushcfunction(luastate, TlsGetCertNotBefore); in LuaRegisterTlsFunctions()
345 lua_setglobal(luastate, "TlsGetCertNotBefore"); in LuaRegisterTlsFunctions()
347 lua_pushcfunction(luastate, TlsGetCertNotAfter); in LuaRegisterTlsFunctions()
348 lua_setglobal(luastate, "TlsGetCertNotAfter"); in LuaRegisterTlsFunctions()
350 lua_pushcfunction(luastate, TlsGetVersion); in LuaRegisterTlsFunctions()
351 lua_setglobal(luastate, "TlsGetVersion"); in LuaRegisterTlsFunctions()
353 lua_pushcfunction(luastate, TlsGetCertInfo); in LuaRegisterTlsFunctions()
354 lua_setglobal(luastate, "TlsGetCertInfo"); in LuaRegisterTlsFunctions()
356 lua_pushcfunction(luastate, TlsGetSNI); in LuaRegisterTlsFunctions()
357 lua_setglobal(luastate, "TlsGetSNI"); in LuaRegisterTlsFunctions()
359 lua_pushcfunction(luastate, TlsGetCertSerial); in LuaRegisterTlsFunctions()
360 lua_setglobal(luastate, "TlsGetCertSerial"); in LuaRegisterTlsFunctions()
362 lua_pushcfunction(luastate, TlsGetCertChain); in LuaRegisterTlsFunctions()
363 lua_setglobal(luastate, "TlsGetCertChain"); in LuaRegisterTlsFunctions()