( baseKeys, size, saltSize, hash, iterations, keyType, usages)
| 538 | } |
| 539 | |
| 540 | async function testDeriveKeyBadHash( |
| 541 | baseKeys, |
| 542 | size, |
| 543 | saltSize, |
| 544 | hash, |
| 545 | iterations, |
| 546 | keyType, |
| 547 | usages) { |
| 548 | const salt = Buffer.from(kSalts[saltSize], 'hex'); |
| 549 | const algorithm = { name: 'PBKDF2', salt, iterations }; |
| 550 | |
| 551 | return Promise.all([ |
| 552 | assert.rejects( |
| 553 | subtle.deriveKey( |
| 554 | { |
| 555 | ...algorithm, |
| 556 | hash: hash.substring(0, 3) + hash.substring(4), |
| 557 | }, |
| 558 | baseKeys[size], |
| 559 | keyType, |
| 560 | true, |
| 561 | usages), |
| 562 | { name: 'NotSupportedError' }), |
| 563 | assert.rejects( |
| 564 | subtle.deriveKey( |
| 565 | { |
| 566 | ...algorithm, |
| 567 | hash: 'HKDF', |
| 568 | }, |
| 569 | baseKeys[size], |
| 570 | keyType, |
| 571 | true, |
| 572 | usages), |
| 573 | { name: 'NotSupportedError' }), |
| 574 | ]); |
| 575 | } |
| 576 | |
| 577 | async function testDeriveKeyBadUsage( |
| 578 | noKey, |
no test coverage detected