# HG changeset patch # User Kim Alvefur # Date 1606669125 -3600 # Node ID adfb46a3e8a72d98f4f8efa6d6b715b2b39b8bac # Parent 1e41dd0f8353df4cdfbcf610d572ac5b44e3e164 util.hashes: Expose sha224 and sha384 HMAC functions For completeness and consistency with set of plain hash functions diff -r 1e41dd0f8353 -r adfb46a3e8a7 teal-src/util/hashes.d.tl --- a/teal-src/util/hashes.d.tl Sun Nov 29 17:58:30 2020 +0100 +++ b/teal-src/util/hashes.d.tl Sun Nov 29 17:58:45 2020 +0100 @@ -11,6 +11,8 @@ md5 : hash hmac_sha1 : hmac hmac_sha256 : hmac + hmac_sha224 : hmac + hmac_sha384 :hmac hmac_sha512 : hmac hmac_md5 : hmac scram_Hi_sha1 : kdf diff -r 1e41dd0f8353 -r adfb46a3e8a7 util-src/hashes.c --- a/util-src/hashes.c Sun Nov 29 17:58:30 2020 +0100 +++ b/util-src/hashes.c Sun Nov 29 17:58:45 2020 +0100 @@ -169,10 +169,18 @@ return Levp_hmac(L, EVP_sha1()); } +static int Lhmac_sha224(lua_State *L) { + return Levp_hmac(L, EVP_sha224()); +} + static int Lhmac_sha256(lua_State *L) { return Levp_hmac(L, EVP_sha256()); } +static int Lhmac_sha384(lua_State *L) { + return Levp_hmac(L, EVP_sha384()); +} + static int Lhmac_sha512(lua_State *L) { return Levp_hmac(L, EVP_sha512()); } @@ -236,7 +244,9 @@ { "sha512", Lsha512 }, { "md5", Lmd5 }, { "hmac_sha1", Lhmac_sha1 }, + { "hmac_sha224", Lhmac_sha224 }, { "hmac_sha256", Lhmac_sha256 }, + { "hmac_sha384", Lhmac_sha384 }, { "hmac_sha512", Lhmac_sha512 }, { "hmac_md5", Lhmac_md5 }, { "scram_Hi_sha1", Lpbkdf2_sha1 }, /* COMPAT */ diff -r 1e41dd0f8353 -r adfb46a3e8a7 util/hmac.lua --- a/util/hmac.lua Sun Nov 29 17:58:30 2020 +0100 +++ b/util/hmac.lua Sun Nov 29 17:58:45 2020 +0100 @@ -13,6 +13,8 @@ return { md5 = hashes.hmac_md5, sha1 = hashes.hmac_sha1, + sha224 = hashes.hmac_sha224, sha256 = hashes.hmac_sha256, + sha384 = hashes.hmac_sha384, sha512 = hashes.hmac_sha512, };