local char = string.char;
local byte = string.byte;
-module "scram"
+module "sasl.scram"
--=========================
--SASL SCRAM-SHA-1 according to RFC 5802
local function validate_username(username)
-- check for forbidden char sequences
for eq in username:gmatch("=(.?.?)") do
- if eq ~= "2D" and eq ~= "3D" then
+ if eq ~= "2C" and eq ~= "3D" then
return false
end
end
- -- replace =2D with , and =3D with =
- username = username:gsub("=2D", ",");
+ -- replace =2C with , and =3D with =
+ username = username:gsub("=2C", ",");
username = username:gsub("=3D", "=");
-- apply SASLprep
username = saslprep(username);
- return username;
+ return username and #username>0 and username;
end
local function hashprep(hashname)