Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions vault/static/src/backend/vault.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,23 @@ const vaultService = {
this.iterations
);

this.keys = {
publicKey: await vault_utils.load_public_key(params.public),
privateKey: await vault_utils.load_private_key(
let private_key = null;
try {
private_key = await vault_utils.load_private_key(
params.private,
pass,
params.iv
),
);
} catch (error) {
console.error(error);
throw new Error(
_t("The entered password is wrong. Please try again.")
);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original message should atleast be written to console.error(...)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed as requested.

}

this.keys = {
publicKey: await vault_utils.load_public_key(params.public),
privateKey: private_key,
};

this.time = new Date();
Expand Down
20 changes: 20 additions & 0 deletions vault/static/tests/vault_tests.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,26 @@ QUnit.module(
assert.deepEqual(master_key, tmp);
});

QUnit.test("vault: Test wrong password", async function (assert) {
assert.expect(1);

const key = await utils.generate_key_pair();
const iv = utils.generate_bytes(10);
const salt = utils.generate_bytes(10);

const wrapper = await utils.derive_key("test", salt, 4000);
const exported = await utils.export_private_key(
key.privateKey,
wrapper,
iv
);

const wrong = await utils.derive_key("wrong", salt, 4000);
await assert.rejects(
utils.load_private_key(exported, wrong, utils.toBase64(iv))
);
});

QUnit.test("vault: Test vault class", async function (assert) {
assert.expect(12);

Expand Down
Loading