mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-26 11:13:00 -03:00
using constant time string comparison for username/password, to prevent timing attacks. fixes #3
This commit is contained in:
parent
7ef02955a0
commit
a12dd0c4a9
1 changed files with 10 additions and 1 deletions
|
@ -17,7 +17,16 @@ auth_username = auth_password = filename = filehash = filesize = ''
|
||||||
|
|
||||||
def check_auth(username, password):
|
def check_auth(username, password):
|
||||||
global auth_username, auth_password
|
global auth_username, auth_password
|
||||||
return username == auth_username and password == auth_password
|
|
||||||
|
if len(username) != 16 or len(password) != 16:
|
||||||
|
return False
|
||||||
|
|
||||||
|
# constant time string comparison, to prevent timing attacks
|
||||||
|
valid = True
|
||||||
|
for i in range(16):
|
||||||
|
if username[i] != auth_username[i] or password[i] != auth_password[i]:
|
||||||
|
valid = False
|
||||||
|
return valid
|
||||||
|
|
||||||
def authenticate():
|
def authenticate():
|
||||||
return Response(
|
return Response(
|
||||||
|
|
Loading…
Add table
Reference in a new issue