Skip to content

Commit 1f0a368

Browse files
author
Will Bamberg
committed
Warn about not reusing IVs
1 parent 616e38f commit 1f0a368

File tree

3 files changed

+3
-0
lines changed

3 files changed

+3
-0
lines changed

web-crypto/encrypt-decrypt/aes-cbc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
*/
2424
async function encryptMessage(key) {
2525
let encoded = getMessageEncoding();
26+
// The iv must never be reused with a given key.
2627
iv = window.crypto.getRandomValues(new Uint8Array(16));
2728
ciphertext = await window.crypto.subtle.encrypt(
2829
{

web-crypto/encrypt-decrypt/aes-ctr.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
*/
2424
async function encryptMessage(key) {
2525
let encoded = getMessageEncoding();
26+
// The counter block value must never be reused with a given key.
2627
counter = window.crypto.getRandomValues(new Uint8Array(16)),
2728
ciphertext = await window.crypto.subtle.encrypt(
2829
{

web-crypto/encrypt-decrypt/aes-gcm.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
*/
2424
async function encryptMessage(key) {
2525
let encoded = getMessageEncoding();
26+
// The iv must never be reused with a given key.
2627
iv = window.crypto.getRandomValues(new Uint8Array(12));
2728
ciphertext = await window.crypto.subtle.encrypt(
2829
{

0 commit comments

Comments
 (0)