Add LuaCrypto compatible functions (plus some auxiliary functions) as per #1136

This commit is contained in:
Miguel Terron 2025-06-01 21:23:34 +12:00
parent 4ca513cba2
commit 55dcce4f7d
6 changed files with 1161 additions and 1 deletions

View file

@ -71,10 +71,10 @@
/* eliptic curves */
#define MBEDTLS_ECP_DP_SECP256R1_ENABLED
#define MBEDTLS_ECP_DP_SECP384R1_ENABLED
#define MBEDTLS_ECP_DP_SECP521R1_ENABLED
#define MBEDTLS_ECP_DP_CURVE25519_ENABLED
#ifndef TINY
#define MBEDTLS_ECP_DP_CURVE448_ENABLED
/*#define MBEDTLS_ECP_DP_SECP521R1_ENABLED*/
/*#define MBEDTLS_ECP_DP_BP384R1_ENABLED*/
/*#define MBEDTLS_ECP_DP_SECP192R1_ENABLED*/
/*#define MBEDTLS_ECP_DP_SECP224R1_ENABLED*/

View file

@ -100,6 +100,7 @@ TOOL_NET_REDBEAN_LUA_MODULES = \
o/$(MODE)/tool/net/lmaxmind.o \
o/$(MODE)/tool/net/lsqlite3.o \
o/$(MODE)/tool/net/largon2.o \
o/$(MODE)/tool/net/lcrypto.o \
o/$(MODE)/tool/net/launch.o
o/$(MODE)/tool/net/redbean.dbg: \

1147
tool/net/lcrypto.c Normal file

File diff suppressed because it is too large Load diff

10
tool/net/lcrypto.h Normal file
View file

@ -0,0 +1,10 @@
#ifndef COSMOPOLITAN_TOOL_NET_LCRYPTO_H_
#define COSMOPOLITAN_TOOL_NET_LCRYPTO_H_
#include "third_party/lua/lauxlib.h"
COSMOPOLITAN_C_START_
int LuaCrypto(lua_State *L);
int luaopen_lcrypto(lua_State *L);
COSMOPOLITAN_C_END_
#endif /* COSMOPOLITAN_TOOL_NET_LCRYPTO_H_ */

View file

@ -8,6 +8,7 @@ int LuaMaxmind(lua_State *);
int LuaRe(lua_State *);
int luaopen_argon2(lua_State *);
int luaopen_lsqlite3(lua_State *);
int LuaCrypto(lua_State *);
int LuaBarf(lua_State *);
int LuaBenchmark(lua_State *);

View file

@ -5426,6 +5426,7 @@ static const luaL_Reg kLuaLibs[] = {
{"path", LuaPath}, //
{"re", LuaRe}, //
{"unix", LuaUnix}, //
{"crypto", LuaCrypto}, //
};
static void LuaSetArgv(lua_State *L) {