diff options
Diffstat (limited to 'test/storage/StorageSupport.mc')
| -rw-r--r-- | test/storage/StorageSupport.mc | 21 |
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)); |
