aboutsummaryrefslogtreecommitdiffstats
path: root/src/openssl.c
diff options
context:
space:
mode:
authorLibravatarLibravatar daurnimator <quae@daurnimator.com> 2018-11-01 17:02:20 +1100
committerLibravatarLibravatar daurnimator <quae@daurnimator.com> 2018-11-01 17:03:04 +1100
commit073976efbdfe5d78597872579485fed75e3ce8aa (patch)
treeb4ea017376bca25b8cd18baa4e1f96db1d9912b9 /src/openssl.c
parent3540ec0895993988f32ecb779fe5f56dce0f4753 (diff)
downloadluaossl-073976efbdfe5d78597872579485fed75e3ce8aa.tar.gz
luaossl-073976efbdfe5d78597872579485fed75e3ce8aa.tar.bz2
luaossl-073976efbdfe5d78597872579485fed75e3ce8aa.zip
src/openssl.c: Factor out mk_checkdigest from mk_optdigest
Diffstat (limited to 'src/openssl.c')
-rw-r--r--src/openssl.c13
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() */