Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

random.expovariate() usage inside the check_user function #7

Open
theSyndical opened this issue Jan 28, 2022 · 0 comments
Open

random.expovariate() usage inside the check_user function #7

theSyndical opened this issue Jan 28, 2022 · 0 comments

Comments

@theSyndical
Copy link

theSyndical commented Jan 28, 2022

Raymond thanks for the amazing course!

i have a question regarding this snippet of code:

def check_user(user: User, password: str) -> bool:
hashpass, salt = user_info[user].hashed_password
target_hash_pass = hash_password(password, salt)[0]
sleep(random.expovariate(10))
return secrets.compare_digest(hashpass, target_hash_pass)

whats the point of a random sleep with exponential distribution ? to my knowledge it wont prevent timing attacks.
according to the documentation compare_digest is designed to prevent timing analysis so it already takes care of that for us.

thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant