46 local otp = token:sub(1,8) |
46 local otp = token:sub(1,8) |
47 local nonce = token:sub(9) |
47 local nonce = token:sub(9) |
48 local signature = base64.decode(string.match(password, " (.+)")) |
48 local signature = base64.decode(string.match(password, " (.+)")) |
49 local jid = username.."@"..realm |
49 local jid = username.."@"..realm |
50 |
50 |
51 if totp:verify(otp, OTP_DEVIATION, luatz.gmtime(luatz.time())) then |
51 if totp:verify(otp, OTP_DEVIATION, luatz.time()) then |
52 log("debug", "The TOTP was verified"); |
52 log("debug", "The TOTP was verified"); |
53 local hmac_ctx = hmac.new(token_secret, DIGEST_TYPE) |
53 local hmac_ctx = hmac.new(token_secret, DIGEST_TYPE) |
54 if signature == hmac_ctx:final(otp..nonce..jid) then |
54 if signature == hmac_ctx:final(otp..nonce..jid) then |
55 log("debug", "The key was verified"); |
55 log("debug", "The key was verified"); |
56 if check_nonce(jid, otp, nonce) then |
56 if check_nonce(jid, otp, nonce) then |