mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 15:09:33 +01:00
user: use fixed salt to derive key for encryption
This commit is contained in:
@@ -23,7 +23,7 @@ export default class Storage {
|
|||||||
decrypt(password, cipher) {
|
decrypt(password, cipher) {
|
||||||
return this.storage.decrypt(password, cipher);
|
return this.storage.decrypt(password, cipher);
|
||||||
}
|
}
|
||||||
deriveKey(password) {
|
deriveKey(password, salt) {
|
||||||
return this.storage.deriveKey(password, null, true);
|
return this.storage.deriveKey(password, salt, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export default class User {
|
|||||||
|
|
||||||
async key() {
|
async key() {
|
||||||
const user = await this.get();
|
const user = await this.get();
|
||||||
return user.key;
|
return { key: user.key, salt: user.salt };
|
||||||
}
|
}
|
||||||
|
|
||||||
async set(user) {
|
async set(user) {
|
||||||
@@ -31,7 +31,7 @@ export default class User {
|
|||||||
password,
|
password,
|
||||||
grant_type: "password",
|
grant_type: "password",
|
||||||
});
|
});
|
||||||
const key = await this.context.deriveKey(password);
|
const key = await this.context.deriveKey(password, response.payload.salt);
|
||||||
let user = userFromResponse(response, key);
|
let user = userFromResponse(response, key);
|
||||||
await this.context.write("user", user);
|
await this.context.write("user", user);
|
||||||
}
|
}
|
||||||
@@ -69,7 +69,7 @@ export default class User {
|
|||||||
password,
|
password,
|
||||||
email,
|
email,
|
||||||
});
|
});
|
||||||
const key = await this.context.deriveKey(password);
|
const key = await this.context.deriveKey(password, response.payload.salt);
|
||||||
let user = userFromResponse(response, key);
|
let user = userFromResponse(response, key);
|
||||||
await this.context.write("user", user);
|
await this.context.write("user", user);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user