aes.js: fix salt changing even when not used
This commit is contained in:
parent
f49f072fab
commit
76fd0c0a1c
@ -88,17 +88,9 @@ function getKey(keyMaterial, salt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
encButton.handle.addEventListener("click", async function() {
|
encButton.handle.addEventListener("click", async function() {
|
||||||
|
|
||||||
let salt;
|
|
||||||
if (encSalt.enabledFunc()) {
|
|
||||||
salt = encSalt.value;
|
|
||||||
} else {
|
|
||||||
salt = window.crypto.getRandomValues(new Uint8Array(16));
|
|
||||||
encSalt.value = salt;
|
|
||||||
}
|
|
||||||
|
|
||||||
let keyMaterial = await getKeyMaterial(encPass.value);
|
let keyMaterial = await getKeyMaterial(encPass.value);
|
||||||
let key;
|
let key;
|
||||||
|
let salt;
|
||||||
if (encManualKey.value) {
|
if (encManualKey.value) {
|
||||||
key = await window.crypto.subtle.importKey(
|
key = await window.crypto.subtle.importKey(
|
||||||
"raw",
|
"raw",
|
||||||
@ -108,6 +100,13 @@ encButton.handle.addEventListener("click", async function() {
|
|||||||
["encrypt", "decrypt"]
|
["encrypt", "decrypt"]
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
if (encSalt.enabledFunc()) {
|
||||||
|
salt = encSalt.value;
|
||||||
|
} else {
|
||||||
|
salt = window.crypto.getRandomValues(new Uint8Array(16));
|
||||||
|
encSalt.value = salt;
|
||||||
|
}
|
||||||
|
|
||||||
key = await getKey(keyMaterial, salt);
|
key = await getKey(keyMaterial, salt);
|
||||||
encKey.value = await window.crypto.subtle.exportKey("raw", key);
|
encKey.value = await window.crypto.subtle.exportKey("raw", key);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user