@@ -64,11 +64,14 @@ async function hmacGenerateKey(algorithm, extractable, keyUsages) {
|
64 | 64 | 'SyntaxError'); |
65 | 65 | } |
66 | 66 | |
67 | | -const key = await generateKey('hmac', { length }).catch((err) => { |
| 67 | +let key; |
| 68 | +try { |
| 69 | +key = await generateKey('hmac', { length }); |
| 70 | +} catch (err) { |
68 | 71 | throw lazyDOMException( |
69 | 72 | 'The operation failed for an operation-specific reason', |
70 | 73 | { name: 'OperationError', cause: err }); |
71 | | -}); |
| 74 | +} |
72 | 75 | |
73 | 76 | return new InternalCryptoKey( |
74 | 77 | key, |
@@ -94,12 +97,15 @@ async function kmacGenerateKey(algorithm, extractable, keyUsages) {
|
94 | 97 | 'SyntaxError'); |
95 | 98 | } |
96 | 99 | |
97 | | -const keyData = await randomBytes(length / 8).catch((err) => { |
| 100 | +let keyData; |
| 101 | +try { |
| 102 | +keyData = await randomBytes(length / 8); |
| 103 | +} catch (err) { |
98 | 104 | throw lazyDOMException( |
99 | 105 | 'The operation failed for an operation-specific reason' + |
100 | 106 | `[${err.message}]`, |
101 | 107 | { name: 'OperationError', cause: err }); |
102 | | -}); |
| 108 | +} |
103 | 109 | |
104 | 110 | return new InternalCryptoKey( |
105 | 111 | createSecretKey(keyData), |
|