libs.hashes: Fix HMAC-SHA-1 blocksize to 64 (20 is output size)

Tue, 12 Jan 2016 14:06:20 +0100

author
Kim Alvefur <zash@zash.se>
date
Tue, 12 Jan 2016 14:06:20 +0100
changeset 398
b4ce2e524ed8
parent 397
918829f384d6
child 399
82ad158714e5

libs.hashes: Fix HMAC-SHA-1 blocksize to 64 (20 is output size)

libs/hashes.lua file | annotate | diff | comparison | revisions
--- a/libs/hashes.lua	Sat Jan 09 02:03:26 2016 +0100
+++ b/libs/hashes.lua	Tue Jan 12 14:06:20 2016 +0100
@@ -35,13 +35,13 @@
 	local t_concat = table.concat;
 
 	local function hmac_sha1(key, message, hexres)
-		if #key > 20 then
+		if #key > 64 then
 			key = sha1(key);
-		elseif #key < 20 then
-			key = key .. s_rep("\0", 20 - #key);
+		elseif #key < 64 then
+			key = key .. s_rep("\0", 64 - #key);
 		end
 		local o_key_pad, i_key_pad = {}, {}
-		for i = 1, 20 do
+		for i = 1, 64 do
 			local b = s_byte(key, i)
 			o_key_pad[i] = s_char(bxor(b, 0x5c));
 			i_key_pad[i] = s_char(bxor(b, 0x36));

mercurial