fix(keys): new passwords have at least 12 characters
The register can't check a password it never sees, and should its database leak, the verifier and the keys wrapped under the password fall to guessing at Argon2id's cost (the second reading's M8). Devices now refuse a new password shorter than 12 characters, counted as code points once normalised (halkyon_keys' checkNewPassword), at sign-up, a reset keeping the keys and a change alike, before anything is derived; the new password's field says so, and the refusal has its own text (en, de). Signing in takes any length, so a password set before keeps working. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
dab2c80524
commit
b33b99a50a
2 changed files with 216 additions and 29 deletions
|
|
@ -196,7 +196,7 @@ void main() {
|
|||
|
||||
await expectLater(
|
||||
passwords.signUp(
|
||||
await passwords.makePassword('another'),
|
||||
await passwords.makePassword('another password'),
|
||||
address: 'anna@example.org',
|
||||
request: request,
|
||||
code: gateway.codeFor('anna@example.org'),
|
||||
|
|
@ -368,7 +368,7 @@ void main() {
|
|||
passwords.resetPassword(
|
||||
address: 'anna@example.org',
|
||||
phrase: otherFakePhrase,
|
||||
newPassword: 'new',
|
||||
newPassword: 'a new password',
|
||||
totpCode: fakeTotpCode,
|
||||
),
|
||||
failsWith(PasswordProblem.phraseDoesNotFit),
|
||||
|
|
@ -377,7 +377,7 @@ void main() {
|
|||
passwords.resetPassword(
|
||||
address: 'anna@example.org',
|
||||
phrase: 'too short',
|
||||
newPassword: 'new',
|
||||
newPassword: 'a new password',
|
||||
totpCode: fakeTotpCode,
|
||||
),
|
||||
failsWith(PasswordProblem.notAPhrase),
|
||||
|
|
@ -386,11 +386,11 @@ void main() {
|
|||
final pending = await passwords.resetPassword(
|
||||
address: 'anna@example.org',
|
||||
phrase: fakePhrase,
|
||||
newPassword: 'new',
|
||||
newPassword: 'a new password',
|
||||
totpCode: fakeTotpCode,
|
||||
);
|
||||
|
||||
expect(anna.password, 'new');
|
||||
expect(anna.password, 'a new password');
|
||||
expect(pending.keys, crypto.keysNumbered(200));
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -92,6 +92,32 @@ void main() {
|
|||
);
|
||||
});
|
||||
|
||||
test(
|
||||
'a new password has at least 12 characters, for a new account, a '
|
||||
'reset keeping the keys and a change alike; signing in takes any',
|
||||
() async {
|
||||
Matcher tooShort() => throwsA(
|
||||
isA<PasswordFailed>().having(
|
||||
(failed) => failed.problem,
|
||||
'problem',
|
||||
PasswordProblem.passwordTooShort,
|
||||
),
|
||||
);
|
||||
await expectLater(crypto.newAccount('eleven char'), tooShort());
|
||||
await expectLater(
|
||||
crypto.keepingKeys('eleven char', account.keys, phrase: account.phrase),
|
||||
tooShort(),
|
||||
);
|
||||
await expectLater(
|
||||
crypto.newPassword('eleven char', account.keys),
|
||||
tooShort(),
|
||||
);
|
||||
// A password set before the minimum (none outside development) still
|
||||
// unlocks: unlocking checks no length.
|
||||
expect(await unlock('short'), isA<PasswordUnlock>());
|
||||
},
|
||||
);
|
||||
|
||||
test('a wrong password opens nothing; an empty one is refused', () async {
|
||||
await expectLater(
|
||||
open(
|
||||
|
|
|
|||
Loading…
Reference in a new issue