diff options
author | daurnimator <quae@daurnimator.com> | 2018-11-01 17:02:20 +1100 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2018-11-01 17:03:04 +1100 |
commit | 073976efbdfe5d78597872579485fed75e3ce8aa (patch) | |
tree | b4ea017376bca25b8cd18baa4e1f96db1d9912b9 /src | |
parent | 3540ec0895993988f32ecb779fe5f56dce0f4753 (diff) | |
download | luaossl-073976efbdfe5d78597872579485fed75e3ce8aa.tar.gz luaossl-073976efbdfe5d78597872579485fed75e3ce8aa.tar.bz2 luaossl-073976efbdfe5d78597872579485fed75e3ce8aa.zip |
src/openssl.c: Factor out mk_checkdigest from mk_optdigest
Diffstat (limited to 'src')
-rw-r--r-- | src/openssl.c | 13 |
1 files changed, 11 insertions, 2 deletions
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() */ |