Code format

This commit is contained in:
Bruno Silvestre 2022-07-20 17:39:20 -03:00
parent c9539bca86
commit f22b3ea609

View File

@ -675,36 +675,35 @@ static int meth_getpeerfinished(lua_State *L)
*/
static int meth_exportkeyingmaterial(lua_State *L)
{
p_ssl ssl = (p_ssl)luaL_checkudata(L, 1, "SSL:Connection");
p_ssl ssl = (p_ssl)luaL_checkudata(L, 1, "SSL:Connection");
if(ssl->state != LSEC_STATE_CONNECTED) {
lua_pushnil(L);
lua_pushstring(L, "closed");
return 0;
}
if(ssl->state != LSEC_STATE_CONNECTED) {
lua_pushnil(L);
lua_pushstring(L, "closed");
return 0;
}
size_t llen = 0;
const char *label = luaL_checklstring(L, 2, &llen);
int olen = luaL_checkinteger(L, 3);
size_t contextlen = 0;
const unsigned char *context = NULL;
size_t llen = 0;
const char *label = luaL_checklstring(L, 2, &llen);
int olen = luaL_checkinteger(L, 3);
size_t contextlen = 0;
const unsigned char *context = NULL;
if(!lua_isnoneornil(L, 4)) {
context = (unsigned char *)luaL_checklstring(L, 4, &contextlen);
}
if (!lua_isnoneornil(L, 4))
context = (unsigned char*)luaL_checklstring(L, 4, &contextlen);
/* temporary buffer memory-managed by Lua itself */
unsigned char *out = lua_newuserdata(L, olen);
/* Temporary buffer memory-managed by Lua itself */
unsigned char *out = lua_newuserdata(L, olen);
if(SSL_export_keying_material(ssl->ssl, out, olen, label, llen, context, contextlen, context != NULL) != 1) {
lua_pushnil(L);
/* Could not find whether OpenSSL keeps any details anywhere */
lua_pushstring(L, "error exporting keying material");
return 2;
}
if(SSL_export_keying_material(ssl->ssl, out, olen, label, llen, context, contextlen, context != NULL) != 1) {
lua_pushnil(L);
/* Could not find whether OpenSSL keeps any details anywhere */
lua_pushstring(L, "error exporting keying material");
return 2;
}
lua_pushlstring(L, (char *)out, olen);
return 1;
lua_pushlstring(L, (char*)out, olen);
return 1;
}
/**