| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9a4bbdc commit bb051c5
8 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -245,12 +245,15 @@ async function aesGenerateKey(algorithm, extractable, keyUsages) { | |||
| 245 | 245 | 'SyntaxError'); | |
| 246 | 246 | } | |
| 247 | 247 | ||
| 248 | - const key = await generateKey('aes', { length }).catch((err) => { | ||
| 248 | + let key; | ||
| 249 | + try { | ||
| 250 | + key = await generateKey('aes', { length }); | ||
| 251 | + } catch (err) { | ||
| 249 | 252 | throw lazyDOMException( | |
| 250 | 253 | 'The operation failed for an operation-specific reason' + | |
| 251 | 254 | `[${err.message}]`, | |
| 252 | 255 | { name: 'OperationError', cause: err }); | |
| 253 | - }); | ||
| 256 | + } | ||
| 254 | 257 | ||
| 255 | 258 | return new InternalCryptoKey( | |
| 256 | 259 | key, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -149,11 +149,14 @@ async function cfrgGenerateKey(algorithm, extractable, keyUsages) { | |||
| 149 | 149 | break; | |
| 150 | 150 | } | |
| 151 | 151 | ||
| 152 | - const keyPair = await generateKeyPair(genKeyType).catch((err) => { | ||
| 152 | + let keyPair; | ||
| 153 | + try { | ||
| 154 | + keyPair = await generateKeyPair(genKeyType); | ||
| 155 | + } catch (err) { | ||
| 153 | 156 | throw lazyDOMException( | |
| 154 | 157 | 'The operation failed for an operation-specific reason', | |
| 155 | 158 | { name: 'OperationError', cause: err }); | |
| 156 | - }); | ||
| 159 | + } | ||
| 157 | 160 | ||
| 158 | 161 | let publicUsages; | |
| 159 | 162 | let privateUsages; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -91,12 +91,15 @@ async function c20pGenerateKey(algorithm, extractable, keyUsages) { | |||
| 91 | 91 | 'SyntaxError'); | |
| 92 | 92 | } | |
| 93 | 93 | ||
| 94 | - const keyData = await randomBytes(32).catch((err) => { | ||
| 94 | + let keyData; | ||
| 95 | + try { | ||
| 96 | + keyData = await randomBytes(32); | ||
| 97 | + } catch (err) { | ||
| 95 | 98 | throw lazyDOMException( | |
| 96 | 99 | 'The operation failed for an operation-specific reason' + | |
| 97 | 100 | `[${err.message}]`, | |
| 98 | 101 | { name: 'OperationError', cause: err }); | |
| 99 | - }); | ||
| 102 | + } | ||
| 100 | 103 | ||
| 101 | 104 | return new InternalCryptoKey( | |
| 102 | 105 | createSecretKey(keyData), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -97,11 +97,14 @@ async function ecGenerateKey(algorithm, extractable, keyUsages) { | |||
| 97 | 97 | // Fall through | |
| 98 | 98 | } | |
| 99 | 99 | ||
| 100 | - const keypair = await generateKeyPair('ec', { namedCurve }).catch((err) => { | ||
| 100 | + let keyPair; | ||
| 101 | + try { | ||
| 102 | + keyPair = await generateKeyPair('ec', { namedCurve }); | ||
| 103 | + } catch(err) { | ||
| 101 | 104 | throw lazyDOMException( | |
| 102 | 105 | 'The operation failed for an operation-specific reason', | |
| 103 | 106 | { name: 'OperationError', cause: err }); | |
| 104 | - }); | ||
| 107 | + } | ||
| 105 | 108 | ||
| 106 | 109 | let publicUsages; | |
| 107 | 110 | let privateUsages; | |
@@ -120,14 +123,14 @@ async function ecGenerateKey(algorithm, extractable, keyUsages) { | |||
| 120 | 123 | ||
| 121 | 124 | const publicKey = | |
| 122 | 125 | new InternalCryptoKey( | |
| 123 | - keypair.publicKey, | ||
| 126 | + keyPair.publicKey, | ||
| 124 | 127 | keyAlgorithm, | |
| 125 | 128 | publicUsages, | |
| 126 | 129 | true); | |
| 127 | 130 | ||
| 128 | 131 | const privateKey = | |
| 129 | 132 | new InternalCryptoKey( | |
| 130 | - keypair.privateKey, | ||
| 133 | + keyPair.privateKey, | ||
| 131 | 134 | keyAlgorithm, | |
| 132 | 135 | privateUsages, | |
| 133 | 136 | extractable); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -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), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -88,11 +88,14 @@ async function mlDsaGenerateKey(algorithm, extractable, keyUsages) { | |||
| 88 | 88 | 'SyntaxError'); | |
| 89 | 89 | } | |
| 90 | 90 | ||
| 91 | - const keyPair = await generateKeyPair(name.toLowerCase()).catch((err) => { | ||
| 91 | + let keyPair; | ||
| 92 | + try { | ||
| 93 | + keyPair = await generateKeyPair(name.toLowerCase()); | ||
| 94 | + } catch (err) { | ||
| 92 | 95 | throw lazyDOMException( | |
| 93 | 96 | 'The operation failed for an operation-specific reason', | |
| 94 | 97 | { name: 'OperationError', cause: err }); | |
| 95 | - }); | ||
| 98 | + } | ||
| 96 | 99 | ||
| 97 | 100 | const publicUsages = getUsagesUnion(usageSet, 'verify'); | |
| 98 | 101 | const privateUsages = getUsagesUnion(usageSet, 'sign'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -59,11 +59,14 @@ async function mlKemGenerateKey(algorithm, extractable, keyUsages) { | |||
| 59 | 59 | 'SyntaxError'); | |
| 60 | 60 | } | |
| 61 | 61 | ||
| 62 | - const keyPair = await generateKeyPair(name.toLowerCase()).catch((err) => { | ||
| 62 | + let keyPair; | ||
| 63 | + try { | ||
| 64 | + keyPair = await generateKeyPair(name.toLowerCase()); | ||
| 65 | + } catch(err) { | ||
| 63 | 66 | throw lazyDOMException( | |
| 64 | 67 | 'The operation failed for an operation-specific reason', | |
| 65 | 68 | { name: 'OperationError', cause: err }); | |
| 66 | - }); | ||
| 69 | + } | ||
| 67 | 70 | ||
| 68 | 71 | const publicUsages = getUsagesUnion(usageSet, 'encapsulateBits', 'encapsulateKey'); | |
| 69 | 72 | const privateUsages = getUsagesUnion(usageSet, 'decapsulateBits', 'decapsulateKey'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -150,14 +150,17 @@ async function rsaKeyGenerate( | |||
| 150 | 150 | } | |
| 151 | 151 | } | |
| 152 | 152 | ||
| 153 | - const keypair = await generateKeyPair('rsa', { | ||
| 154 | - modulusLength, | ||
| 155 | - publicExponent: publicExponentConverted, | ||
| 156 | - }).catch((err) => { | ||
| 153 | + let keyPair; | ||
| 154 | + try { | ||
| 155 | + keyPair = await generateKeyPair('rsa', { | ||
| 156 | + modulusLength, | ||
| 157 | + publicExponent: publicExponentConverted, | ||
| 158 | + }); | ||
| 159 | + } catch (err) { | ||
| 157 | 160 | throw lazyDOMException( | |
| 158 | 161 | 'The operation failed for an operation-specific reason', | |
| 159 | 162 | { name: 'OperationError', cause: err }); | |
| 160 | - }); | ||
| 163 | + } | ||
| 161 | 164 | ||
| 162 | 165 | const keyAlgorithm = { | |
| 163 | 166 | name, | |
@@ -183,14 +186,14 @@ async function rsaKeyGenerate( | |||
| 183 | 186 | ||
| 184 | 187 | const publicKey = | |
| 185 | 188 | new InternalCryptoKey( | |
| 186 | - keypair.publicKey, | ||
| 189 | + keyPair.publicKey, | ||
| 187 | 190 | keyAlgorithm, | |
| 188 | 191 | publicUsages, | |
| 189 | 192 | true); | |
| 190 | 193 | ||
| 191 | 194 | const privateKey = | |
| 192 | 195 | new InternalCryptoKey( | |
| 193 | - keypair.privateKey, | ||
| 196 | + keyPair.privateKey, | ||
| 194 | 197 | keyAlgorithm, | |
| 195 | 198 | privateUsages, | |
| 196 | 199 | extractable); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments