Software /
code /
verse
Changeset
398:b4ce2e524ed8
libs.hashes: Fix HMAC-SHA-1 blocksize to 64 (20 is output size)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 12 Jan 2016 14:06:20 +0100 |
parents | 397:918829f384d6 |
children | 399:82ad158714e5 |
files | libs/hashes.lua |
diffstat | 1 files changed, 4 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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));