mirror of
https://github.com/antonioribeiro/google2fa.git
synced 2026-04-25 16:15:49 +03:00
[GH-ISSUE #170] Google Authenticator and Authy App generating invalid codes #312
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/google2fa#312
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @tuckerww on GitHub (Jun 30, 2021).
Original GitHub issue: https://github.com/antonioribeiro/google2fa/issues/170
It appears that neither the Google Authenticator nor the Authy app generate valid codes, whereas other TOTP apps such as iPhone's built-in 2FA/password manager and the FreeOTP+ app on Android work fine.
My suspicion is that Google and/or Authy updated something in their codebases so that they're no longer compatible with the way the google2fa library generates either the secret or the valid auth-codes.
I tested both by scanning QR codes and by manually entering the secrets.
I also ensured that NTP is running on the server and that the date/time match up. Just in case I even tried passing an extremely large
$window(100) to$google2fa->verifyKey()but that doesn't seem to be the issue.Example Code:
PHP Version
@tuckerww commented on GitHub (Jun 30, 2021):
Aha! I have discovered the issue.
If you set the encryption algorithm to SHA512 then it doesn't work with the Google Authenticator App, but if you leave it as default then it works.
So in my above example I simply removed this line:
This is because
So it uses SHA1 in the app no matter what you specify.
https://github.com/google/google-authenticator/wiki/Key-Uri-Format#algorithm
Closing this.