Skip to content

Commit

Permalink
Fixed: Import will always convert generated passwords to stored when …
Browse files Browse the repository at this point in the history
…importing with passwords locked
  • Loading branch information
palant committed Jun 5, 2019
1 parent b2c6c3c commit 3bc3dbb
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/importers/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ function decryptThenImport(data, masterPass, setSite, setPassword)
]);
}).catch(error =>
{
if (error == "master_password_required")
throw error;

console.error(error);
throw "wrong_master_password";
}).then(([decryptionKey, hmacSecret]) =>
Expand Down
31 changes: 30 additions & 1 deletion test/passwords.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ exports.setUp = function(callback)
origConsoleError = console.error;
console.error = function(...args)
{
if (!String(args[0]).includes("Syntax error"))
if (!String(args[0]).includes("Syntax error") && !String(args[0]).includes("encrypted with wrong algorithm"))
origConsoleError.call(this, ...args);
};

Expand Down Expand Up @@ -1534,6 +1534,35 @@ exports.testImportErrors = function(test)
{
test.ok(false, "Imported data without salt");
}).catch(expectedValue.bind(test, "unknown_data_format")).then(() =>
{
return passwords.importPasswordData(JSON.stringify({
application: "pfp",
format: 3,
data: {
salt: "asdf",
"hmac-secret": "fdsa"
}
}));
}).then(() =>
{
test.ok(false, "Imported data without knowing master password");
}).catch(expectedValue.bind(test, "master_password_required")).then(() =>
{
return masterPassword.changePassword(dummyMaster);
}).then(() =>
{
return passwords.importPasswordData(JSON.stringify({
application: "pfp",
format: 3,
data: {
salt: "asdf",
"hmac-secret": "fakeiv_" + btoa("AES-GCM!fakekey!fakeiv!\"fdsa\"")
}
}));
}).then(() =>
{
test.ok(false, "Imported data not matching master password");
}).catch(expectedValue.bind(test, "wrong_master_password")).then(() =>
{
return passwords.importPasswordData("url,username,password\n");
}).then(() =>
Expand Down

0 comments on commit 3bc3dbb

Please sign in to comment.