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

Commit 51cb9f4

Browse files
panvanodejs-github-bot
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 2718330 commit 51cb9f4

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
@@ -122,6 +122,9 @@ export const vectors = {
122122
[true,
123123
{ name: 'PBKDF2', hash: 'SHA-256', salt: Buffer.alloc(0), iterations: 1 },
124124
{ name: 'HMAC', hash: 'SHA-256' }],
125+
[false,
126+
{ name: 'PBKDF2', hash: 'SHA-256', salt: Buffer.alloc(0), iterations: 2 ** 31 },
127+
{ name: 'AES-CBC', length: 128 }],
125128
[false,
126129
{ name: 'PBKDF2', hash: 'SHA-256', salt: Buffer.alloc(0), iterations: 1 },
127130
'HKDF'],
@@ -181,6 +184,7 @@ export const vectors = {
181184
[true, { name: 'PBKDF2', hash: 'SHA-256', salt: Buffer.alloc(0), iterations: 1 }, 8],
182185
[true, { name: 'PBKDF2', hash: 'SHA-256', salt: Buffer.alloc(0), iterations: 1 }, 0],
183186
[false, { name: 'PBKDF2', hash: 'SHA-256', salt: Buffer.alloc(0), iterations: 0 }, 8],
187+
[false, { name: 'PBKDF2', hash: 'SHA-256', salt: Buffer.alloc(0), iterations: 2 ** 31 }, 8],
184188
[false, { name: 'PBKDF2', hash: 'SHA-256', salt: Buffer.alloc(0), iterations: 1 }, null],
185189
[false, { name: 'PBKDF2', hash: 'SHA-256', salt: Buffer.alloc(0), iterations: 1 }, 7],
186190
[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)