How an authenticator generates a login code
A six-digit login code changes every 30 seconds because time is cut into blocks, mixed with an account key, and reduced to digits. Aegis Authenticator 3.4.3 publishes that behavior in a GPL-3.0 release APK of about 6.9 MB, which makes it a clean authorized Android target. This page follows the REA queries, the decompiled calculation, and a browser clock checked against RFC 6238.
Adjustable clock
Same key, next time block, next code
The key is the public RFC 6238 test string, not an account seed. The demo runs the rule recovered from the release APK: 30-second blocks, HMAC-SHA1, six digits by default.
- 01
Time
59 s - 02
30-second block
1floor(59 / 30)30–59 seconds - 03
Six-digit code
287082
Without JavaScript, the figure shows the result at 59 seconds.
Ask for the rule, not a bypass
The question for the agent is narrow: find how this APK builds the six-digit code, explain why a new code appears every 30 seconds, and rebuild a small demo whose clock you can move. That is a packaging and cryptography-reading exercise on software you are allowed to analyze.
Use REA to inspect aegis-v3.4.3.apk. Find how it generates the six-digit login code, explain why it changes every 30 seconds, and rebuild a small demo where I can change the time.
Android analysis for this pass needs a full JDK 17 or newer (this inspection used JDK 21) selected with JAVA_HOME or PATH, plus the jadx helper jar named in the footnotes. Point REA at that jar and the APK you downloaded yourself:
REA_JADX_MCP_JAR="$PWD/jadx-headless-mcp-0.7.1-all.jar" \
npx -y [email protected] inspect-android-package \
./aegis-v3.4.3.apk --format json --full-output
Pin for this study
The commands on this page use [email protected] (npm latest on 2026-10-13, published 2026-10-11). Do not swap in @latest if you want the same tool list later. Node engines for that tarball are ^22.19.0 || ^24.11.0 || >=26.0.0.
| Piece | Pin used here |
|---|---|
| REA | [email protected] |
| JDK | 17+ required since 5.0.0; this pass used 21 |
| Android helper | jadx-headless-mcp 0.7.1, via REA_JADX_MCP_JAR |
| APK | Aegis Authenticator 3.4.3 official release, GPL-3.0, about 6.9 MB |
| Clock check | RFC 6238 appendix B SHA-1 vectors, self-hosted JSON |
- Download
aegis-v3.4.3.apkfrom the project’s own release. Recordsha256sumbefore you open it. This site does not mirror the APK. - Select JDK 21 (or another full JDK 17+) with
JAVA_HOME. - Pin
npx -y [email protected]and pointREA_JADX_MCP_JARat the helper jar you downloaded. - Ask for the six-digit rule, not for an account bypass.
- Rebuild the clock and check it against the RFC vectors before you trust one screenshot.
- Stop if the file is not a build you are allowed to inspect.
This pass is static. It does not use the 6.4.0 ADB device lane, and it does not open a live authenticator database. Device work on an emulator or handset you control is a separate guide: /docs/android-adb/. A licensed JEB MCP is also optional and separate: /docs/jeb/. Neither is required to read TotpInfo with the JADX helper.
Three classes out of 3,077
A package inventory names com.beemdevelopment.aegis, version 3.4.3, and 3,077 classes. Searching for Totp returns three hits. Only one of them owns the calculation.
inspect_android_package
{"path": "aegis-v3.4.3.apk"}
search_android_classes
{"path": "aegis-v3.4.3.apk", "query": "Totp"}
Package: com.beemdevelopment.aegis
Version: 3.4.3
Classes: 3,077
Three matches:
otp.TotpInfo
ui.views.TotpProgressBar
importers.TotpAuthenticatorImporter
TotpInfo is the generator. TotpProgressBar draws the countdown. TotpAuthenticatorImporter brings in accounts from another authenticator. TOTP means time-based one-time password: the same key and the same time block always produce the same code.
Connect the generator to the screen
Inspecting TotpInfo shows two getOtp overloads. Tracing callers of the base OtpInfo.getOtp lands on the list row and the copy action.
inspect_android_class
{"path": "aegis-v3.4.3.apk",
"class_name": "com.beemdevelopment.aegis.otp.TotpInfo"}
trace_android_references
{"path": "aegis-v3.4.3.apk",
"class_name": "com.beemdevelopment.aegis.otp.OtpInfo",
"method_name": "getOtp"}
TotpInfo methods:
getOtp() · overload 0
getOtp(long) · overload 1
OtpInfo.getOtp callers:
ui.views.EntryHolder.getOtp
ui.MainActivity.copyEntryCode
The timestamp overload is the one the UI uses. EntryHolder.getOtp calls TotpInfo.getOtp(timestamp) when it paints a row. MainActivity.copyEntryCode is the copy-to-clipboard path. Class names in the result drop the shared com.beemdevelopment.aegis prefix; the request paths above are shortened the same way for display.
Read the calculation
Constructors fix the defaults: period 30 seconds, algorithm SHA1, six digits. The timestamp method turns milliseconds into a block index and hands that block to the generator. Formatting keeps leading zeroes, so a code may start with 0.
// TotpInfo defaults and clock
setPeriod(30);
getOtp(System.currentTimeMillis() / 1000);
// OtpInfo default algorithm and digits
this(bArr, "SHA1", 6);
// Block passed to the generator
(long) Math.floor(j / ((double) this._period))
// generateOTP → getHash
byte[] hash = getHash(bArr, str, j);
// getHash: account key + encoded block
Mac mac = Mac.getInstance(str);
mac.init(secretKeySpec);
return mac.doFinal(bArrArray);
// OTP.toString, case 0
this._code % ((int) Math.pow(10.0d, i))
// Keep leading zeroes
while (sb.length() < i) {
sb.insert(0, "0");
}
A readable summary of the same methods:
seconds = current_time_ms / 1000
block = floor(seconds / 30)
hash = HMAC_SHA1(account_key, big_endian_8_bytes(block))
number = select_31_bits(hash)
code = pad_with_zeroes(number % 1_000_000, 6)
Seconds 30 through 59 all share block 1. At 60 seconds the block becomes 2 and the code changes, even though the key did not. A different account key at the same timestamp produces a different code. The excerpts above are several methods, wrapped for display. Aegis itself is GPL-3.0; the diagram and the browser clock on this page are new teaching material.
Inside the generator
In the release APK, generateOTP is placed on kotlin.ExceptionsKt. REA follows the call from TotpInfo and returns the body. The matching release source names the helper HOTP.
public static OTP generateOTP(byte[] bArr, String str,
int i, long j)
throws NoSuchAlgorithmException, InvalidKeyException {
byte[] hash = getHash(bArr, str, j);
int i2 = hash[hash.length - 1] & 15;
return new OTP(
(hash[i2 + 3] & 255)
| ((hash[i2] & 127) << 24)
| ((hash[i2 + 1] & 255) << 16)
| ((hash[i2 + 2] & 255) << 8), i, 0);
}
The last hash byte selects a window. Four bytes at that window become a positive 31-bit integer; formatting then reduces it to the requested digit count. The constructor’s last argument selects the formatting branch the compiler introduced. Compare that body with the matching tag in the Aegis repository when you want the original names.
Clock on this page
Move the clock above across a minute. The public test key is the ASCII string from RFC 6238 appendix B (12345678901234567890), not anyone’s account. At 59 seconds the block is 1 and the six-digit code is 287082. At 60 seconds the block is 2 and the code is 359152. Sliding inside one block does not change the code.
| Example time | Block | Six-digit code |
|---|---|---|
| 30 seconds | 1 | 287082 |
| 59 seconds | 1 | 287082 |
| 60 seconds | 2 | 359152 |
| 1,111,111,109 seconds | 37,037,036 | 081804 |
The 081804 row is the interesting padding case: the value is shorter than six digits until leading zeroes are restored. It also sits on a block boundary worth keeping in the local suite.
What was checked
Selected Java methods returned by REA were assembled into a small test program. Their output matched an independent reconstruction on 133 cases, including block boundaries and codes that begin with zero. The browser clock also matches the six published SHA-1 vectors in RFC 6238. Those vectors are eight digits; the button above checks both the eight-digit string and its last six digits. Reference rows live in test-vectors.json. The APK was inspected statically. The verification runs the extracted methods and this demo, not a logged-in Aegis account.
A useful next question, still inside the same authorized APK: what changes when an account asks for eight digits, or for a period other than 30 seconds? The defaults are in the constructors; the digit count and period are already parameters.
What this study does not claim
The six-digit strings above are outputs of the public RFC 6238 test key on a clock you can move. They are not codes from a real account. Sliding the control does not talk to Aegis, to a phone, or to an issuer. If a later rea-agents minor changes Evidence field names, keep this pin until you have read /docs/breaking/ — always-bump-minor can break consumers between 6.0 and 6.4.0.
Next step
Similar browser session records can become AgentEnv replay environments
This case is not a claim that it is a specific Hugging Face environment. When REA records an authorized browser session, Scale AgentEnv can expose replay as MCP tools. rea.run mirrors the catalog only — we do not host the RL runtime.
Environments catalog → What is AgentEnv + REA? HF collection ↗ Introducing AgentEnv
Compliance
Use the official release or another build you are allowed to inspect. Reconstructing TOTP on GPL software is interoperability study. Harvesting live account seeds from devices you do not own is not part of this case. This page does not attach ADB to a phone that stores authenticator secrets.
Takeaways
- Search first: three Totp classes, one generator.
- Period 30, HMAC-SHA1, six digits, zero-padded.
- Pin [email protected], JDK 21, jadx-headless-mcp 0.7.1, Aegis 3.4.3.
- Check the rebuild on RFC 6238 before trusting a single screenshot.
- Official GPL APK only. No ADB against a live vault.
Related on rea.run
More on-site cases