4 ms·
Depending on the algorithm, one or two of the digits in the TOTP are counters to help the server figure out clock drift on the client device. This was especial
by slau 2y ago
Depending on the algorithm, one or two of the digits in the TOTP are counters to help the server figure out clock drift on the client device.
This was especially relevant when talking about hardware tokens that had relatively inaccurate clocks. In the RSA algorithm I seem to recall it was the second or third digit. Each clock tick was 2.5 seconds or something, so providing the last digit of the clock counter massively reduced the number of calculations the server had to do in case of a mismatch.
- fanf2 2y agoNo, TOTP implementations don’t compensate for clock drift, but they do compensate for moderate inaccuracy and races at the edges of the 30 second slots by typically allowing two or three codes around the current time +/- 1 minute or so.
- slau 2y agoWell, considering I was part of the implementation team of one of those hardware tokens, I'm sorry I'm going to have to disagree with you :). Please note that I'm not talking about RFC6238 / 4226. I'm talking about proprietary implementations for hardware tokens. We most definitely had drift management. One of the differentiating features to our competitors is that our algorithm had both a "click counter" (number of times the button was pressed) and a "clock counter". The least significant digit of both counters was included in the OTP that was generated. The authentication server used the last digit of both counters to figure out what values to use, and as you say, generated codes in both time directions in order to try and identify the values of the counters (well, the click counter obviously didn't go both directions). The server then stored the last matching click counter value and the drift of the clock value. It wasn't uncommon to have tokens that drifted by multiple minutes per month. This being said, you're right: the clock only incremented every 28 or 32 seconds, not 2.5 seconds as I incorrectly remembered.
- hnbad 2y agoWhen most people say TOTP they refer to the RFC kind, not proprietary OTP token generators. So it's less of a "depending on the algorithm they may do this" thing and more "some proprietary solutions do this instead".