(no title)
fxj | 1 month ago
import base64
import hmac
import struct
import time
def totp(key, time_step=30, digits=6, digest='sha1'):
key = base64.b32decode(key.upper() + '=' \* ((8 - len(key)) % 8))
counter = struct.pack('>Q', int(time.time() / time_step))
mac = hmac.new(key, counter, digest).digest()
offset = mac[-1] & 0x0f
binary = struct.unpack('>L', mac[offset:offset+4])[0] & 0x7fffffff
return str(binary)[-digits:].zfill(digits)
https://dev.to/yusadolat/understanding-totp-what-really-happ...
elderlybanana|1 month ago
crote|1 month ago
As I already mentioned, the fact that people often use it wrong undermines its security, but that doesn't change the intended outcome.
gruez|1 month ago
That's at best a retcon, given given that the RFC was first published in 2008
>You are also supposed to immediately destroy the QR code after importing it.
Most TOTP apps support backups/restores, which defeats this.
alt227|1 month ago
Ferret7446|1 month ago
ACCount37|1 month ago
If I managed to intercept a login, a password and a TOTP key from a login session, I can't use them to log in. Simply because TOTP expires too quickly.
That's the attack surface TOTP covers - it makes stealing credentials slightly less trivial by making one of the credentials ephemeral.
susam|1 month ago
az09mugen|1 month ago