all repos — cgit @ c3b5b5f648d953307672a4b30e9222787668f708

a hyperfast web frontend for git written in c

auth-filters: do not use HMAC-SHA1

Though SHA1 is broken, HMAC-SHA1 is still fine. But let's not push our
luck; SHA256 is more sensible anyway.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Jason A. Donenfeld Jason@zx2c4.com
Sat, 14 Jul 2018 03:32:00 +0200
commit

c3b5b5f648d953307672a4b30e9222787668f708

parent

c132ef2462b3c5223c77eb68fa372edde85cfb6b

2 files changed, 4 insertions(+), 4 deletions(-)

jump to
M filters/gentoo-ldap-authentication.luafilters/gentoo-ldap-authentication.lua

@@ -271,7 +271,7 @@ return nil

end -- Lua hashes strings, so these comparisons are time invariant. - if hmac ~= crypto.hmac.digest("sha1", field .. "|" .. value .. "|" .. tostring(expiration) .. "|" .. salt, secret) then + if hmac ~= crypto.hmac.digest("sha256", field .. "|" .. value .. "|" .. tostring(expiration) .. "|" .. salt, secret) then return nil end

@@ -296,7 +296,7 @@ local salt = crypto.hex(crypto.rand.bytes(16))

value = url_encode(value) field = url_encode(field) authstr = field .. "|" .. value .. "|" .. tostring(expiration) .. "|" .. salt - authstr = authstr .. "|" .. crypto.hmac.digest("sha1", authstr, secret) + authstr = authstr .. "|" .. crypto.hmac.digest("sha256", authstr, secret) return authstr end
M filters/simple-authentication.luafilters/simple-authentication.lua

@@ -231,7 +231,7 @@ return nil

end -- Lua hashes strings, so these comparisons are time invariant. - if hmac ~= crypto.hmac.digest("sha1", field .. "|" .. value .. "|" .. tostring(expiration) .. "|" .. salt, secret) then + if hmac ~= crypto.hmac.digest("sha256", field .. "|" .. value .. "|" .. tostring(expiration) .. "|" .. salt, secret) then return nil end

@@ -256,7 +256,7 @@ local salt = crypto.hex(crypto.rand.bytes(16))

value = url_encode(value) field = url_encode(field) authstr = field .. "|" .. value .. "|" .. tostring(expiration) .. "|" .. salt - authstr = authstr .. "|" .. crypto.hmac.digest("sha1", authstr, secret) + authstr = authstr .. "|" .. crypto.hmac.digest("sha256", authstr, secret) return authstr end