exceptions on decryption

This commit is contained in:
azivner 2018-08-27 21:58:02 +02:00
parent c79fb2cc12
commit 4721ddc6b3

View File

@ -37,10 +37,16 @@ function isProtectedSessionAvailable() {
function decryptNoteTitle(noteId, encryptedTitle) { function decryptNoteTitle(noteId, encryptedTitle) {
const dataKey = getDataKey(); const dataKey = getDataKey();
try {
const iv = dataEncryptionService.noteTitleIv(noteId); const iv = dataEncryptionService.noteTitleIv(noteId);
return dataEncryptionService.decryptString(dataKey, iv, encryptedTitle); return dataEncryptionService.decryptString(dataKey, iv, encryptedTitle);
} }
catch (e) {
e.message = `Cannot decrypt note title for noteId=${noteId}: ` + e.message;
throw e;
}
}
function decryptNote(note) { function decryptNote(note) {
const dataKey = getDataKey(); const dataKey = getDataKey();
@ -49,6 +55,7 @@ function decryptNote(note) {
return; return;
} }
try {
if (note.title) { if (note.title) {
note.title = dataEncryptionService.decryptString(dataKey, dataEncryptionService.noteTitleIv(note.noteId), note.title); note.title = dataEncryptionService.decryptString(dataKey, dataEncryptionService.noteTitleIv(note.noteId), note.title);
} }
@ -64,10 +71,13 @@ function decryptNote(note) {
} }
} }
} }
catch (e) {
e.message = `Cannot decrypt note for noteId=${note.noteId}: ` + e.message;
throw e;
}
}
function decryptNotes(notes) { function decryptNotes(notes) {
const dataKey = getDataKey();
for (const note of notes) { for (const note of notes) {
decryptNote(note); decryptNote(note);
} }