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

Function setupBaseKeys

test/pummel/test-webcrypto-derivebits-pbkdf2.js:364–401  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

362};
363
364async function setupBaseKeys() {
365 const baseKeys = {};
366 const noBits = {};
367 const noKey = {};
368 let wrongKey = null;
369
370 await Promise.all(Object.keys(kPasswords).flatMap((size) => [
371 subtle.importKey(
372 'raw',
373 Buffer.from(kPasswords[size], 'hex'),
374 { name: 'PBKDF2' },
375 false,
376 ['deriveKey', 'deriveBits'])
377 .then((key) => baseKeys[size] = key),
378
379 subtle.importKey(
380 'raw',
381 Buffer.from(kPasswords[size], 'hex'),
382 { name: 'PBKDF2' },
383 false,
384 ['deriveBits'])
385 .then((key) => noKey[size] = key),
386
387 subtle.importKey(
388 'raw',
389 Buffer.from(kPasswords[size], 'hex'),
390 { name: 'PBKDF2' },
391 false,
392 ['deriveKey'])
393 .then((key) => noBits[size] = key),
394 ]).concat(subtle.generateKey(
395 { name: 'ECDH', namedCurve: 'P-521' },
396 false,
397 ['deriveKey', 'deriveBits'])
398 .then((key) => wrongKey = key.privateKey)));
399
400 return { baseKeys, noBits, noKey, wrongKey };
401}
402
403async function testDeriveBits(
404 baseKeys,

Calls 6

allMethod · 0.80
concatMethod · 0.80
flatMapMethod · 0.80
keysMethod · 0.65
thenMethod · 0.45
fromMethod · 0.45

Tested by

no test coverage detected