mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-12 14:09:12 +00:00
PROPERLY make arguments optional in crypto.generatekeypair thanks to @pkulchenko
This commit is contained in:
parent
558214598f
commit
9e121882d0
1 changed files with 6 additions and 2 deletions
|
@ -1110,8 +1110,12 @@ static int LuaCryptoDecrypt(lua_State *L) {
|
|||
}
|
||||
|
||||
static int LuaCryptoGenerateKeyPair(lua_State *L) {
|
||||
const char *key_type = luaL_optstring(L, 1, "rsa"); // Key type (e.g., "rsa", "ecdsa")
|
||||
const char *key_type = "rsa"; // Key type (e.g., "rsa", "ecdsa")
|
||||
|
||||
if (! lua_isinteger(L, 1) && ! lua_isnoneornil(L, 1)) {
|
||||
key_type = luaL_checkstring(L, 1); // Get key type from first argumen
|
||||
lua_remove(L, 1); // Remove the first argument (key type or cipher type) before dispatching
|
||||
}
|
||||
|
||||
if (strcasecmp(key_type, "rsa") == 0) {
|
||||
return LuaRSAGenerateKeyPair(L);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue