From 073976efbdfe5d78597872579485fed75e3ce8aa Mon Sep 17 00:00:00 2001 From: daurnimator Date: Thu, 1 Nov 2018 17:02:20 +1100 Subject: src/openssl.c: Factor out mk_checkdigest from mk_optdigest --- src/openssl.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/openssl.c b/src/openssl.c index 8b73be6..370ef45 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -10725,14 +10725,23 @@ EXPORT int luaopen__openssl_x509_verify_param(lua_State *L) { * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -static const EVP_MD *md_optdigest(lua_State *L, int index) { - const char *name = luaL_optstring(L, index, "sha1"); + +static const EVP_MD *md_checkdigest(lua_State *L, int index) { + const char *name = luaL_checkstring(L, index); const EVP_MD *type; if (!(type = EVP_get_digestbyname(name))) luaL_argerror(L, index, lua_pushfstring(L, "%s: invalid digest type", name)); return type; +} /* md_checkdigest() */ + + +static const EVP_MD *md_optdigest(lua_State *L, int index) { + if (lua_isnoneornil(L, index)) + return EVP_get_digestbyname("sha1"); + + return md_checkdigest(L, index); } /* md_optdigest() */ -- cgit v1.2.3-59-g8ed1b