aboutsummaryrefslogtreecommitdiff
path: root/test/storage/StorageSupport.mc
diff options
context:
space:
mode:
authorcirakg <cirakg@cirakg.xyz>2026-10-25 12:46:42 +0100
committercirakg <cirakg@cirakg.xyz>2026-10-25 12:46:42 +0100
commit096b5a4d17c85fa5f87db3e72364e9c3506d1e64 (patch)
tree9846544fe7d76d849df4a1ee2058f4847f674e7e /test/storage/StorageSupport.mc
parente0384274bbeab999279bdc35bdddbd8a3a451aeb (diff)
feat(pin): exactly 4 digits, entered on the 4th digit
The keypad has no OK key; the 4th digit submits, so a tap that also arrives as START can no longer submit a partial PIN (the likely cause of "Wrong PIN" before the code opened). PINs set by earlier versions still unlock and are then replaced by a 4-digit one. Opening an entry ignores a second request from the same tap. A Require PIN sent from the phone while the watch is locked now applies at the next PIN instead of waiting for Confirm all. The linter skips .claude. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'test/storage/StorageSupport.mc')
-rw-r--r--test/storage/StorageSupport.mc21
1 files changed, 19 insertions, 2 deletions
diff --git a/test/storage/StorageSupport.mc b/test/storage/StorageSupport.mc
index 51a0c7c..5f2ead3 100644
--- a/test/storage/StorageSupport.mc
+++ b/test/storage/StorageSupport.mc
@@ -143,8 +143,9 @@ class FakeTime extends TimeSource {
(:test)
module StorageFixtures {
- const PIN = "246810";
- const OTHER_PIN = "135799";
+ const PIN = "2468"; // KeyManager.PIN_DIGITS digits, like every new PIN
+ const OTHER_PIN = "1357";
+ const LEGACY_PIN = "246810"; // a 6-digit PIN from before the 4-digit rule
const ITERATIONS = 2000; // Kdf.MIN_ITERATIONS: the cheapest allowed
// A fake TOTP entry (the secret is the RFC 4226 test key, not a real one).
@@ -205,6 +206,22 @@ module StorageFixtures {
vault.finishSetPin(job);
}
+ // Store a wrap the way versions before the 4-digit rule did: any 4 to
+ // 10 digits and no PIN-length marker. The session stays locked.
+ function setLegacyPin(store as MemoryBackend, text as String) as Void {
+ var keyManager = new KeyManager(store);
+ var job = new PinJob(pin(text), new [KeyManager.SALT_BYTES]b, ITERATIONS);
+ Jobs.runToCompletion(job, Kdf.ITERATIONS_PER_STEP);
+ keyManager.storeWrap(job, keyManager.newMasterKey());
+ store.deleteValue(KeyManager.PIN_LENGTH_KEY);
+ }
+
+ // True when the store holds the 4-digit PIN marker.
+ function pinMarked(store as MemoryBackend) as Boolean {
+ var marker = store.getValue(KeyManager.PIN_LENGTH_KEY);
+ return marker instanceof Number && marker == KeyManager.PIN_DIGITS;
+ }
+
// One unlock attempt; true when the PIN was right.
function unlock(vault as Vault, text as String) as Boolean {
var job = vault.beginUnlock(pin(text));