aes.js: improved error handling
This commit is contained in:
parent
1f141ccbad
commit
1d9f304830
@ -77,9 +77,18 @@ async function encrypt() {
|
|||||||
async function decrypt() {
|
async function decrypt() {
|
||||||
let msgEncoded = decMsg.value;
|
let msgEncoded = decMsg.value;
|
||||||
|
|
||||||
let ciphertext = new b64ToBuf(msgEncoded.ciphertext);
|
let ciphertext, iv, salt;
|
||||||
let iv = new Uint8Array(b64ToBuf(msgEncoded.iv));
|
try {
|
||||||
let salt = new Uint8Array(b64ToBuf(msgEncoded.salt));
|
ciphertext = new b64ToBuf(msgEncoded.ciphertext);
|
||||||
|
iv = new Uint8Array(b64ToBuf(msgEncoded.iv));
|
||||||
|
salt = new Uint8Array(b64ToBuf(msgEncoded.salt));
|
||||||
|
} catch (e) {
|
||||||
|
decMsg.alertBox("alert-error", "Invalid base64 value.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ciphertext === undefined || iv === undefined || salt === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let keyMaterial = await getKeyMaterial(decPass.value);
|
let keyMaterial = await getKeyMaterial(decPass.value);
|
||||||
let key = await getKey(keyMaterial, salt);
|
let key = await getKey(keyMaterial, salt);
|
||||||
|
Loading…
Reference in New Issue
Block a user