(handle, algorithm)
| 43 | const kUsages = ['sign', 'verify']; |
| 44 | |
| 45 | function normalizeKeyLength(handle, algorithm) { |
| 46 | let length = handle.getSymmetricKeySize() * 8; |
| 47 | if (length === 0 && algorithm.name === 'HMAC') |
| 48 | throw lazyDOMException('Zero-length key is not supported', 'DataError'); |
| 49 | |
| 50 | if (algorithm.length !== undefined) { |
| 51 | const byteLength = numBitsToBytes(algorithm.length); |
| 52 | if (byteLength !== handle.getSymmetricKeySize()) |
| 53 | throw lazyDOMException('Invalid key length', 'DataError'); |
| 54 | |
| 55 | if (algorithm.length % 8 !== 0) { |
| 56 | handle = importSecretKey( |
| 57 | truncateToBitLength(algorithm.length, handle.export())); |
| 58 | } |
| 59 | |
| 60 | length = algorithm.length; |
| 61 | } |
| 62 | |
| 63 | return { handle, length }; |
| 64 | } |
| 65 | |
| 66 | function hmacGenerateKey(algorithm, extractable, usages) { |
| 67 | const { |
no test coverage detected
searching dependent graphs…