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

Function testDeriveKey

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

Source from the content-addressed store, hash-verified

508
509
510async function testDeriveKey(
511 baseKeys,
512 size,
513 saltSize,
514 hash,
515 iterations,
516 keyType,
517 usages) {
518 const algorithm = {
519 name: 'PBKDF2',
520 salt: Buffer.from(kSalts[saltSize], 'hex'),
521 hash,
522 iterations,
523 };
524
525 const key = await subtle.deriveKey(
526 algorithm,
527 baseKeys[size],
528 keyType,
529 true,
530 usages);
531
532 const bits = await subtle.exportKey('raw', key);
533
534 assert.strictEqual(
535 Buffer.from(bits).toString('hex'),
536 kDerivations[size][saltSize][hash][iterations]
537 .slice(0, keyType.length / 4));
538}
539
540async function testDeriveKeyBadHash(
541 baseKeys,

Calls 3

sliceMethod · 0.65
fromMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected