65 end |
65 end |
66 |
66 |
67 -- hash algorithm independent Hi(PBKDF2) implementation |
67 -- hash algorithm independent Hi(PBKDF2) implementation |
68 function Hi(hmac, str, salt, i) |
68 function Hi(hmac, str, salt, i) |
69 local Ust = hmac(str, salt.."\0\0\0\1"); |
69 local Ust = hmac(str, salt.."\0\0\0\1"); |
70 local res = Ust; |
70 local res = Ust; |
71 for n=1,i-1 do |
71 for n=1,i-1 do |
72 local Und = hmac(str, Ust) |
72 local Und = hmac(str, Ust) |
73 res = binaryXOR(res, Und) |
73 res = binaryXOR(res, Und) |
74 Ust = Und |
74 Ust = Und |
75 end |
75 end |
78 |
78 |
79 local function validate_username(username) |
79 local function validate_username(username) |
80 -- check for forbidden char sequences |
80 -- check for forbidden char sequences |
81 for eq in username:gmatch("=(.?.?)") do |
81 for eq in username:gmatch("=(.?.?)") do |
82 if eq ~= "2D" and eq ~= "3D" then |
82 if eq ~= "2D" and eq ~= "3D" then |
83 return false |
83 return false |
84 end |
84 end |
85 end |
85 end |
86 |
86 |
87 -- replace =2D with , and =3D with = |
87 -- replace =2D with , and =3D with = |
88 username = username:gsub("=2D", ","); |
88 username = username:gsub("=2D", ","); |
89 username = username:gsub("=3D", "="); |
89 username = username:gsub("=3D", "="); |