From 8fffd3e2e1ec0c5f3517a779b42974a4c1beae27 Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Wed, 3 Mar 2021 00:13:26 +0100 Subject: [PATCH] feat: electron >=12.0.0 is now supported (and tested on ci) --- .github/workflows/test.yml | 44 +++++++++- README.md | 4 +- test/.electron.js | 4 + test/jwe/cookbook.test.mjs | 27 +++++-- test/jwe/smoke.test.mjs | 99 ++++++++++++++++------- test/jwk/jwk2key.test.mjs | 30 ++++--- test/jws/smoke.test.mjs | 22 +++-- test/unit/decrypt_key_management.test.mjs | 35 +++++--- test/unit/encrypt_key_management.test.mjs | 35 +++++--- test/util/generators.test.mjs | 60 ++++++++++---- 10 files changed, 260 insertions(+), 100 deletions(-) create mode 100644 test/.electron.js diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bae886562c..ec2c104ead 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -87,8 +87,6 @@ jobs: with: path: dist key: dist-${{ hashFiles('src/**/*.ts') }}-${{ hashFiles('tsconfig/*.json') }} - - run: npm install - working-directory: ./test - name: Test Node.js crypto run: npm run test - name: Test Node.js crypto w/ CryptoKey @@ -99,6 +97,48 @@ jobs: if: ${{ !startsWith(matrix.node-version, '14') && !startsWith(matrix.node-version, '12') }} - run: git reset HEAD --hard + test-electron: + needs: + - build + strategy: + matrix: + electron-version: + - 12.0.0 + - latest + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup node + uses: actions/setup-node@v2 + with: + node-version: 14 + check-latest: true + - name: Store node version variable + id: node + run: | + echo "::set-output name=version::$(node -v)" + - name: Cache node_modules + uses: actions/cache@v2 + id: node_modules + with: + path: node_modules + key: ${{ runner.os }}-node_modules-${{ hashFiles('package.json') }}-${{ steps.node.outputs.version }} + - name: Install dependencies + run: npx panva/npm-install-retry + if: ${{ steps.node_modules.outputs.cache-hit != 'true' }} + - name: Load cached dist + uses: actions/cache@v2 + id: dist + with: + path: dist + key: dist-${{ hashFiles('src/**/*.ts') }}-${{ hashFiles('tsconfig/*.json') }} + - name: Install Electron + run: npm install --global xvfb-maybe electron@${{ matrix.electron-version }} + - name: Test Electron crypto + run: xvfb-maybe electron ./test/.electron + - run: git reset HEAD --hard + browserstack: env: BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }} diff --git a/README.md b/README.md index 5d9ca64574..5b03fffa4a 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,7 @@ Legend: | Platform | supported versions | caveats | | -- | -- | -- | | Node.js | LTS ^12.19.0 || ^14.15.0 | | -| Electron | `process.version` must match
the Node.js supported versions. So 12+ | see [1] | +| Electron | ^12.0.0 | see [1] | | Deno | ✕ | needs [Web Cryptography API integration](https://github.com/denoland/deno/issues/1891) first | | React Native | ✕ | has no available and usable crypto runtime | | IE | ✕ | implements old version of the Web Cryptography API specification | @@ -129,7 +129,7 @@ Legend: 1 Due to its use of BoringSSL the following is not supported in Electron - A128KW, A192KW, A256KW, and all composite algorithms utilizing those - - secp256k1 EC curves + - secp256k1 EC curve - Ed448, X25519, and X448 OKP Sub Types 2 RSA1_5, OKP JWK Key Type, and secp256k1 EC curve is not supported in [Web Cryptography API][webcrypto]. diff --git a/test/.electron.js b/test/.electron.js new file mode 100644 index 0000000000..8ed525724d --- /dev/null +++ b/test/.electron.js @@ -0,0 +1,4 @@ +const { app } = require('electron'); + +const exit = () => app.exit(process.exitCode); +require('ava/lib/cli').run().then(exit, exit); diff --git a/test/jwe/cookbook.test.mjs b/test/jwe/cookbook.test.mjs index f40844d72c..7a28fb3113 100644 --- a/test/jwe/cookbook.test.mjs +++ b/test/jwe/cookbook.test.mjs @@ -173,6 +173,7 @@ Promise.all([ title: 'https://tools.ietf.org/html/rfc7520#section-5.1 - Key Encryption using RSA v1.5 and AES-HMAC-SHA2', webcrypto: false, + electron: true, reproducible: false, input: { plaintext: @@ -246,6 +247,7 @@ Promise.all([ title: 'https://tools.ietf.org/html/rfc7520#section-5.2 - Key Encryption using RSA-OAEP with AES-GCM', webcrypto: true, + electron: true, input: { plaintext: 'You can trust us to stick with you through thick and thin–to the bitter end. And you can trust us to keep any secret of yours–closer than you keep it yourself. But you cannot trust us to let you face trouble alone, and go off without a word. We are your friends, Frodo.', @@ -319,6 +321,7 @@ Promise.all([ title: 'https://tools.ietf.org/html/rfc7520#section-5.3 - Key Wrap using PBES2-AES-KeyWrap with AES-CBC-HMAC-SHA2', webcrypto: true, + electron: false, reproducible: true, input: { plaintext: @@ -375,6 +378,7 @@ Promise.all([ title: 'https://tools.ietf.org/html/rfc7520#section-5.4 - Key Agreement with Key Wrapping using ECDH-ES and AES-KeyWrap with AES-GCM', webcrypto: true, + electron: false, input: { plaintext: 'You can trust us to stick with you through thick and thin–to the bitter end. And you can trust us to keep any secret of yours–closer than you keep it yourself. But you cannot trust us to let you face trouble alone, and go off without a word. We are your friends, Frodo.', @@ -448,6 +452,7 @@ Promise.all([ title: 'https://tools.ietf.org/html/rfc7520#section-5.5 - Key Agreement using ECDH-ES with AES-CBC-HMAC-SHA2', webcrypto: true, + electron: true, input: { plaintext: 'You can trust us to stick with you through thick and thin–to the bitter end. And you can trust us to keep any secret of yours–closer than you keep it yourself. But you cannot trust us to let you face trouble alone, and go off without a word. We are your friends, Frodo.', @@ -515,6 +520,7 @@ Promise.all([ title: 'https://tools.ietf.org/html/rfc7520#section-5.6 - Direction Encryption using AES-GCM', webcrypto: true, + electron: true, reproducible: true, input: { plaintext: @@ -565,6 +571,7 @@ Promise.all([ title: 'https://tools.ietf.org/html/rfc7520#section-5.6 - Key Wrap using AES-GCM KeyWrap with AES-CBC-HMAC-SHA2', webcrypto: true, + electron: true, reproducible: true, input: { plaintext: @@ -628,6 +635,7 @@ Promise.all([ title: 'https://tools.ietf.org/html/rfc7520#section-5.8 - Key Wrap using AES-KeyWrap with AES-GCM', webcrypto: true, + electron: false, reproducible: true, input: { plaintext: @@ -685,6 +693,7 @@ Promise.all([ { title: 'https://tools.ietf.org/html/rfc7520#section-5.9 - Compressed Content', webcrypto: true, + electron: false, reproducible: true, input: { plaintext: @@ -747,6 +756,7 @@ Promise.all([ title: 'https://tools.ietf.org/html/rfc7520#section-5.10 - Including Additional Authenticated Data', webcrypto: true, + electron: false, reproducible: true, input: { plaintext: @@ -811,6 +821,7 @@ Promise.all([ title: 'https://tools.ietf.org/html/rfc7520#section-5.11 - Protecting Specific Header Fields', webcrypto: true, + electron: false, reproducible: true, input: { plaintext: @@ -874,6 +885,7 @@ Promise.all([ { title: 'https://tools.ietf.org/html/rfc7520#section-5.12 - Protecting Content Only', webcrypto: true, + electron: false, reproducible: true, input: { plaintext: @@ -935,22 +947,23 @@ Promise.all([ ]; for (const vector of vectors) { - let conditional; + let run = test; if ( ('WEBCRYPTO' in process.env || 'CRYPTOKEY' in process.env) && vector.webcrypto === false ) { - conditional = test.failing; - } else { - conditional = test; + run = run.failing; + } + if ('electron' in process.versions && vector.electron === false) { + run = run.failing; } if (vector.skip) { - conditional = test.skip; + run = run.skip; } if (vector.only) { - conditional = test.only; + run = run.only; } - conditional(testCookbook, vector); + run(testCookbook, vector); } }, ); diff --git a/test/jwe/smoke.test.mjs b/test/jwe/smoke.test.mjs index 7f7f3df2cc..249647f96f 100644 --- a/test/jwe/smoke.test.mjs +++ b/test/jwe/smoke.test.mjs @@ -136,22 +136,40 @@ Promise.all([ algs: ['ECDH-ES', 'ECDH-ES+A128KW', 'ECDH-ES+A192KW', 'ECDH-ES+A256KW'], generate: { crv: 'X448' }, }, - p256: { + p256kw: { public: pubjwk(p256), private: p256, - algs: ['ECDH-ES', 'ECDH-ES+A128KW', 'ECDH-ES+A192KW', 'ECDH-ES+A256KW'], + algs: ['ECDH-ES+A128KW', 'ECDH-ES+A192KW', 'ECDH-ES+A256KW'], + generate: { crv: 'P-256' }, + }, + p256dir: { + public: pubjwk(p256), + private: p256, + algs: ['ECDH-ES'], generate: { crv: 'P-256' }, }, - p384: { + p384kw: { public: pubjwk(p384), private: p384, - algs: ['ECDH-ES', 'ECDH-ES+A128KW', 'ECDH-ES+A192KW', 'ECDH-ES+A256KW'], + algs: ['ECDH-ES+A128KW', 'ECDH-ES+A192KW', 'ECDH-ES+A256KW'], generate: { crv: 'P-384' }, }, - p521: { + p384dir: { + public: pubjwk(p384), + private: p384, + algs: ['ECDH-ES'], + generate: { crv: 'P-384' }, + }, + p521kw: { public: pubjwk(p521), private: p521, - algs: ['ECDH-ES', 'ECDH-ES+A128KW', 'ECDH-ES+A192KW', 'ECDH-ES+A256KW'], + algs: ['ECDH-ES+A128KW', 'ECDH-ES+A192KW', 'ECDH-ES+A256KW'], + generate: { crv: 'P-521' }, + }, + p521dir: { + public: pubjwk(p521), + private: p521, + algs: ['ECDH-ES'], generate: { crv: 'P-521' }, }, octAny: { @@ -276,40 +294,63 @@ Promise.all([ test(smoke, 'rsa'); test('with wrap ops', smoke, 'rsa', ['wrapKey'], ['unwrapKey']); test('with enc ops', smoke, 'rsa', ['encrypt'], ['decrypt']); - test(smoke, 'p256'); - test(smoke, 'p384'); - test(smoke, 'p521'); - test(smoke, 'oct128'); - test('as keyobject', smoke, 'oct128', ['wrapKey'], ['unwrapKey'], true); + test(smoke, 'p256dir'); + test(smoke, 'p384dir'); + test(smoke, 'p521dir'); test(smoke, 'oct128gcm'); test('as keyobject', smoke, 'oct128gcm', ['encrypt'], ['decrypt'], true); - test(smoke, 'oct192'); - test('as keyobject', smoke, 'oct192', ['wrapKey'], ['unwrapKey'], true); test(smoke, 'oct192gcm'); test('as keyobject', smoke, 'oct192gcm', ['encrypt'], ['decrypt'], true); - test(smoke, 'oct256'); - test('as keyobject', smoke, 'oct256', ['wrapKey'], ['unwrapKey'], true); test(smoke, 'oct256gcm'); test('as keyobject', smoke, 'oct256gcm', ['encrypt'], ['decrypt'], true); test(smoke, 'oct256c'); test(smoke, 'oct384c'); test(smoke, 'oct512c'); - test(smoke, 'octAny'); - test('as keyobject (deriveBits)', smoke, 'octAny', ['deriveBits'], ['deriveBits'], true); - test('as keyobject (deriveKey)', smoke, 'octAny', ['deriveKey'], ['deriveKey'], true); - let conditional; - if ('WEBCRYPTO' in process.env || 'CRYPTOKEY' in process.env) { - conditional = test.failing; - } else { - conditional = test; + function conditional({ webcrypto = 1, electron = 1 } = {}, ...args) { + let run = test; + if ((!webcrypto && 'WEBCRYPTO' in process.env)) { + run = run.failing; + } + + if (!electron && 'electron' in process.versions) { + run = run.failing; + } + return run; } - conditional(smoke, 'rsa1_5'); - conditional(smoke, 'x25519'); - conditional(smoke, 'x448'); - conditional('as keyobject', smoke, 'oct256c', undefined, undefined, true); - conditional('as keyobject', smoke, 'oct384c', undefined, undefined, true); - conditional('as keyobject', smoke, 'oct512c', undefined, undefined, true); + + conditional({ webcrypto: 0 }, smoke, 'rsa1_5'); + conditional({ webcrypto: 0, electron: 0 }, smoke, 'x25519'); + conditional({ webcrypto: 0, electron: 0 }, smoke, 'x448'); + conditional({ webcrypto: 0 }, 'as keyobject', smoke, 'oct256c', undefined, undefined, true); + conditional({ webcrypto: 0 }, 'as keyobject', smoke, 'oct384c', undefined, undefined, true); + conditional({ webcrypto: 0 }, 'as keyobject', smoke, 'oct512c', undefined, undefined, true); + conditional({ electron: 0 })(smoke, 'octAny'); + conditional({ electron: 0 })( + 'as keyobject (deriveBits)', + smoke, + 'octAny', + ['deriveBits'], + ['deriveBits'], + true, + ); + conditional({ electron: 0 })( + 'as keyobject (deriveKey)', + smoke, + 'octAny', + ['deriveKey'], + ['deriveKey'], + true, + ); + conditional({ electron: 0 })(smoke, 'oct128'); + conditional({ electron: 0 })('as keyobject', smoke, 'oct128', ['wrapKey'], ['unwrapKey'], true); + conditional({ electron: 0 })(smoke, 'oct192'); + conditional({ electron: 0 })('as keyobject', smoke, 'oct192', ['wrapKey'], ['unwrapKey'], true); + conditional({ electron: 0 })(smoke, 'oct256'); + conditional({ electron: 0 })('as keyobject', smoke, 'oct256', ['wrapKey'], ['unwrapKey'], true); + conditional({ electron: 0 }, smoke, 'p256kw'); + conditional({ electron: 0 }, smoke, 'p384kw'); + conditional({ electron: 0 }, smoke, 'p521kw'); }, (err) => { test('failed to import', (t) => { diff --git a/test/jwk/jwk2key.test.mjs b/test/jwk/jwk2key.test.mjs index a9cddf58d5..4df4c721c6 100644 --- a/test/jwk/jwk2key.test.mjs +++ b/test/jwk/jwk2key.test.mjs @@ -220,14 +220,19 @@ Promise.all([import(`${root}/jwk/parse`), import(`${root}/jwk/from_key_like`)]). ); }); - let conditional; - if ('WEBCRYPTO' in process.env) { - conditional = test.failing; - } else { - conditional = test; + function conditional({ webcrypto = 1, electron = 1 } = {}, ...args) { + let run = test; + if (!webcrypto && 'WEBCRYPTO' in process.env) { + run = run.failing; + } + + if (!electron && 'electron' in process.versions) { + run = run.failing; + } + return run; } - conditional('secret key object can be transformed to a JWK', async (t) => { + conditional({ webcrypto: 0 })('secret key object can be transformed to a JWK', async (t) => { const keylike = await parseJwk( { ext: true, @@ -250,35 +255,38 @@ Promise.all([import(`${root}/jwk/parse`), import(`${root}/jwk/from_key_like`)]). d: '47Iw2GXvj-hpfgGsfF3F2mekHKaDc2qv7WTqtAkU1H0', kty: 'EC', }; - conditional(testKeyImportExport, { ...secp256k1, alg: 'ES256K' }); + conditional({ webcrypto: 0, electron: 0 })(testKeyImportExport, { + ...secp256k1, + alg: 'ES256K', + }); const ed25519 = { crv: 'Ed25519', x: 'GVLslCt7dY6H8p_yatNaGOtpdrCho5qaLvIvNTMd29M', d: 'FRaWZohbbDyzhYpTCS9m4fv2xoK6HG83bw6jq6zNxEs', kty: 'OKP', }; - conditional(testKeyImportExport, { ...ed25519, alg: 'EdDSA' }); + conditional({ webcrypto: 0 })(testKeyImportExport, { ...ed25519, alg: 'EdDSA' }); const ed448 = { crv: 'Ed448', x: 'KYWcaDwgH77xdAwcbzOgvCVcGMy9I6prRQBhQTTdKXUcr-VquTz7Fd5adJO0wT2VHysF3bk3kBoA', d: 'UhC3-vN5vp_g9PnTknXZgfXUez7Xvw-OfuJ0pYkuwzpYkcTvacqoFkV_O05WMHpyXkzH9q2wzx5n', kty: 'OKP', }; - conditional(testKeyImportExport, { ...ed448, alg: 'EdDSA' }); + conditional({ webcrypto: 0, electron: 0 })(testKeyImportExport, { ...ed448, alg: 'EdDSA' }); const x25519 = { crv: 'X25519', x: 'axR8Q7PEd74nY9nWaAoAYpMe3gp5sWbau6V6X1inPw4', d: 'aCvvb3jEBnxJJBjCIN2a9ZDTL-HG6LVgBbij4m8-d3Y', kty: 'OKP', }; - conditional(testKeyImportExport, { ...x25519, alg: 'ECDH-ES' }); + conditional({ webcrypto: 0 })(testKeyImportExport, { ...x25519, alg: 'ECDH-ES' }); const x448 = { crv: 'X448', x: 'z8s0Ej7D4pgIDu233UHoDW48EbiEm5eFv8_LuFwRr0xVREHhCtdxH75x6J8egZbjDGweOSbeHbY', d: 'xBrCwLlrHa1ov2cbmD4eMw4t6DoN_MWsBT_mxcA_QWsCS_9sKMRyFpphNN9_2iKrGPTC9pWCS5w', kty: 'OKP', }; - conditional(testKeyImportExport, { ...x448, alg: 'ECDH-ES' }); + conditional({ webcrypto: 0, electron: 0 })(testKeyImportExport, { ...x448, alg: 'ECDH-ES' }); }, (err) => { test('failed to import', (t) => { diff --git a/test/jws/smoke.test.mjs b/test/jws/smoke.test.mjs index 84b9618e32..5057cf6c4e 100644 --- a/test/jws/smoke.test.mjs +++ b/test/jws/smoke.test.mjs @@ -221,15 +221,21 @@ Promise.all([ test('as keyobject', smoke, 'oct384', true); test('as keyobject', smoke, 'oct512', true); - let conditional; - if ('WEBCRYPTO' in process.env || 'CRYPTOKEY' in process.env) { - conditional = test.failing; - } else { - conditional = test; + function conditional({ webcrypto = 1, electron = 1 } = {}, ...args) { + let run = test; + if ((!webcrypto && 'WEBCRYPTO' in process.env) || 'CRYPTOKEY' in process.env) { + run = run.failing; + } + + if (!electron && 'electron' in process.versions) { + run = run.failing; + } + return run; } - conditional(smoke, 'secp256k1'); - conditional(smoke, 'ed25519'); - conditional(smoke, 'ed448'); + + conditional({ webcrypto: 0, electron: 0 })(smoke, 'secp256k1'); + conditional({ webcrypto: 0 })(smoke, 'ed25519'); + conditional({ webcrypto: 0, electron: 0 })(smoke, 'ed448'); }, (err) => { test('failed to import', (t) => { diff --git a/test/unit/decrypt_key_management.test.mjs b/test/unit/decrypt_key_management.test.mjs index b13388fe49..4129c23b42 100644 --- a/test/unit/decrypt_key_management.test.mjs +++ b/test/unit/decrypt_key_management.test.mjs @@ -71,20 +71,29 @@ Promise.all([ }); } - let conditional; - if ('WEBCRYPTO' in process.env) { - conditional = test.failing; - } else { - conditional = test; + function conditional({ webcrypto = 1, electron = 1 } = {}, ...args) { + let run = test; + if (!webcrypto && 'WEBCRYPTO' in process.env) { + run = run.failing; + } + + if (!electron && 'electron' in process.versions) { + run = run.failing; + } + return run; } - conditional('ECDH-ES cannot be executed with secp256k1', async (t) => { - const { privateKey } = await generateKeyPair('ES256K'); - await t.throwsAsync(decryptKeyManagement('ECDH-ES', privateKey, undefined, { epk: {} }), { - code: 'ERR_JOSE_NOT_SUPPORTED', - message: - 'ECDH-ES with the provided key is not allowed or not supported by your javascript runtime', - }); - }); + + conditional({ webcrypto: 0, electron: 0 })( + 'ECDH-ES cannot be executed with secp256k1', + async (t) => { + const { privateKey } = await generateKeyPair('ES256K'); + await t.throwsAsync(decryptKeyManagement('ECDH-ES', privateKey, undefined, { epk: {} }), { + code: 'ERR_JOSE_NOT_SUPPORTED', + message: + 'ECDH-ES with the provided key is not allowed or not supported by your javascript runtime', + }); + }, + ); }, (err) => { test('failed to import', (t) => { diff --git a/test/unit/encrypt_key_management.test.mjs b/test/unit/encrypt_key_management.test.mjs index ca7c0e16e9..b2f029a8e9 100644 --- a/test/unit/encrypt_key_management.test.mjs +++ b/test/unit/encrypt_key_management.test.mjs @@ -13,20 +13,29 @@ Promise.all([ }); }); - let conditional; - if ('WEBCRYPTO' in process.env) { - conditional = test.failing; - } else { - conditional = test; + function conditional({ webcrypto = 1, electron = 1 } = {}, ...args) { + let run = test; + if (!webcrypto && 'WEBCRYPTO' in process.env) { + run = run.failing; + } + + if (!electron && 'electron' in process.versions) { + run = run.failing; + } + return run; } - conditional('ECDH-ES cannot be executed with secp256k1', async (t) => { - const { publicKey } = await generateKeyPair('ES256K'); - await t.throwsAsync(encryptKeyManagement('ECDH-ES', 'A128GCM', publicKey), { - code: 'ERR_JOSE_NOT_SUPPORTED', - message: - 'ECDH-ES with the provided key is not allowed or not supported by your javascript runtime', - }); - }); + + conditional({ webcrypto: 0, electron: 0 })( + 'ECDH-ES cannot be executed with secp256k1', + async (t) => { + const { publicKey } = await generateKeyPair('ES256K'); + await t.throwsAsync(encryptKeyManagement('ECDH-ES', 'A128GCM', publicKey), { + code: 'ERR_JOSE_NOT_SUPPORTED', + message: + 'ECDH-ES with the provided key is not allowed or not supported by your javascript runtime', + }); + }, + ); }, (err) => { test('failed to import', (t) => { diff --git a/test/util/generators.test.mjs b/test/util/generators.test.mjs index 92a11f5124..3ff1000ec8 100644 --- a/test/util/generators.test.mjs +++ b/test/util/generators.test.mjs @@ -123,23 +123,53 @@ Promise.all([ test(`crv: ${crv}`, testKeyPair, 'ECDH-ES+A256KW', { crv }); } - let conditional; - if ('WEBCRYPTO' in process.env) { - conditional = test.failing; - } else { - conditional = test; + function conditional({ webcrypto = 1, electron = 1 } = {}, ...args) { + let run = test; + if (!webcrypto && 'WEBCRYPTO' in process.env) { + run = run.failing; + } + + if (!electron && 'electron' in process.versions) { + run = run.failing; + } + return run; } - conditional(testKeyPair, 'EdDSA'); - conditional('crv: Ed25519', testKeyPair, 'EdDSA', { crv: 'Ed25519' }); - conditional('crv: Ed448', testKeyPair, 'EdDSA', { crv: 'Ed448' }); - conditional(testKeyPair, 'ES256K'); - conditional(testKeyPair, 'RSA1_5'); - conditional('with modulusLength', testKeyPair, 'RSA1_5', { modulusLength: 3072 }); + + conditional({ webcrypto: 0 })(testKeyPair, 'EdDSA'); + conditional({ webcrypto: 0 })('crv: Ed25519', testKeyPair, 'EdDSA', { crv: 'Ed25519' }); + conditional({ webcrypto: 0, electron: 0 })('crv: Ed448', testKeyPair, 'EdDSA', { + crv: 'Ed448', + }); + conditional({ webcrypto: 0, electron: 0 })(testKeyPair, 'ES256K'); + conditional({ webcrypto: 0 })(testKeyPair, 'RSA1_5'); + conditional({ webcrypto: 0 })('with modulusLength', testKeyPair, 'RSA1_5', { + modulusLength: 3072, + }); for (const crv of ['X25519', 'X448']) { - conditional(`crv: ${crv}`, testKeyPair, 'ECDH-ES', { crv }); - conditional(`crv: ${crv}`, testKeyPair, 'ECDH-ES+A128KW', { crv }); - conditional(`crv: ${crv}`, testKeyPair, 'ECDH-ES+A192KW', { crv }); - conditional(`crv: ${crv}`, testKeyPair, 'ECDH-ES+A256KW', { crv }); + conditional({ webcrypto: 0, electron: crv === 'X25519' })( + `crv: ${crv}`, + testKeyPair, + 'ECDH-ES', + { crv }, + ); + conditional({ webcrypto: 0, electron: crv === 'X25519' })( + `crv: ${crv}`, + testKeyPair, + 'ECDH-ES+A128KW', + { crv }, + ); + conditional({ webcrypto: 0, electron: crv === 'X25519' })( + `crv: ${crv}`, + testKeyPair, + 'ECDH-ES+A192KW', + { crv }, + ); + conditional({ webcrypto: 0, electron: crv === 'X25519' })( + `crv: ${crv}`, + testKeyPair, + 'ECDH-ES+A256KW', + { crv }, + ); } async function testSecret(t, alg, expectedLength) {