Make key type optional in crypto.generateKeyPair. Defaults to rsa

This commit is contained in:
Miguel Terron 2025-06-02 15:30:37 +12:00
parent e1403ff9a9
commit c1be35a820

View file

@ -1110,7 +1110,7 @@ static int LuaCryptoDecrypt(lua_State *L) {
} }
static int LuaCryptoGenerateKeyPair(lua_State *L) { static int LuaCryptoGenerateKeyPair(lua_State *L) {
const char *key_type = luaL_checkstring(L, 1); // Key type (e.g., "rsa", "ecdsa") const char *key_type = luaL_optstring(L, 1, "rsa"); // Key type (e.g., "rsa", "ecdsa")
lua_remove(L, 1); // Remove the first argument (key type or cipher type) before dispatching lua_remove(L, 1); // Remove the first argument (key type or cipher type) before dispatching
if (strcasecmp(key_type, "rsa") == 0) { if (strcasecmp(key_type, "rsa") == 0) {