crypto: validate the limit of PBKDF2 iterations · nodejs/node@f4665f1 · GitHub
Skip to content

Commit f4665f1

Browse files
panvaaduh95
authored andcommitted
crypto: validate the limit of PBKDF2 iterations
Reject iteration counts outside of OpenSSL supported range Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: #65704 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
1 parent 624abbe commit f4665f1

3 files changed

Lines changed: 32 additions & 0 deletions

File tree

‎lib/internal/crypto/webidl.js‎

Lines changed: 6 additions & 0 deletions

‎test/fixtures/webcrypto/supports-level-2.mjs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ export const vectors = {
124124
[true,
125125
{ name: 'PBKDF2', hash: 'SHA-256', salt: Buffer.alloc(0), iterations: 1 },
126126
{ name: 'HMAC', hash: 'SHA-256' }],
127+
[false,
128+
{ name: 'PBKDF2', hash: 'SHA-256', salt: Buffer.alloc(0), iterations: 2 ** 31 },
129+
{ name: 'AES-CBC', length: 128 }],
127130
[false,
128131
{ name: 'PBKDF2', hash: 'SHA-256', salt: Buffer.alloc(0), iterations: 1 },
129132
'HKDF'],
@@ -183,6 +186,7 @@ export const vectors = {
183186
[true, { name: 'PBKDF2', hash: 'SHA-256', salt: Buffer.alloc(0), iterations: 1 }, 8],
184187
[true, { name: 'PBKDF2', hash: 'SHA-256', salt: Buffer.alloc(0), iterations: 1 }, 0],
185188
[false, { name: 'PBKDF2', hash: 'SHA-256', salt: Buffer.alloc(0), iterations: 0 }, 8],
189+
[false, { name: 'PBKDF2', hash: 'SHA-256', salt: Buffer.alloc(0), iterations: 2 ** 31 }, 8],
186190
[false, { name: 'PBKDF2', hash: 'SHA-256', salt: Buffer.alloc(0), iterations: 1 }, null],
187191
[false, { name: 'PBKDF2', hash: 'SHA-256', salt: Buffer.alloc(0), iterations: 1 }, 7],
188192
[false, { name: 'PBKDF2', hash: 'Invalid', salt: Buffer.alloc(0), iterations: 1 }, 8],

‎test/parallel/test-webcrypto-derivebits.js‎

Lines changed: 22 additions & 0 deletions

0 commit comments

Comments
 (0)