From 6c35c519c9181f8246b36ad02572adb609d6de1d Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Thu, 3 Sep 2020 19:20:58 +0200 Subject: [PATCH] refactor: removed deprecated methods and utilities BREAKING CHANGE: deprecated method `JWK.importKey` was removed BREAKING CHANGE: deprecated method `JWKS.KeyStore.fromJWKS` was removed BREAKING CHANGE: the use of unregistered curve name P-256K for secp256k1 was removed --- P-256K/index.js | 6 - lib/help/asn1/oids.js | 4 +- lib/jwa/ecdh/dir.js | 3 +- lib/jwa/ecdh/kw.js | 3 +- lib/jwa/ecdsa.js | 3 +- lib/jwk/import.js | 6 - lib/jwk/index.js | 6 - lib/jwk/key/ec.js | 9 - lib/jwk/key/secp256k1_crv.js | 13 -- lib/jwks/keystore.js | 7 +- lib/registry/ec_curves.js | 4 +- test/fixtures/index.js | 13 -- test/help/P-256K.key_utils.test.js | 29 --- test/jwk/P-256K.import.test.js | 273 ----------------------------- test/jwk/import.test.js | 3 +- test/jwks/keystore.test.js | 1 - test/jws/smoke.P-256K.test.js | 21 --- test/jws/smoke.test.js | 1 - 18 files changed, 7 insertions(+), 398 deletions(-) delete mode 100644 P-256K/index.js delete mode 100644 lib/jwk/key/secp256k1_crv.js delete mode 100644 test/help/P-256K.key_utils.test.js delete mode 100644 test/jwk/P-256K.import.test.js delete mode 100644 test/jws/smoke.P-256K.test.js diff --git a/P-256K/index.js b/P-256K/index.js deleted file mode 100644 index 7d66971a27..0000000000 --- a/P-256K/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// rename 'secp256k1' to 'P-256K' - -const { rename } = require('../lib/jwk/key/secp256k1_crv') -rename('P-256K') - -module.exports = require('../lib') diff --git a/lib/help/asn1/oids.js b/lib/help/asn1/oids.js index 678010db91..be28bcf2f0 100644 --- a/lib/help/asn1/oids.js +++ b/lib/help/asn1/oids.js @@ -1,8 +1,6 @@ -const { name: secp256k1 } = require('../../jwk/key/secp256k1_crv') - const oids = { '1 2 840 10045 3 1 7': 'P-256', - '1 3 132 0 10': secp256k1, + '1 3 132 0 10': 'secp256k1', '1 3 132 0 34': 'P-384', '1 3 132 0 35': 'P-521', '1 2 840 10045 2 1': 'ecPublicKey', diff --git a/lib/jwa/ecdh/dir.js b/lib/jwa/ecdh/dir.js index 7f09d14040..5185f19fad 100644 --- a/lib/jwa/ecdh/dir.js +++ b/lib/jwa/ecdh/dir.js @@ -1,7 +1,6 @@ const { improvedDH } = require('../../help/runtime_support') const { KEYLENGTHS } = require('../../registry') const { generateSync } = require('../../jwk/generate') -const { name: secp256k1 } = require('../../jwk/key/secp256k1_crv') const derive = require('./derive') @@ -24,7 +23,7 @@ const unwrapKey = (key, payload, header) => { module.exports = (JWA, JWK) => { JWA.keyManagementEncrypt.set('ECDH-ES', wrapKey) JWA.keyManagementDecrypt.set('ECDH-ES', unwrapKey) - JWK.EC.deriveKey['ECDH-ES'] = key => (key.use === 'enc' || key.use === undefined) && key.crv !== secp256k1 + JWK.EC.deriveKey['ECDH-ES'] = key => (key.use === 'enc' || key.use === undefined) && key.crv !== 'secp256k1' if (improvedDH) { JWK.OKP.deriveKey['ECDH-ES'] = key => (key.use === 'enc' || key.use === undefined) && key.keyObject.asymmetricKeyType.startsWith('x') diff --git a/lib/jwa/ecdh/kw.js b/lib/jwa/ecdh/kw.js index d32f2f0985..237a893744 100644 --- a/lib/jwa/ecdh/kw.js +++ b/lib/jwa/ecdh/kw.js @@ -1,7 +1,6 @@ const { improvedDH } = require('../../help/runtime_support') const { KEYOBJECT } = require('../../help/consts') const { generateSync } = require('../../jwk/generate') -const { name: secp256k1 } = require('../../jwk/key/secp256k1_crv') const { ECDH_DERIVE_LENGTHS } = require('../../registry') const derive = require('./derive') @@ -36,7 +35,7 @@ module.exports = (JWA, JWK) => { if (kwWrap && kwUnwrap) { JWA.keyManagementEncrypt.set(jwaAlg, wrapKey.bind(undefined, kwWrap, derive.bind(undefined, jwaAlg, keylen))) JWA.keyManagementDecrypt.set(jwaAlg, unwrapKey.bind(undefined, kwUnwrap, derive.bind(undefined, jwaAlg, keylen))) - JWK.EC.deriveKey[jwaAlg] = key => (key.use === 'enc' || key.use === undefined) && key.crv !== secp256k1 + JWK.EC.deriveKey[jwaAlg] = key => (key.use === 'enc' || key.use === undefined) && key.crv !== 'secp256k1' if (improvedDH) { JWK.OKP.deriveKey[jwaAlg] = key => (key.use === 'enc' || key.use === undefined) && key.keyObject.asymmetricKeyType.startsWith('x') diff --git a/lib/jwa/ecdsa.js b/lib/jwa/ecdsa.js index 096bf2f143..fd114abb1f 100644 --- a/lib/jwa/ecdsa.js +++ b/lib/jwa/ecdsa.js @@ -5,7 +5,6 @@ const { KEYOBJECT } = require('../help/consts') const resolveNodeAlg = require('../help/node_alg') const { asInput } = require('../help/key_object') const { dsaEncodingSupported } = require('../help/runtime_support') -const { name: secp256k1 } = require('../jwk/key/secp256k1_crv') let sign, verify @@ -40,7 +39,7 @@ const crvToAlg = (crv) => { switch (crv) { case 'P-256': return 'ES256' - case secp256k1: + case 'secp256k1': return 'ES256K' case 'P-384': return 'ES384' diff --git a/lib/jwk/import.js b/lib/jwk/import.js index c07d71d723..160d3f4892 100644 --- a/lib/jwk/import.js +++ b/lib/jwk/import.js @@ -1,5 +1,3 @@ -const { deprecate } = require('util') - const { createPublicKey, createPrivateKey, createSecretKey, KeyObject } = require('../help/key_object') const base64url = require('../help/base64url') const isObject = require('../help/is_object') @@ -134,7 +132,3 @@ const asKey = (key, parameters, { calculateMissingRSAPrimes = false } = {}) => { } module.exports = asKey -Object.defineProperty(asKey, 'deprecated', { - value: deprecate((key, parameters) => { return asKey(key, parameters, { calculateMissingRSAPrimes: true }) }, 'JWK.importKey() is deprecated, use JWK.asKey() instead'), - enumerable: false -}) diff --git a/lib/jwk/index.js b/lib/jwk/index.js index 0c95c4f043..6d0d41c80f 100644 --- a/lib/jwk/index.js +++ b/lib/jwk/index.js @@ -13,9 +13,3 @@ module.exports = { EmbeddedJWK, EmbeddedX5C } - -/* deprecated */ -Object.defineProperty(module.exports, 'importKey', { - value: importKey.deprecated, - enumerable: false -}) diff --git a/lib/jwk/key/ec.js b/lib/jwk/key/ec.js index 489656351c..0a5848a4db 100644 --- a/lib/jwk/key/ec.js +++ b/lib/jwk/key/ec.js @@ -10,7 +10,6 @@ const { keyObjectSupported } = require('../../help/runtime_support') const { createPublicKey, createPrivateKey } = require('../../help/key_object') const errors = require('../../errors') -const { name: secp256k1 } = require('./secp256k1_crv') const Key = require('./base') @@ -62,10 +61,6 @@ class ECKey extends Key { throw new errors.JOSENotSupported(`unsupported EC key curve: ${crv}`) } - if (crv === secp256k1 && crv !== 'secp256k1') { - crv = 'secp256k1' - } - let privateKey, publicKey if (keyObjectSupported) { @@ -91,10 +86,6 @@ class ECKey extends Key { throw new errors.JOSENotSupported(`unsupported EC key curve: ${crv}`) } - if (crv === secp256k1 && crv !== 'secp256k1') { - crv = 'secp256k1' - } - let privateKey, publicKey if (keyObjectSupported) { diff --git a/lib/jwk/key/secp256k1_crv.js b/lib/jwk/key/secp256k1_crv.js deleted file mode 100644 index 02525b6136..0000000000 --- a/lib/jwk/key/secp256k1_crv.js +++ /dev/null @@ -1,13 +0,0 @@ -const { deprecate } = require('util') - -const deprecation = deprecate(() => {}, '"P-256K" EC curve name is deprecated') - -module.exports = { - name: 'secp256k1', - rename (value) { - if (value !== 'secp256k1') { - deprecation() - } - module.exports.name = value - } -} diff --git a/lib/jwks/keystore.js b/lib/jwks/keystore.js index 15a6fbb11e..83820aa14e 100644 --- a/lib/jwks/keystore.js +++ b/lib/jwks/keystore.js @@ -1,4 +1,4 @@ -const { deprecate, inspect } = require('util') +const { inspect } = require('util') const isObject = require('../help/is_object') const { generate, generateSync } = require('../jwk/generate') @@ -177,9 +177,4 @@ function asKeyStore (jwks, { ignoreErrors = false, calculateMissingRSAPrimes = f return new KeyStore(...keys) } -Object.defineProperty(KeyStore, 'fromJWKS', { - value: deprecate(jwks => asKeyStore(jwks, { calculateMissingRSAPrimes: true }), 'JWKS.KeyStore.fromJWKS() is deprecated, use JWKS.asKeyStore() instead'), - enumerable: false -}) - module.exports = { KeyStore, asKeyStore } diff --git a/lib/registry/ec_curves.js b/lib/registry/ec_curves.js index 08e553d3e5..c03d96abc0 100644 --- a/lib/registry/ec_curves.js +++ b/lib/registry/ec_curves.js @@ -1,7 +1,5 @@ const { getCurves } = require('crypto') -const { name: secp256k1 } = require('../jwk/key/secp256k1_crv') - const curves = new Set() if (getCurves().includes('prime256v1')) { @@ -9,7 +7,7 @@ if (getCurves().includes('prime256v1')) { } if (getCurves().includes('secp256k1')) { - curves.add(secp256k1) + curves.add('secp256k1') } if (getCurves().includes('secp384r1')) { diff --git a/test/fixtures/index.js b/test/fixtures/index.js index f7fc5e505c..f2b6dec713 100644 --- a/test/fixtures/index.js +++ b/test/fixtures/index.js @@ -65,14 +65,6 @@ module.exports.JWK = { d: 'xTAmXNRL8ksBlr-F3yXDrUdRDn1gyIvY_PC2e_iUK7c' }, - 'P-256K': { - kty: 'EC', - crv: 'P-256K', - x: 'VRaLqtMjg_JRaDzkbfit7zonkOGDZ42qbZyljhqsg3U', - y: '5qgTxoRAf0hJxcphVg1NE9r0Xv-HHZyVIJxEbo6SAsQ', - d: 'xTAmXNRL8ksBlr-F3yXDrUdRDn1gyIvY_PC2e_iUK7c' - }, - 'P-384': { kty: 'EC', crv: 'P-384', @@ -124,11 +116,6 @@ module.exports.PEM = { private: readFileSync(join(__dirname, 'secp256k1.key')), public: readFileSync(join(__dirname, 'secp256k1.pem')) }, - 'P-256K': { - testEnc: false, - private: readFileSync(join(__dirname, 'secp256k1.key')), - public: readFileSync(join(__dirname, 'secp256k1.pem')) - }, 'P-384': { private: readFileSync(join(__dirname, 'P-384.key')), public: readFileSync(join(__dirname, 'P-384.pem')) diff --git a/test/help/P-256K.key_utils.test.js b/test/help/P-256K.key_utils.test.js deleted file mode 100644 index b4db798472..0000000000 --- a/test/help/P-256K.key_utils.test.js +++ /dev/null @@ -1,29 +0,0 @@ -// require 'secp256k1' renamed to 'P-256K' -require('../../P-256K') - -const test = require('ava') - -if ('electron' in process.versions) return - -const { createPublicKey, createPrivateKey } = require('../../lib/help/key_object') - -const { keyObjectToJWK, jwkToPem } = require('../../lib/help/key_utils') -const { JWK: fixtures } = require('../fixtures') -const clone = obj => JSON.parse(JSON.stringify(obj)) - -test('EC P-256K Public key', t => { - const expected = clone(fixtures['P-256K']) - delete expected.d - const pem = createPublicKey(jwkToPem(expected)) - const actual = keyObjectToJWK(pem) - - t.deepEqual(actual, expected) -}) - -test('EC P-256K Private key', t => { - const expected = fixtures['P-256K'] - const pem = createPrivateKey(jwkToPem(expected)) - const actual = keyObjectToJWK(pem) - - t.deepEqual(actual, expected) -}) diff --git a/test/jwk/P-256K.import.test.js b/test/jwk/P-256K.import.test.js deleted file mode 100644 index 5071ab3402..0000000000 --- a/test/jwk/P-256K.import.test.js +++ /dev/null @@ -1,273 +0,0 @@ -// require 'secp256k1' renamed to 'P-256K' -require('../../P-256K') - -const test = require('ava') - -if ('electron' in process.versions) return - -const { createPrivateKey, createPublicKey } = require('../../lib/help/key_object') -const { hasProperty, hasNoProperties, hasProperties } = require('../macros') -const fixtures = require('../fixtures') - -const ECKey = require('../../lib/jwk/key/ec') - -Object.entries({ - 'P-256K': ['ES256K', 'zZYrH69YCAAihM7ZCoRj90VI55H5MmQscSpf-JuUS50'] -}).forEach(([crv, [alg, kid]]) => { - // private - ;(() => { - const keyObject = createPrivateKey(fixtures.PEM[crv].private) - const key = new ECKey(keyObject) - - test(`${crv} EC Private key`, hasProperty, key, 'crv', crv) - test(`${crv} EC Private key (with alg)`, hasProperty, new ECKey(keyObject, { alg }), 'alg', alg) - test(`${crv} EC Private key (with kid)`, hasProperty, new ECKey(keyObject, { kid: 'foobar' }), 'kid', 'foobar') - test(`${crv} EC Private key (with use)`, hasProperty, new ECKey(keyObject, { use: 'sig' }), 'use', 'sig') - test(`${crv} EC Private key`, hasNoProperties, key, 'k', 'e', 'n', 'p', 'q', 'dp', 'dq', 'qi') - test(`${crv} EC Private key`, hasProperties, key, 'x', 'y', 'd') - test(`${crv} EC Private key`, hasProperty, key, 'alg', undefined) - test(`${crv} EC Private key`, hasProperty, key, 'kid', kid) - test(`${crv} EC Private key`, hasProperty, key, 'kty', 'EC') - test(`${crv} EC Private key`, hasProperty, key, 'private', true) - test(`${crv} EC Private key`, hasProperty, key, 'public', false) - test(`${crv} EC Private key`, hasProperty, key, 'secret', false) - test(`${crv} EC Private key`, hasProperty, key, 'type', 'private') - test(`${crv} EC Private key`, hasProperty, key, 'use', undefined) - - test(`${crv} EC Private key algorithms (no operation)`, t => { - const result = key.algorithms() - t.is(result.constructor, Set) - t.deepEqual([...result], [alg]) - }) - - test(`${crv} EC Private key algorithms (no operation, w/ alg)`, t => { - const key = new ECKey(keyObject, { alg }) - const result = key.algorithms() - t.is(result.constructor, Set) - t.deepEqual([...result], [alg]) - }) - - test(`${crv} EC Private key supports sign alg (no use)`, t => { - const result = key.algorithms('sign') - t.is(result.constructor, Set) - t.deepEqual([...result], [alg]) - }) - - test(`${crv} EC Private key supports verify alg (no use)`, t => { - const result = key.algorithms('verify') - t.is(result.constructor, Set) - t.deepEqual([...result], [alg]) - }) - - test(`${crv} EC Private key supports sign alg when \`use\` is "sig")`, t => { - const sigKey = new ECKey(keyObject, { use: 'sig' }) - const result = sigKey.algorithms('sign') - t.is(result.constructor, Set) - t.deepEqual([...result], [alg]) - }) - - test(`${crv} EC Private key supports verify alg when \`use\` is "sig")`, t => { - const sigKey = new ECKey(keyObject, { use: 'sig' }) - const result = sigKey.algorithms('verify') - t.is(result.constructor, Set) - t.deepEqual([...result], [alg]) - }) - - test(`${crv} EC Private key supports single sign alg when \`alg\` is set)`, t => { - const sigKey = new ECKey(keyObject, { alg }) - const result = sigKey.algorithms('sign') - t.is(result.constructor, Set) - t.deepEqual([...result], [alg]) - }) - - test(`${crv} EC Private key supports single verify alg when \`alg\` is set)`, t => { - const sigKey = new ECKey(keyObject, { alg }) - const result = sigKey.algorithms('verify') - t.is(result.constructor, Set) - t.deepEqual([...result], [alg]) - }) - - test(`${crv} EC Private key no sign support when \`use\` is "enc"`, t => { - const encKey = new ECKey(keyObject, { use: 'enc' }) - const result = encKey.algorithms('sign') - t.is(result.constructor, Set) - t.deepEqual([...result], []) - }) - - test(`${crv} EC Private key no verify support when \`use\` is "enc"`, t => { - const encKey = new ECKey(keyObject, { use: 'enc' }) - const result = encKey.algorithms('verify') - t.is(result.constructor, Set) - t.deepEqual([...result], []) - }) - - test(`${crv} EC Private key .algorithms("encrypt")`, t => { - const result = key.algorithms('encrypt') - t.is(result.constructor, Set) - t.deepEqual([...result], []) - }) - - test(`${crv} EC Private key .algorithms("decrypt")`, t => { - const result = key.algorithms('decrypt') - t.is(result.constructor, Set) - t.deepEqual([...result], []) - }) - - test(`${crv} EC Private key .algorithms("wrapKey")`, t => { - const result = key.algorithms('wrapKey') - t.is(result.constructor, Set) - t.deepEqual([...result], []) - }) - - test(`${crv} EC Private key .algorithms("deriveKey")`, t => { - const result = key.algorithms('deriveKey') - t.is(result.constructor, Set) - t.deepEqual([...result], []) - }) - - test(`${crv} EC Private key .algorithms("wrapKey") when use is sig`, t => { - const sigKey = new ECKey(keyObject, { use: 'sig' }) - const result = sigKey.algorithms('wrapKey') - t.is(result.constructor, Set) - t.deepEqual([...result], []) - }) - - test(`${crv} EC Private key .algorithms("unwrapKey")`, t => { - const result = key.algorithms('unwrapKey') - t.is(result.constructor, Set) - t.deepEqual([...result], []) - }) - - test(`${crv} EC Private key .algorithms("deriveKey") when use is sig`, t => { - const sigKey = new ECKey(keyObject, { use: 'sig' }) - const result = sigKey.algorithms('deriveKey') - t.is(result.constructor, Set) - t.deepEqual([...result], []) - }) - })() - - // public - ;(() => { - const keyObject = createPublicKey(fixtures.PEM[crv].public) - const key = new ECKey(keyObject) - - test(`${crv} EC Public key`, hasProperty, key, 'crv', crv) - test(`${crv} EC Public key (with alg)`, hasProperty, new ECKey(keyObject, { alg }), 'alg', alg) - test(`${crv} EC Public key (with kid)`, hasProperty, new ECKey(keyObject, { kid: 'foobar' }), 'kid', 'foobar') - test(`${crv} EC Public key (with use)`, hasProperty, new ECKey(keyObject, { use: 'sig' }), 'use', 'sig') - test(`${crv} EC Public key`, hasNoProperties, key, 'k', 'e', 'n', 'p', 'q', 'dp', 'dq', 'qi', 'd') - test(`${crv} EC Public key`, hasProperties, key, 'x', 'y') - test(`${crv} EC Public key`, hasProperty, key, 'alg', undefined) - test(`${crv} EC Public key`, hasProperty, key, 'kid', kid) - test(`${crv} EC Public key`, hasProperty, key, 'kty', 'EC') - test(`${crv} EC Public key`, hasProperty, key, 'private', false) - test(`${crv} EC Public key`, hasProperty, key, 'public', true) - test(`${crv} EC Public key`, hasProperty, key, 'secret', false) - test(`${crv} EC Public key`, hasProperty, key, 'type', 'public') - test(`${crv} EC Public key`, hasProperty, key, 'use', undefined) - - test(`${crv} EC Public key algorithms (no operation)`, t => { - const result = key.algorithms() - t.is(result.constructor, Set) - t.deepEqual([...result], [alg]) - }) - - test(`${crv} EC Public key algorithms (no operation, w/ alg)`, t => { - const key = new ECKey(keyObject, { alg }) - const result = key.algorithms() - t.is(result.constructor, Set) - t.deepEqual([...result], [alg]) - }) - - test(`${crv} EC Public key cannot sign`, t => { - const result = key.algorithms('sign') - t.is(result.constructor, Set) - t.deepEqual([...result], []) - }) - - test(`${crv} EC Public key supports verify alg (no use)`, t => { - const result = key.algorithms('verify') - t.is(result.constructor, Set) - t.deepEqual([...result], [alg]) - }) - - test(`${crv} EC Public key cannot sign even when \`use\` is "sig")`, t => { - const sigKey = new ECKey(keyObject, { use: 'sig' }) - const result = sigKey.algorithms('sign') - t.is(result.constructor, Set) - t.deepEqual([...result], []) - }) - - test(`${crv} EC Public key supports verify alg when \`use\` is "sig")`, t => { - const sigKey = new ECKey(keyObject, { use: 'sig' }) - const result = sigKey.algorithms('verify') - t.is(result.constructor, Set) - t.deepEqual([...result], [alg]) - }) - - test(`${crv} EC Public key cannot sign even when \`alg\` is set)`, t => { - const sigKey = new ECKey(keyObject, { alg }) - const result = sigKey.algorithms('sign') - t.is(result.constructor, Set) - t.deepEqual([...result], []) - }) - - test(`${crv} EC Public key supports single verify alg when \`alg\` is set)`, t => { - const sigKey = new ECKey(keyObject, { alg }) - const result = sigKey.algorithms('verify') - t.is(result.constructor, Set) - t.deepEqual([...result], [alg]) - }) - - test(`${crv} EC Public key no sign support when \`use\` is "enc"`, t => { - const encKey = new ECKey(keyObject, { use: 'enc' }) - const result = encKey.algorithms('sign') - t.is(result.constructor, Set) - t.deepEqual([...result], []) - }) - - test(`${crv} EC Public key no verify support when \`use\` is "enc"`, t => { - const encKey = new ECKey(keyObject, { use: 'enc' }) - const result = encKey.algorithms('verify') - t.is(result.constructor, Set) - t.deepEqual([...result], []) - }) - - test(`${crv} EC Public key .algorithms("encrypt")`, t => { - const result = key.algorithms('encrypt') - t.is(result.constructor, Set) - t.deepEqual([...result], []) - }) - - test(`${crv} EC Public key .algorithms("decrypt")`, t => { - const result = key.algorithms('decrypt') - t.is(result.constructor, Set) - t.deepEqual([...result], []) - }) - - test(`${crv} EC Public key .algorithms("wrapKey")`, t => { - const result = key.algorithms('wrapKey') - t.is(result.constructor, Set) - t.deepEqual([...result], []) - }) - - test(`${crv} EC Public key .algorithms("deriveKey")`, t => { - const result = key.algorithms('deriveKey') - t.is(result.constructor, Set) - t.deepEqual([...result], []) - }) - - test(`${crv} EC Public key .algorithms("wrapKey") when use is sig`, t => { - const sigKey = new ECKey(keyObject, { use: 'sig' }) - const result = sigKey.algorithms('wrapKey') - t.is(result.constructor, Set) - t.deepEqual([...result], []) - }) - - test(`${crv} EC Public key .algorithms("unwrapKey")`, t => { - const result = key.algorithms('unwrapKey') - t.is(result.constructor, Set) - t.deepEqual([...result], []) - }) - })() -}) diff --git a/test/jwk/import.test.js b/test/jwk/import.test.js index dc21e1b731..3c5c4ba679 100644 --- a/test/jwk/import.test.js +++ b/test/jwk/import.test.js @@ -1,6 +1,6 @@ const test = require('ava') -const { JWS, JWE, JWK: { asKey, importKey, generate }, errors } = require('../..') +const { JWS, JWE, JWK: { asKey, generate }, errors } = require('../..') const { edDSASupported, keyObjectSupported } = require('../../lib/help/runtime_support') const { createSecretKey, createPrivateKey } = require('../../lib/help/key_object') @@ -98,7 +98,6 @@ test('minimal RSA test', async t => { const key = await generate('RSA') const { d, e, n } = key.toJWK(true) const minKey = asKey({ kty: 'RSA', d, e, n }, { calculateMissingRSAPrimes: true }) - importKey({ kty: 'RSA', d, e, n }) // deprecated key.algorithms('sign').forEach((alg) => { JWS.verify(JWS.sign({}, key), minKey, { alg }) JWS.verify(JWS.sign({}, minKey), key, { alg }) diff --git a/test/jwks/keystore.test.js b/test/jwks/keystore.test.js index 625e69f9a1..af3d914a34 100644 --- a/test/jwks/keystore.test.js +++ b/test/jwks/keystore.test.js @@ -269,7 +269,6 @@ test('minimal RSA test', async t => { const key = generateSync('RSA') const { d, e, n } = key.toJWK(true) asKeyStore({ keys: [{ kty: 'RSA', d, e, n }] }, { calculateMissingRSAPrimes: true }) - KeyStore.fromJWKS({ keys: [{ kty: 'RSA', d, e, n }] }) // deprecated t.throws(() => { asKeyStore({ keys: [{ kty: 'RSA', d: d.substr(3), e, n }] }, { calculateMissingRSAPrimes: true }) }, { instanceOf: errors.JWKImportFailed, code: 'ERR_JWK_IMPORT_FAILED', message: 'failed to calculate missing primes' }) diff --git a/test/jws/smoke.P-256K.test.js b/test/jws/smoke.P-256K.test.js deleted file mode 100644 index 22bad0b35e..0000000000 --- a/test/jws/smoke.P-256K.test.js +++ /dev/null @@ -1,21 +0,0 @@ -// require 'secp256k1' renamed to 'P-256K' -require('../../P-256K') - -const test = require('ava') - -if ('electron' in process.versions) return - -const { JWK: { asKey } } = require('../..') - -const type = 'P-256K' -const { private: key, public: pub } = require('../fixtures').PEM[type] - -const { JWS: { success, failure } } = require('../macros') - -const sKey = asKey(key) -const vKey = asKey(pub) - -sKey.algorithms('sign').forEach((alg) => { - test(`key ${type} > alg ${alg}`, success, sKey, vKey, alg) - test(`key ${type} > alg ${alg} (negative cases)`, failure, sKey, vKey, alg) -}) diff --git a/test/jws/smoke.test.js b/test/jws/smoke.test.js index 8992d8478c..2547c1017e 100644 --- a/test/jws/smoke.test.js +++ b/test/jws/smoke.test.js @@ -10,7 +10,6 @@ const fixtures = require('../fixtures') const { JWS: { success, failure } } = require('../macros') Object.entries(fixtures.PEM).forEach(([type, { private: key, public: pub }]) => { - if (type === 'P-256K') return if ('electron' in process.versions && (type.startsWith('X') || type === 'Ed448' || type === 'secp256k1')) return if (!edDSASupported && (type.startsWith('Ed') || type.startsWith('X'))) return