| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a028805 commit 36bb8da
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -288,8 +288,11 @@ async function exportKeyRaw(key) { | |||
| 288 | 288 | case 'NODE-ED25519': | |
| 289 | 289 | // Fall through | |
| 290 | 290 | case 'NODE-ED448': | |
| 291 | - return lazyRequire('internal/crypto/ec') | ||
| 292 | - .ecExportKey(key, kWebCryptoKeyFormatRaw); | ||
| 291 | + if (key.type === 'public') { | ||
| 292 | + return lazyRequire('internal/crypto/ec') | ||
| 293 | + .ecExportKey(key, kWebCryptoKeyFormatRaw); | ||
| 294 | + } | ||
| 295 | + break; | ||
| 293 | 296 | case 'ECDSA': | |
| 294 | 297 | // Fall through | |
| 295 | 298 | case 'ECDH': | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -268,15 +268,12 @@ async function test2(namedCurve) { | |||
| 268 | 268 | true, ['verify']), | |
| 269 | 269 | ]); | |
| 270 | 270 | ||
| 271 | - const [ | ||
| 272 | - rawKey1, | ||
| 273 | - rawKey2, | ||
| 274 | - ] = await Promise.all([ | ||
| 275 | - subtle.exportKey('raw', privateKey), | ||
| 276 | - subtle.exportKey('raw', publicKey), | ||
| 277 | - ]); | ||
| 278 | - assert.deepStrictEqual(Buffer.from(rawKey1), vector.privateKey); | ||
| 279 | - assert.deepStrictEqual(Buffer.from(rawKey2), vector.publicKey); | ||
| 271 | + const rawPublicKey = await subtle.exportKey('raw', publicKey); | ||
| 272 | + assert.deepStrictEqual(Buffer.from(rawPublicKey), vector.publicKey); | ||
| 273 | + | ||
| 274 | + assert.rejects(subtle.exportKey('raw', privateKey), { | ||
| 275 | + message: new RegExp(`Unable to export a raw ${namedCurve} private key`) | ||
| 276 | + }).then(common.mustCall()); | ||
| 280 | 277 | ||
| 281 | 278 | const sig = await subtle.sign( | |
| 282 | 279 | { name: namedCurve }, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments