MCPcopy Create free account
hub / github.com/nodejs/node / testDeriveBitsBadLengths

Function testDeriveBitsBadLengths

test/pummel/test-webcrypto-derivebits-pbkdf2.js:424–458  ·  view source on GitHub ↗
(
  baseKeys,
  size,
  saltSize,
  hash,
  iterations)

Source from the content-addressed store, hash-verified

422}
423
424async function testDeriveBitsBadLengths(
425 baseKeys,
426 size,
427 saltSize,
428 hash,
429 iterations) {
430 const algorithm = {
431 name: 'PBKDF2',
432 salt: Buffer.from(kSalts[saltSize], 'hex'),
433 iterations,
434 hash,
435 };
436
437 return Promise.all([
438 assert.rejects(
439 subtle.deriveBits(algorithm, baseKeys[size], undefined), {
440 name: 'OperationError',
441 }),
442 assert.rejects(
443 subtle.deriveBits(algorithm, baseKeys[size], null), {
444 message: 'length cannot be null',
445 name: 'OperationError',
446 }),
447 assert.rejects(
448 subtle.deriveBits(algorithm, baseKeys[size]), {
449 message: 'length cannot be null',
450 name: 'OperationError',
451 }),
452 assert.rejects(
453 subtle.deriveBits(algorithm, baseKeys[size], 15), {
454 message: /length must be a multiple of 8/,
455 name: 'OperationError',
456 }),
457 ]);
458}
459
460async function testDeriveBitsBadHash(
461 baseKeys,

Calls 2

allMethod · 0.80
fromMethod · 0.45

Tested by

no test coverage detected