3 ms·
> I think you're just initializing a bunch of null bytes. You're right. From MDN: > The Uint8Array typed array represents an array of 8-bit unsigned integers.
by lioeters 7y ago
> I think you're just initializing a bunch of null bytes.
You're right. From MDN:
> The Uint8Array typed array represents an array of 8-bit unsigned integers. The contents are initialized to 0.
..And the function signature for crypto.subtle.encrypt() describes the iv parameter for the algorithm:
> iv - A BufferSource — the initialization vector. This must be unique for every encryption operation carried out with a given key.
> Put another way: never reuse an IV with the same key.
https://developer.mozilla.org/en-US/docs/Web/API/AesGcmParams https://developer.mozilla.org/en-US/docs/Web/API/AesGcmParam...
The code comment implies that the author knew the iv parameter should be unique - and yet passed an array of zeros every time.
- dchest 7y agonever reuse an IV with the same key Exactly, the key is always different.
- lioeters 7y agoThank you, I'd misunderstood the author's intention, my fault for not reading the article carefully. > In this case, we only encrypt the content once with the random key so we don’t need an iv and can leave it filled with 0.