Comparison

util-src/hashes.c @ 9967:dc9bb31cbffe

util.hashes: Rename PBKDF2 function It's not SCRAM-specific
author Kim Alvefur <zash@zash.se>
date Sun, 13 Jan 2019 13:57:18 +0100
parent 9966:9f1c5ae8d70b
child 9968:d536796a305f
comparison
equal deleted inserted replaced
9966:9f1c5ae8d70b 9967:dc9bb31cbffe
97 MAKE_HMAC_FUNCTION(Lhmac_sha1, EVP_sha1, SHA_DIGEST_LENGTH, SHA_CTX) 97 MAKE_HMAC_FUNCTION(Lhmac_sha1, EVP_sha1, SHA_DIGEST_LENGTH, SHA_CTX)
98 MAKE_HMAC_FUNCTION(Lhmac_sha256, EVP_sha256, SHA256_DIGEST_LENGTH, SHA256_CTX) 98 MAKE_HMAC_FUNCTION(Lhmac_sha256, EVP_sha256, SHA256_DIGEST_LENGTH, SHA256_CTX)
99 MAKE_HMAC_FUNCTION(Lhmac_sha512, EVP_sha512, SHA512_DIGEST_LENGTH, SHA512_CTX) 99 MAKE_HMAC_FUNCTION(Lhmac_sha512, EVP_sha512, SHA512_DIGEST_LENGTH, SHA512_CTX)
100 MAKE_HMAC_FUNCTION(Lhmac_md5, EVP_md5, MD5_DIGEST_LENGTH, MD5_CTX) 100 MAKE_HMAC_FUNCTION(Lhmac_md5, EVP_md5, MD5_DIGEST_LENGTH, MD5_CTX)
101 101
102 static int LscramHi(lua_State *L) { 102 static int Lpbkdf2_sha1(lua_State *L) {
103 unsigned char out[SHA_DIGEST_LENGTH]; 103 unsigned char out[SHA_DIGEST_LENGTH];
104 104
105 size_t pass_len, salt_len; 105 size_t pass_len, salt_len;
106 const char *pass = luaL_checklstring(L, 1, &pass_len); 106 const char *pass = luaL_checklstring(L, 1, &pass_len);
107 const unsigned char *salt = (unsigned char *)luaL_checklstring(L, 2, &salt_len); 107 const unsigned char *salt = (unsigned char *)luaL_checklstring(L, 2, &salt_len);
125 { "md5", Lmd5 }, 125 { "md5", Lmd5 },
126 { "hmac_sha1", Lhmac_sha1 }, 126 { "hmac_sha1", Lhmac_sha1 },
127 { "hmac_sha256", Lhmac_sha256 }, 127 { "hmac_sha256", Lhmac_sha256 },
128 { "hmac_sha512", Lhmac_sha512 }, 128 { "hmac_sha512", Lhmac_sha512 },
129 { "hmac_md5", Lhmac_md5 }, 129 { "hmac_md5", Lhmac_md5 },
130 { "scram_Hi_sha1", LscramHi }, 130 { "scram_Hi_sha1", Lpbkdf2_sha1 }, /* COMPAT */
131 { "pbkdf2_hmac_sha1", Lpbkdf2_sha1 },
131 { NULL, NULL } 132 { NULL, NULL }
132 }; 133 };
133 134
134 LUALIB_API int luaopen_util_hashes(lua_State *L) { 135 LUALIB_API int luaopen_util_hashes(lua_State *L) {
135 #if (LUA_VERSION_NUM > 501) 136 #if (LUA_VERSION_NUM > 501)