Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New option to fully reset Secret Storage keys in boostrapSecretStorage #1202

Merged
merged 2 commits into from
Feb 10, 2020
Merged
Changes from 1 commit
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
7 changes: 5 additions & 2 deletions src/crypto/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ Crypto.prototype.createRecoveryKeyFromPassphrase = async function(password) {
* @param {bool} [opts.setupNewKeyBackup] If true, a new key backup version will be
* created and the private key stored in the new SSSS store. Ignored if keyBackupInfo
* is supplied.
* @param {bool} [opts.setupNewSecretStorage] Optional. Reset even if keys already exist.
* Returns:
* {Promise} A promise which resolves to key creation data for
* SecretStorage#addKey: an object with `passphrase` and/or `pubkey` fields.
Expand All @@ -371,6 +372,7 @@ Crypto.prototype.bootstrapSecretStorage = async function({
createSecretStorageKey = async () => { },
keyBackupInfo,
setupNewKeyBackup,
setupNewSecretStorage,
} = {}) {
logger.log("Bootstrapping Secure Secret Storage");

Expand All @@ -386,7 +388,7 @@ Crypto.prototype.bootstrapSecretStorage = async function({
const appCallbacks = Object.assign({}, this._baseApis._cryptoCallbacks);

try {
const inStorage =
const inStorage = !setupNewSecretStorage &&
await this._crossSigningInfo.isStoredInSecretStorage(this._secretStorage);
if (!this._crossSigningInfo.getId() || !inStorage) {
logger.log(
Expand All @@ -411,12 +413,13 @@ Crypto.prototype.bootstrapSecretStorage = async function({
);
}
} else {
if (setupNewSecretStorage) throw new Error("What the HELL");
turt2live marked this conversation as resolved.
Show resolved Hide resolved
logger.log("Cross signing keys are present in secret storage");
}

// Check if Secure Secret Storage has a default key. If we don't have one, create
// the default key (which will also be signed by the cross-signing master key).
if (!await this.hasSecretStorageKey()) {
if (setupNewSecretStorage || !await this.hasSecretStorageKey()) {
let newKeyId;
if (keyBackupInfo) {
logger.log("Secret storage default key not found, using key backup key");
Expand Down