3 ms·
This could be a stupid question, why not just use the first few characters from the hash of the secret and the timestamp?
by Donckele 5y ago
This could be a stupid question, why not just use the first few characters from the hash of the secret and the timestamp?
- duskwuff 5y agoThat's pretty close to what they're doing, with some small changes (using HMAC, measuring the time in 30-second intervals, and generating a numeric code).
- Jtsummers 5y agoOne of the requirements for HOTP (which TOTP is based on) was that the code should be numeric for phone entry or similarly constrained entry mechanisms. > R4 - The value displayed on the token MUST be easily read and entered by the user: This requires the HOTP value to be of reasonable length. The HOTP value must be at least a 6-digit value. It is also desirable that the HOTP value be 'numeric only' so that it can be easily entered on restricted devices such as phones. See R4 at https://datatracker.ietf.org/doc/html/rfc4226 https://datatracker.ietf.org/doc/html/rfc4226 (split across pages 4 and 5).
- cbdumas 5y agoWith that scheme an attacker who gets access to a code (no matter how old) can then generate their own going forward. The hash function here means that even if someone obtains a code they can't generate other codes.
- TimWolla 5y agoOne reason might be that those characters would include letters. A digits-only code is much easier to type, e.g. using a restricted keypad, such as a phone.
- tshaddox 5y agoDon't all hashes start out as numbers anyway, before they get encoded as alphanumeric strings?
- jjeaff 5y agoThat's basically what they do. Most apps like Google authenticator use totp rather than hotp. The t stands for time, the h is hmac. Except they also use an algorithm to convert those characters to digits only. It's all described under the totp section.