Skip to content
Snippets Groups Projects
Commit 600e9a16 authored by sand's avatar sand
Browse files

use a constant-time comparison function to check user passwords

parent 4b349a40
No related branches found
No related tags found
No related merge requests found
import crypt
from werkzeug.security import safe_str_cmp
from authserv.oath import accept_totp
from authserv import protocol
def _check_main_password(userpw, password):
if crypt.crypt(password, userpw) == userpw:
if safe_str_cmp(crypt.crypt(password, userpw), userpw):
return protocol.OK
else:
return protocol.ERR_AUTHENTICATION_FAILURE
......@@ -12,7 +13,7 @@ def _check_main_password(userpw, password):
def _check_app_specific_password(asps, password):
for app_pw in asps:
if crypt.crypt(password, app_pw) == app_pw:
if safe_str_cmp(crypt.crypt(password, app_pw), app_pw):
return protocol.OK
return protocol.ERR_AUTHENTICATION_FAILURE
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment