Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions python/stdlib/timing_attack.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import hmac


received_digest = (
b"\xe2\x93\x08\x19T8\xdc\x80\xef\x87\x90m\x1f\x9d\xf7\xf2"
b"\xf5\x10>\xdbf\xa2\xaf\xf7x\xcdX\xdf"
)

key = b"my-super-duper-special-secret-key"
password = b"pass"
digest = hmac.digest(key, password, digest="sha224")

if digest == received_digest:

Check failure on line 13 in python/stdlib/timing_attack.py

View check run for this annotation

Precaution / Precaution Unsubscribed

PY005: Observable Timing Discrepancy

Comparing digests with the '==' operator is vulnerable to timing attacks.
print("Authentication okay")