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

Function testDeriveBitsBadHash

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

Source from the content-addressed store, hash-verified

458}
459
460async function testDeriveBitsBadHash(
461 baseKeys,
462 size,
463 saltSize,
464 hash,
465 iterations) {
466 const salt = Buffer.from(kSalts[saltSize], 'hex');
467 const algorithm = { name: 'PBKDF2', salt, iterations };
468
469 return Promise.all([
470 assert.rejects(
471 subtle.deriveBits(
472 {
473 ...algorithm,
474 hash: hash.substring(0, 3) + hash.substring(4),
475 }, baseKeys[size], 256), {
476 name: 'NotSupportedError',
477 }),
478 assert.rejects(
479 subtle.deriveBits(
480 {
481 ...algorithm,
482 hash: 'HKDF',
483 },
484 baseKeys[size], 256), {
485 name: 'NotSupportedError',
486 }),
487 ]);
488}
489
490async function testDeriveBitsBadUsage(
491 noBits,

Calls 2

allMethod · 0.80
fromMethod · 0.45

Tested by

no test coverage detected