News for hackers. Stuff that matters.
Re:How to Set Up Two-Factor Authentication for Login and Sudo by e12e on Monday May 16, 2016 @04:41AM (#11705030)
Ah, indeed. There's a seperate function for HOTP:

https://github.com/google/google-authenticator/blob/3fb90bda...

And of course the switch statement that handles the core logic starts by checking scratch codes, and if that doesn't work, proceeds to check TOTP/HOTP:

https://github.com/google/google-authenticator/blob/3fb90bda...

I'm not a big fan of this style:

https://github.com/google/google-authenticator/blob/3fb90bda...

But at least there's a comment documenting the magic return code (#DEFINE VALID_SCRATCH_CODE = 0, or an enum, or basically anything else, anyone?):

/* Checks for possible use of scratch codes. Returns -1 on error, 0 on success, * and 1, if no scratch code had been entered, and subsequent tests should be * applied. */

There are no comments on this comment yet.