mirror of
https://github.com/brunoos/luasec.git
synced 2025-07-16 13:59:52 +02:00
Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
4c06287052 | |||
5f4799d8cf | |||
5787d51bb8 | |||
a2b211f847 | |||
769ac528e2 | |||
0f0e07eb41 | |||
fddde111f7 | |||
6405645155 | |||
e01c6e63cd | |||
c297c5204c | |||
e42bc358e2 | |||
f72457bbf9 | |||
361813c0da |
24
CHANGELOG
24
CHANGELOG
@ -1,3 +1,27 @@
|
||||
--------------------------------------------------------------------------------
|
||||
LuaSec 1.3.2
|
||||
---------------
|
||||
This version includes:
|
||||
|
||||
* Fix: place EAI_OVERFLOW inside macro, unbreak build on <10.7 (Sergey Fedorov)
|
||||
* Fix: Expand workaround for zero errno to OpenSSL 3.0.x (Kim Alvefur)
|
||||
* Fix: reset block timeout at send or receive (MartinDahlberg)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
LuaSec 1.3.1
|
||||
---------------
|
||||
This version includes:
|
||||
|
||||
* Fix: check if PSK is available
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
LuaSec 1.3.0
|
||||
---------------
|
||||
This version includes:
|
||||
|
||||
* Add :getlocalchain() + :getlocalcertificate() to mirror the peer methods (@mwild1)
|
||||
* Add Pre-Shared Key (PSK) support (@jclab-joseph)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
LuaSec 1.2.0
|
||||
---------------
|
||||
|
4
INSTALL
4
INSTALL
@ -1,9 +1,9 @@
|
||||
LuaSec 1.2.0
|
||||
LuaSec 1.3.2
|
||||
------------
|
||||
|
||||
* OpenSSL options:
|
||||
|
||||
By default, this version includes options for OpenSSL 3.0.0 beta2
|
||||
By default, this version includes options for OpenSSL 3.0.8
|
||||
|
||||
If you need to generate the options for a different version of OpenSSL:
|
||||
|
||||
|
4
LICENSE
4
LICENSE
@ -1,5 +1,5 @@
|
||||
LuaSec 1.2.0 license
|
||||
Copyright (C) 2006-2022 Bruno Silvestre, UFG
|
||||
LuaSec 1.3.2 license
|
||||
Copyright (C) 2006-2023 Bruno Silvestre, UFG
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
@ -1,4 +1,4 @@
|
||||
LuaSec 1.2.0
|
||||
LuaSec 1.3.2
|
||||
===============
|
||||
LuaSec depends on OpenSSL, and integrates with LuaSocket to make it
|
||||
easy to add secure connections to any Lua applications or scripts.
|
||||
|
@ -1,8 +1,8 @@
|
||||
package = "LuaSec"
|
||||
version = "1.2.0-1"
|
||||
version = "1.3.2-1"
|
||||
source = {
|
||||
url = "git+https://github.com/brunoos/luasec",
|
||||
tag = "v1.2.0",
|
||||
tag = "v1.3.2",
|
||||
}
|
||||
description = {
|
||||
summary = "A binding for OpenSSL library to provide TLS/SSL communication over LuaSocket.",
|
||||
@ -87,7 +87,7 @@ build = {
|
||||
"$(OPENSSL_BINDIR)",
|
||||
},
|
||||
libraries = {
|
||||
"libssl32MD", "libcrypto32MD", "ws2_32"
|
||||
"libssl", "libcrypto", "ws2_32"
|
||||
},
|
||||
incdirs = {
|
||||
"$(OPENSSL_INCDIR)", "src/", "src/luasocket"
|
@ -61,7 +61,7 @@
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>ws2_32.lib;libeay32MDd.lib;ssleay32MDd.lib;lua5.1.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>ws2_32.lib;libssl.lib;libcrypto.lib;lua5.1.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)ssl.dll</OutputFile>
|
||||
<AdditionalLibraryDirectories>C:\devel\openssl\lib\VC;C:\devel\lua-dll9;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
@ -85,7 +85,7 @@
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>ws2_32.lib;libssl32MD.lib;libcrypto32MD.lib;lua5.1.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>ws2_32.lib;libssl.lib;libcrypto.lib;lua5.1.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
||||
<AdditionalLibraryDirectories>C:\devel\openssl-1.1.0\lib\VC;C:\devel\lua-5.1\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
|
@ -4,6 +4,11 @@
|
||||
local socket = require("socket")
|
||||
local ssl = require("ssl")
|
||||
|
||||
if not ssl.config.capabilities.psk then
|
||||
print("[ERRO] PSK not available")
|
||||
os.exit(1)
|
||||
end
|
||||
|
||||
-- @param hint (nil | string)
|
||||
-- @param max_identity_len (number)
|
||||
-- @param max_psk_len (number)
|
||||
|
@ -4,6 +4,11 @@
|
||||
local socket = require("socket")
|
||||
local ssl = require("ssl")
|
||||
|
||||
if not ssl.config.capabilities.psk then
|
||||
print("[ERRO] PSK not available")
|
||||
os.exit(1)
|
||||
end
|
||||
|
||||
-- @param identity (string)
|
||||
-- @param max_psk_len (number)
|
||||
-- @return psk (string)
|
||||
|
14
src/compat.h
14
src/compat.h
@ -1,7 +1,7 @@
|
||||
/*--------------------------------------------------------------------------
|
||||
* LuaSec 1.2.0
|
||||
* LuaSec 1.3.2
|
||||
*
|
||||
* Copyright (C) 2006-2022 Bruno Silvestre
|
||||
* Copyright (C) 2006-2023 Bruno Silvestre
|
||||
*
|
||||
*--------------------------------------------------------------------------*/
|
||||
|
||||
@ -48,8 +48,14 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#if !defined(LIBRESSL_VERSION_NUMBER) && ((OPENSSL_VERSION_NUMBER & 0xFFFFF000L) == 0x10101000L)
|
||||
#define LSEC_OPENSSL_1_1_1
|
||||
#if !defined(LIBRESSL_VERSION_NUMBER) && ((OPENSSL_VERSION_NUMBER & 0xFFFFF000L) == 0x10101000L || (OPENSSL_VERSION_NUMBER & 0xFFFFF000L) == 0x30000000L)
|
||||
#define LSEC_OPENSSL_ERRNO_BUG
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#if !defined(LIBRESSL_VERSION_NUMBER) && !defined(OPENSSL_NO_PSK)
|
||||
#define LSEC_ENABLE_PSK
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
10
src/config.c
10
src/config.c
@ -1,7 +1,7 @@
|
||||
/*--------------------------------------------------------------------------
|
||||
* LuaSec 1.2.0
|
||||
* LuaSec 1.3.2
|
||||
*
|
||||
* Copyright (C) 2006-2022 Bruno Silvestre.
|
||||
* Copyright (C) 2006-2023 Bruno Silvestre
|
||||
*
|
||||
*--------------------------------------------------------------------------*/
|
||||
|
||||
@ -74,6 +74,12 @@ LSEC_API int luaopen_ssl_config(lua_State *L)
|
||||
lua_pushboolean(L, 1);
|
||||
lua_rawset(L, -3);
|
||||
|
||||
#ifdef LSEC_ENABLE_PSK
|
||||
lua_pushstring(L, "psk");
|
||||
lua_pushboolean(L, 1);
|
||||
lua_rawset(L, -3);
|
||||
#endif
|
||||
|
||||
#ifdef LSEC_ENABLE_DANE
|
||||
// DANE
|
||||
lua_pushstring(L, "dane");
|
||||
|
@ -1,9 +1,8 @@
|
||||
/*--------------------------------------------------------------------------
|
||||
* LuaSec 1.2.0
|
||||
* LuaSec 1.3.2
|
||||
*
|
||||
* Copyright (C) 2014-2022 Kim Alvefur, Paul Aurich, Tobias Markmann,
|
||||
* Matthew Wild.
|
||||
* Copyright (C) 2006-2022 Bruno Silvestre.
|
||||
* Copyright (C) 2014-2023 Kim Alvefur, Paul Aurich, Tobias Markmann, Matthew Wild
|
||||
* Copyright (C) 2006-2023 Bruno Silvestre
|
||||
*
|
||||
*--------------------------------------------------------------------------*/
|
||||
|
||||
@ -708,6 +707,7 @@ static int set_alpn_cb(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if defined(LSEC_ENABLE_PSK)
|
||||
/**
|
||||
* Callback to select the PSK.
|
||||
*/
|
||||
@ -842,6 +842,7 @@ static int set_client_psk_cb(lua_State *L) {
|
||||
lua_pushboolean(L, 1);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(LSEC_ENABLE_DANE)
|
||||
/*
|
||||
@ -894,9 +895,11 @@ static luaL_Reg funcs[] = {
|
||||
{"setdhparam", set_dhparam},
|
||||
{"setverify", set_verify},
|
||||
{"setoptions", set_options},
|
||||
#if defined(LSEC_ENABLE_PSK)
|
||||
{"setpskhint", set_psk_identity_hint},
|
||||
{"setserverpskcb", set_server_psk_cb},
|
||||
{"setclientpskcb", set_client_psk_cb},
|
||||
#endif
|
||||
{"setmode", set_mode},
|
||||
#if !defined(OPENSSL_NO_EC)
|
||||
{"setcurve", set_curve},
|
||||
|
@ -2,9 +2,9 @@
|
||||
#define LSEC_CONTEXT_H
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* LuaSec 1.2.0
|
||||
* LuaSec 1.3.2
|
||||
*
|
||||
* Copyright (C) 2006-2022 Bruno Silvestre
|
||||
* Copyright (C) 2006-2023 Bruno Silvestre
|
||||
*
|
||||
*--------------------------------------------------------------------------*/
|
||||
|
||||
|
7
src/ec.c
7
src/ec.c
@ -1,3 +1,10 @@
|
||||
/*--------------------------------------------------------------------------
|
||||
* LuaSec 1.3.2
|
||||
*
|
||||
* Copyright (C) 2006-2023 Bruno Silvestre
|
||||
*
|
||||
*--------------------------------------------------------------------------*/
|
||||
|
||||
#include <openssl/objects.h>
|
||||
|
||||
#include "ec.h"
|
||||
|
4
src/ec.h
4
src/ec.h
@ -1,7 +1,7 @@
|
||||
/*--------------------------------------------------------------------------
|
||||
* LuaSec 1.2.0
|
||||
* LuaSec 1.3.2
|
||||
*
|
||||
* Copyright (C) 2006-2022 Bruno Silvestre
|
||||
* Copyright (C) 2006-2023 Bruno Silvestre
|
||||
*
|
||||
*--------------------------------------------------------------------------*/
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
----------------------------------------------------------------------------
|
||||
-- LuaSec 1.2.0
|
||||
-- Copyright (C) 2009-2022 PUC-Rio
|
||||
-- LuaSec 1.3.2
|
||||
--
|
||||
-- Copyright (C) 2009-2023 PUC-Rio
|
||||
--
|
||||
-- Author: Pablo Musa
|
||||
-- Author: Tomas Guisasola
|
||||
@ -18,8 +19,8 @@ local try = socket.try
|
||||
-- Module
|
||||
--
|
||||
local _M = {
|
||||
_VERSION = "1.2.0",
|
||||
_COPYRIGHT = "LuaSec 1.2.0 - Copyright (C) 2009-2022 PUC-Rio",
|
||||
_VERSION = "1.3.2",
|
||||
_COPYRIGHT = "LuaSec 1.3.2 - Copyright (C) 2009-2023 PUC-Rio",
|
||||
PORT = 443,
|
||||
TIMEOUT = 60
|
||||
}
|
||||
|
@ -78,9 +78,7 @@ int buffer_meth_send(lua_State *L, p_buffer buf) {
|
||||
const char *data = luaL_checklstring(L, 2, &size);
|
||||
long start = (long) luaL_optnumber(L, 3, 1);
|
||||
long end = (long) luaL_optnumber(L, 4, -1);
|
||||
#ifdef LUASOCKET_DEBUG
|
||||
p_timeout tm = timeout_markstart(buf->tm);
|
||||
#endif
|
||||
timeout_markstart(buf->tm);
|
||||
if (start < 0) start = (long) (size+start+1);
|
||||
if (end < 0) end = (long) (size+end+1);
|
||||
if (start < 1) start = (long) 1;
|
||||
@ -98,7 +96,7 @@ int buffer_meth_send(lua_State *L, p_buffer buf) {
|
||||
}
|
||||
#ifdef LUASOCKET_DEBUG
|
||||
/* push time elapsed during operation as the last return value */
|
||||
lua_pushnumber(L, timeout_gettime() - timeout_getstart(tm));
|
||||
lua_pushnumber(L, timeout_gettime() - timeout_getstart(buf->tm));
|
||||
#endif
|
||||
return lua_gettop(L) - top;
|
||||
}
|
||||
@ -117,9 +115,7 @@ int buffer_meth_receive(lua_State *L, p_buffer buf) {
|
||||
top = 3;
|
||||
}
|
||||
part = luaL_optlstring(L, 3, "", &size);
|
||||
#ifdef LUASOCKET_DEBUG
|
||||
p_timeout tm = timeout_markstart(buf->tm);
|
||||
#endif
|
||||
timeout_markstart(buf->tm);
|
||||
/* initialize buffer with optional extra prefix
|
||||
* (useful for concatenating previous partial results) */
|
||||
luaL_buffinit(L, &b);
|
||||
@ -155,7 +151,7 @@ int buffer_meth_receive(lua_State *L, p_buffer buf) {
|
||||
}
|
||||
#ifdef LUASOCKET_DEBUG
|
||||
/* push time elapsed during operation as the last return value */
|
||||
lua_pushnumber(L, timeout_gettime() - timeout_getstart(tm));
|
||||
lua_pushnumber(L, timeout_gettime() - timeout_getstart(buf->tm));
|
||||
#endif
|
||||
return lua_gettop(L) - top;
|
||||
}
|
||||
|
@ -426,7 +426,9 @@ const char *socket_gaistrerror(int err) {
|
||||
case EAI_MEMORY: return "memory allocation failure";
|
||||
case EAI_NONAME:
|
||||
return "host or service not provided, or not known";
|
||||
#ifdef EAI_OVERFLOW
|
||||
case EAI_OVERFLOW: return "argument buffer overflow";
|
||||
#endif
|
||||
#ifdef EAI_PROTOCOL
|
||||
case EAI_PROTOCOL: return "resolved protocol is unknown";
|
||||
#endif
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*--------------------------------------------------------------------------
|
||||
* LuaSec 1.2.0
|
||||
* LuaSec 1.3.2
|
||||
*
|
||||
* Copyright (C) 2006-2022 Bruno Silvestre
|
||||
* Copyright (C) 2006-2023 Bruno Silvestre
|
||||
*
|
||||
*--------------------------------------------------------------------------*/
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
|
||||
/*
|
||||
OpenSSL version: OpenSSL 3.0.0-beta2
|
||||
OpenSSL version: OpenSSL 3.0.8
|
||||
*/
|
||||
|
||||
static lsec_ssl_option_t ssl_options[] = {
|
||||
|
@ -2,9 +2,9 @@
|
||||
#define LSEC_OPTIONS_H
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* LuaSec 1.2.0
|
||||
* LuaSec 1.3.2
|
||||
*
|
||||
* Copyright (C) 2006-2022 Bruno Silvestre
|
||||
* Copyright (C) 2006-2023 Bruno Silvestre
|
||||
*
|
||||
*--------------------------------------------------------------------------*/
|
||||
|
||||
|
@ -18,9 +18,9 @@ end
|
||||
local function generate(options, version)
|
||||
print([[
|
||||
/*--------------------------------------------------------------------------
|
||||
* LuaSec 1.2.0
|
||||
* LuaSec 1.3.2
|
||||
*
|
||||
* Copyright (C) 2006-2022 Bruno Silvestre
|
||||
* Copyright (C) 2006-2023 Bruno Silvestre
|
||||
*
|
||||
*--------------------------------------------------------------------------*/
|
||||
|
||||
|
13
src/ssl.c
13
src/ssl.c
@ -1,9 +1,8 @@
|
||||
/*--------------------------------------------------------------------------
|
||||
* LuaSec 1.2.0
|
||||
* LuaSec 1.3.2
|
||||
*
|
||||
* Copyright (C) 2014-2022 Kim Alvefur, Paul Aurich, Tobias Markmann,
|
||||
* Matthew Wild.
|
||||
* Copyright (C) 2006-2022 Bruno Silvestre.
|
||||
* Copyright (C) 2014-2023 Kim Alvefur, Paul Aurich, Tobias Markmann, Matthew Wild
|
||||
* Copyright (C) 2006-2023 Bruno Silvestre
|
||||
*
|
||||
*--------------------------------------------------------------------------*/
|
||||
|
||||
@ -48,8 +47,8 @@ static int lsec_socket_error()
|
||||
#if defined(WIN32)
|
||||
return WSAGetLastError();
|
||||
#else
|
||||
#if defined(LSEC_OPENSSL_1_1_1)
|
||||
// Bug in OpenSSL 1.1.1
|
||||
#if defined(LSEC_OPENSSL_ERRNO_BUG)
|
||||
// Bug in OpenSSL
|
||||
if (errno == 0)
|
||||
return LSEC_IO_SSL;
|
||||
#endif
|
||||
@ -948,7 +947,7 @@ static int meth_getalpn(lua_State *L)
|
||||
|
||||
static int meth_copyright(lua_State *L)
|
||||
{
|
||||
lua_pushstring(L, "LuaSec 1.2.0 - Copyright (C) 2006-2022 Bruno Silvestre, UFG"
|
||||
lua_pushstring(L, "LuaSec 1.3.2 - Copyright (C) 2006-2023 Bruno Silvestre, UFG"
|
||||
#if defined(WITH_LUASOCKET)
|
||||
"\nLuaSocket 3.0-RC1 - Copyright (C) 2004-2013 Diego Nehab"
|
||||
#endif
|
||||
|
@ -2,9 +2,9 @@
|
||||
#define LSEC_SSL_H
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* LuaSec 1.2.0
|
||||
* LuaSec 1.3.2
|
||||
*
|
||||
* Copyright (C) 2006-2022 Bruno Silvestre
|
||||
* Copyright (C) 2006-2023 Bruno Silvestre
|
||||
*
|
||||
*--------------------------------------------------------------------------*/
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
------------------------------------------------------------------------------
|
||||
-- LuaSec 1.2.0
|
||||
-- LuaSec 1.3.2
|
||||
--
|
||||
-- Copyright (C) 2006-2022 Bruno Silvestre
|
||||
-- Copyright (C) 2006-2023 Bruno Silvestre
|
||||
--
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
@ -202,7 +202,7 @@ local function newcontext(cfg)
|
||||
end
|
||||
|
||||
-- PSK
|
||||
if cfg.psk then
|
||||
if config.capabilities.psk and cfg.psk then
|
||||
if cfg.mode == "client" then
|
||||
if type(cfg.psk) ~= "function" then
|
||||
return nil, "invalid PSK configuration"
|
||||
@ -302,7 +302,7 @@ core.setmethod("info", info)
|
||||
--
|
||||
|
||||
local _M = {
|
||||
_VERSION = "1.2.0",
|
||||
_VERSION = "1.3.2",
|
||||
_COPYRIGHT = core.copyright(),
|
||||
config = config,
|
||||
loadcertificate = x509.load,
|
||||
|
@ -1,8 +1,8 @@
|
||||
/*--------------------------------------------------------------------------
|
||||
* LuaSec 1.2.0
|
||||
* LuaSec 1.3.2
|
||||
*
|
||||
* Copyright (C) 2014-2022 Kim Alvefur, Paul Aurich, Tobias Markmann
|
||||
* Matthew Wild, Bruno Silvestre.
|
||||
* Copyright (C) 2014-2023 Kim Alvefur, Paul Aurich, Tobias Markmann, Matthew Wild
|
||||
* Copyright (C) 2014-2023 Bruno Silvestre
|
||||
*
|
||||
*--------------------------------------------------------------------------*/
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
/*--------------------------------------------------------------------------
|
||||
* LuaSec 1.2.0
|
||||
* LuaSec 1.3.2
|
||||
*
|
||||
* Copyright (C) 2014-2022 Kim Alvefur, Paul Aurich, Tobias Markmann
|
||||
* Matthew Wild, Bruno Silvestre.
|
||||
* Copyright (C) 2014-2023 Kim Alvefur, Paul Aurich, Tobias Markmann, Matthew Wild
|
||||
* Copyright (C) 2013-2023 Bruno Silvestre
|
||||
*
|
||||
*--------------------------------------------------------------------------*/
|
||||
|
||||
|
Reference in New Issue
Block a user