diff --git a/src/crypto/public_key/elliptic/ecdh_x.js b/src/crypto/public_key/elliptic/ecdh_x.js index 6a0f562b..43ce91b2 100644 --- a/src/crypto/public_key/elliptic/ecdh_x.js +++ b/src/crypto/public_key/elliptic/ecdh_x.js @@ -28,7 +28,15 @@ export async function generate(algo) { case enums.publicKey.x25519: try { const webCrypto = util.getWebCrypto(); - const webCryptoKey = await webCrypto.generateKey('X25519', true, ['deriveKey', 'deriveBits']); + const webCryptoKey = await webCrypto.generateKey('X25519', true, ['deriveKey', 'deriveBits']) + .catch(err => { + if (err.name === 'OperationError') { // Temporary (hopefully) fix for WebKit on Linux + const newErr = new Error('Unexpected key generation issue'); + newErr.name = 'NotSupportedError'; + throw newErr; + } + throw err; + }); const privateKey = await webCrypto.exportKey('jwk', webCryptoKey.privateKey); const publicKey = await webCrypto.exportKey('jwk', webCryptoKey.publicKey); @@ -196,7 +204,15 @@ export async function generateEphemeralEncryptionMaterial(algo, recipientA) { case enums.publicKey.x25519: try { const webCrypto = util.getWebCrypto(); - const ephemeralKeyPair = await webCrypto.generateKey('X25519', true, ['deriveKey', 'deriveBits']); + const ephemeralKeyPair = await webCrypto.generateKey('X25519', true, ['deriveKey', 'deriveBits']) + .catch(err => { + if (err.name === 'OperationError') { // Temporary (hopefully) fix for WebKit on Linux + const newErr = new Error('Unexpected key generation issue'); + newErr.name = 'NotSupportedError'; + throw newErr; + } + throw err; + }); const ephemeralPublicKeyJwt = await webCrypto.exportKey('jwk', ephemeralKeyPair.publicKey); const ephemeralPrivateKeyJwt = await webCrypto.exportKey('jwk', ephemeralKeyPair.privateKey); if (ephemeralPrivateKeyJwt.x !== ephemeralPublicKeyJwt.x) { // Weird issue with Webkit on Linux: https://bugs.webkit.org/show_bug.cgi?id=289693 diff --git a/src/crypto/public_key/elliptic/eddsa.js b/src/crypto/public_key/elliptic/eddsa.js index 79d68db4..86d9f17e 100644 --- a/src/crypto/public_key/elliptic/eddsa.js +++ b/src/crypto/public_key/elliptic/eddsa.js @@ -38,7 +38,15 @@ export async function generate(algo) { case enums.publicKey.ed25519: try { const webCrypto = util.getWebCrypto(); - const webCryptoKey = await webCrypto.generateKey('Ed25519', true, ['sign', 'verify']); + const webCryptoKey = await webCrypto.generateKey('Ed25519', true, ['sign', 'verify']) + .catch(err => { + if (err.name === 'OperationError') { // Temporary (hopefully) fix for WebKit on Linux + const newErr = new Error('Unexpected key generation issue'); + newErr.name = 'NotSupportedError'; + throw newErr; + } + throw err; + }); const privateKey = await webCrypto.exportKey('jwk', webCryptoKey.privateKey); const publicKey = await webCrypto.exportKey('jwk', webCryptoKey.publicKey); @@ -48,7 +56,7 @@ export async function generate(algo) { seed: b64ToUint8Array(privateKey.d, true) }; } catch (err) { - if (err.name !== 'NotSupportedError' && err.name !== 'OperationError') { // Temporary (hopefully) fix for WebKit on Linux + if (err.name !== 'NotSupportedError') { throw err; } const seed = getRandomBytes(getPayloadSize(algo));