authenticator

Two Windows desktop builds of the Google Authenticator one-time passcode generator — one driven by the original BlackBerry sources, one by the original Android sources — packaged so their output can be compared side by side.

Language
Java
Stars
0
Last updated
License
Apache-2.0

From the README

Authenticator for Windows

Two Windows desktop builds of the Google Authenticator one-time passcode generator — one driven by the original BlackBerry sources, one by the original Android sources — packaged so their output can be compared side by side.

Developed by Abdul Manan — github.com/abdulmanan69

Licence

Edition Executable Passcode engine
BlackBerry core GoogleAuthenticatorBlackBerry.exe upstream/blackberry
Android core GoogleAuthenticatorAndroid.exe upstream/android

Both ship in one installer, share a single bundled Java runtime, and keep separate account vaults so neither can disturb the other.

Why two

The two Google implementations were written years apart, by different teams, on different crypto stacks — Bouncy Castle SHA-1 on BlackBerry, JCE HMACSHA1 on Android. Running both on the same secret is a direct check that each still produces RFC-correct codes, and a way to see the one place they genuinely differ (see Known difference below).

Install

Download GoogleAuthenticator-Setup.exe from Releases, and run it.

Per-user install — no administrator rights. Files go to %LOCALAPPDATA%\Programs\GoogleAuthenticator, two Start Menu shortcuts are created, and an entry appears under Apps & features. Remove from there, or with uninstall.exe in the install folder.

Java is not required; a trimmed runtime (java.base, java.desktop, java.logging, jdk.unsupported) is bundled.

Adding accounts

Scan QR image — pick a saved screenshot or photo of a setup QR code. Decoding uses ZXing, tries both binarizers and both polarities, and accepts either an otpauth:// link or a bare base-32 secret.

Three test images are in windows/samples/ — open the same one in both editions and the codes should match.

Add manually — type a name and a base-32 secret, or paste an otpauth:// link straight into the secret box. Choose TOTP or HOTP and, for HOTP, a starting counter. The secret is validated with that edition's own decoder, so a key the Android Base32String rejects will not silently pass in the BlackBerry build.

Verifying the two agree

cd windows
powershell -ExecutionPolicy Bypass -File build.ps1
powershell -ExecutionPolicy Bypass -File verify.ps1

verify.ps1 runs tools/CrossCheck.java and tools/QrCheck.java:

== RFC 4226 HOTP vectors ==
  c=0 rfc=755224 bb=755224 android=755224  PASS
  ... all 10 PASS
== live TOTP, both engines, same instant ==
  JBSWY3DPEHPK3PXP  bb=559222 android=559222  MATCH
== 4000 random secret/counter pairs ==
  checked=4000 differ=0
== countdown agreement ==
  bb=30s android=30s  AGREE
ALL CHECKS PASSED
QR ROUND-TRIP PASSED

Passcode logic is not mine

No passcode arithmetic was written for this port. Every file below is a byte-for-byte copy of its upstream original, which is committed alongside it so the two can be diffed.

BlackBerry — from upstream/blackberry/src: PasscodeGenerator.java, Base32String.java, Base32Legacy.java, and the 11 vendored org/bouncycastle/** files supplying SHA-1 and HMAC.

Android — from upstream/android/java: otp/PasscodeGenerator.java, otp/TotpCounter.java, otp/OtpSourceException.java, time/Clock.java, time/SystemWallClock.java, util/Base32String.java.

Two adapters were added, because the upstream call sites are platform-bound:

  • OtpCore.java — a lift of AuthenticatorScreen.computePin. That class binds net.rim.*.
  • AndroidOtpCore.java — reassembles OtpProvider.getCurrentCode, OtpProvider.computePin and AccountDb.getSigningOracle. Those read through Android SQLite and SharedPreferences. Its one deviation: a secret that fails to decode raises OtpSourceException rather than returning null and then throwing NullPointerException.

Both editions are 6-digit, SHA-1, 30-second TOTP.

Known difference

The BlackBerry PasscodeGenerator accepts a passCodeLength but hardcodes PIN_MODULO = 10^6, so a non-default length yields six real digits zero-padded to the requested width. The Android version indexes DIGITS_POWER[codeLength] and is correct. Both apps use 6 digits, so the two agree in practice; the BlackBerry bug is preserved, not patched, because the point of this repo is to run the original code unchanged.

Storage

Neither original storage layer is portable — BlackBerry used a signed PersistentStore, Android used SQLite behind the OS keystore. Each edition instead keeps an AES-256-GCM vault keyed by PBKDF2-HMAC-SHA256 (210,000 iterations) over a master password set on first run.

Edition Vault
BlackBerry core %APPDATA%\GoogleAuthenticator\vault.dat
Android core %APPDATA%\GoogleAuthenticatorAndroid\vault.dat

There is no password recovery. Uninstalling leaves both vaults in place.

Build

cd windows
powershell -ExecutionPolicy Bypass -File build.ps1

Needs JDK 21 (javac, jar, jlink, jpackage) and the in-box .NET Framework compiler at C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe. No WiX, Inno Setup or NSIS — the installer is a small C# WinForms program with the payload embedded as a resource.

Layout

windows/
  src/        both OTP cores (verbatim) + the shared Swing UI
  lib/        guava-27.1-android.jar, zxing-core-3.5.3.jar
  assets/     icon.png, icon.ico
  tools/      CrossCheck.java, QrCheck.java
  installer/  Setup.cs, Uninstaller.cs
  build.ps1   rebuild everything
  verify.ps1  compare the two editions
upstream/
  blackberry/ unmodified, from google/google-authenticator
  android/    unmodified, from google/google-authenticator-android

Licence

Apache 2.0 — see LICENSE and NOTICE. Passcode generation is Google code under the same licence; ZXing and Guava are Apache 2.0; the Bouncy Castle files vendored in the BlackBerry tree are MIT.