3 ms·
I think you both raise valid points. This was an interesting thing to look at to see get a quick idea of how TOTP works. On the flip side, though, if this we
by anamexis 7y ago
I think you both raise valid points.
This was an interesting thing to look at to see get a quick idea of how TOTP works.
On the flip side, though, if this we had this hypothetical implementation:
import totp
if __name__ == '__main__':
totp.generate()
Well, we probably wouldn't be here discussing it.
- PeterisP 7y agoWell, the key part essentially is just like that, it's the single line mac = hmac.new(secret_bytes, counter_bytes, digest).digest() and everything else is just converting data to/from the proper format for this function.
- anamexis 7y agoWell sure, but given that TOTP is itself just formatted HMAC, that "everything else" of formatting is the essence of TOTP. Otherwise you probably wouldn't say you're implementing TOTP, you'd say you're implementing HMAC.