1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-15 23:00:36 +02:00

All: Various improvements to E2EE

This commit is contained in:
Laurent Cozic
2017-12-26 11:38:53 +01:00
parent bef7c38724
commit 08d2655f13
16 changed files with 129 additions and 59 deletions

View File

@ -48,6 +48,7 @@ class EncryptionService {
masterKey = await MasterKey.save(masterKey);
await this.enableEncryption(masterKey, password);
await this.loadMasterKeysFromSettings();
return masterKey;
}
async enableEncryption(masterKey, password = null) {
@ -220,6 +221,9 @@ class EncryptionService {
}
async encrypt(method, key, plainText) {
if (!method) throw new Error('Encryption method is required');
if (!key) throw new Error('Encryption key is required');
const sjcl = shim.sjclModule;
if (method === EncryptionService.METHOD_SJCL) {
@ -261,6 +265,9 @@ class EncryptionService {
}
async decrypt(method, key, cipherText) {
if (!method) throw new Error('Encryption method is required');
if (!key) throw new Error('Encryption key is required');
const sjcl = shim.sjclModule;
if (method === EncryptionService.METHOD_SJCL || method === EncryptionService.METHOD_SJCL_2) {