(name, length)
| 17 | const usages = ['sign', 'verify']; |
| 18 | |
| 19 | async function test(name, length) { |
| 20 | length ??= name === 'KMAC128' ? 128 : 256; |
| 21 | const key = await subtle.generateKey({ |
| 22 | name, |
| 23 | length, |
| 24 | }, true, usages); |
| 25 | |
| 26 | assert(key); |
| 27 | assert(isCryptoKey(key)); |
| 28 | |
| 29 | assert.strictEqual(key.type, 'secret'); |
| 30 | assert.strictEqual(key.toString(), '[object CryptoKey]'); |
| 31 | assert.strictEqual(key.extractable, true); |
| 32 | assert.deepStrictEqual(key.usages, usages); |
| 33 | assert.strictEqual(key.algorithm.name, name); |
| 34 | assert.strictEqual(key.algorithm.length, length); |
| 35 | assert.strictEqual(key.algorithm, key.algorithm); |
| 36 | assert.strictEqual(key.usages, key.usages); |
| 37 | |
| 38 | const raw = await subtle.exportKey('raw-secret', key); |
| 39 | assert.strictEqual(raw.byteLength, Math.ceil(length / 8)); |
| 40 | } |
| 41 | |
| 42 | const kTests = [ |
| 43 | ['KMAC128', 0], |
no test coverage detected
searching dependent graphs…