It's amazing! Its default UX assumes you're basically air gapped. It works based on a minimal shared secret that's totally portable. Conceptually, it's as clear as "hash (your secret+(now()//30)), display hash as decimal, only show the last 6 (ish) digits".
What a triumph. I love TOTP.
This is meant as a sidelong critique on passkeys.
Without a means for transfering from one password management resource to another, passkeys create an increasingly significant friction against migrating one's account and artifically reduces competitive pressure on the vendor.
The phrase we use for that anti-consumer phenomenom is "vendor lock-in"
(If your employer has an effective and practical import and export technique for passkeys, I would be delighted to hear so and apologize for the suggestion otherwise. But as far as I've seen, that's not a thing.)
I'm not working specifically on passkeys lately so I don't know exactly what is already available to the public, I'll ask around
Without it passkeys are a sham. And since that was and is the case I don't see any conceivable future where passkeys benefit anyone but google/apple/ms. For the sake of the web it needs to die.
The simplicity of the implementation makes a test suite even more valuable, as it’s really quite hard to figure out if your implementation is correct.
https://shkspr.mobi/blog/2025/03/using-the-web-crypto-api-to...
However, reading the article this section caught my eye:
"As we now know, SHA-1 has some fundamental weaknesses. ... But the TOTP authors disagree and allow a for some different algorithms to be used."
With significant compute resources SHA1 can be broken for some use cases, but I don't think this is one of them. Is HN aware of any practical attacks against TOTP-SHA1?
But has anyone actually reaserached this? For all we know, using hma-sha256 in TOTP may actually make it less secure.
Passenger jets can fly with duct tape on their wings
>> Implementations MUST extract a 6-digit code at a minimum and possibly 7 and 8-digit code. Depending on security requirements, Digit = 7 or more SHOULD be considered in order to extract a longer HOTP value. RFC 4226 - 5.3. Generating an HOTP Value
Am I bad at reading specs or is there a maximum here? If I say „minimum 6, possibly 7 or 8“, that sounds like 9 and more isn’t allowed.
And I also often wonder about the OTP aspect, whether there is any protection in TOTP backends for the same TOTP being used twice.
Because of clock skew and latency, a service might choose to allow the previous and/or next code as being acceptable.
Rather pleasingly, 30,000,000 seconds is roughly 1 year.
So, assuming a uniform distribution of codes, you would expect to see a repeat after a year.
You also need to keep in mind the birthday paradox. Repeated codes will happen with high probability after around sqrt(1,000,000) = 1000 code emissions. https://en.wikipedia.org/wiki/Birthday_problem