From fe420d0bf9d7424d6efcd79071eb15785995978a Mon Sep 17 00:00:00 2001 From: larabr <7375870+larabr@users.noreply.github.com> Date: Thu, 19 Oct 2023 15:41:02 +0200 Subject: [PATCH] Rename `enums.curve.x25519Legacy` to `.curve25519Legacy` To keep name aligned with the spec. --- openpgp.d.ts | 4 ++-- src/enums.js | 4 ++-- src/key/helper.js | 4 ++-- test/general/config.js | 2 +- test/general/key.js | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/openpgp.d.ts b/openpgp.d.ts index df44c530..bfdcaf96 100644 --- a/openpgp.d.ts +++ b/openpgp.d.ts @@ -834,9 +834,9 @@ export namespace enums { /** @deprecated use `ed25519Legacy` instead */ ed25519 = 'ed25519', ed25519Legacy = 'ed25519', - /** @deprecated use `x25519Legacy` instead */ + /** @deprecated use `curve25519Legacy` instead */ curve25519 = 'curve25519', - x25519Legacy = 'curve25519', + curve25519Legacy = 'curve25519', secp256k1 = 'secp256k1', brainpoolP256r1 = 'brainpoolP256r1', brainpoolP384r1 = 'brainpoolP384r1', diff --git a/src/enums.js b/src/enums.js index c6df0a9b..220ed807 100644 --- a/src/enums.js +++ b/src/enums.js @@ -54,10 +54,10 @@ export default { '2B06010401DA470F01': 'ed25519', /** Curve25519 - deprecated by crypto-refresh (replaced by standaone X25519 algo) */ - 'x25519Legacy': 'curve25519', + 'curve25519Legacy': 'curve25519', 'X25519': 'curve25519', 'cv25519': 'curve25519', - /** @deprecated use `x25519Legacy` instead */ + /** @deprecated use `curve25519Legacy` instead */ 'curve25519': 'curve25519', 'Curve25519': 'curve25519', '1.3.6.1.4.1.3029.1.5.1': 'curve25519', diff --git a/src/key/helper.js b/src/key/helper.js index a075cd48..05a83331 100644 --- a/src/key/helper.js +++ b/src/key/helper.js @@ -333,8 +333,8 @@ export function sanitizeKeyOptions(options, subkeyDefaults = {}) { } catch (e) { throw new Error('Unknown curve'); } - if (options.curve === enums.curve.ed25519Legacy || options.curve === enums.curve.x25519Legacy) { - options.curve = options.sign ? enums.curve.ed25519Legacy : enums.curve.x25519Legacy; + if (options.curve === enums.curve.ed25519Legacy || options.curve === enums.curve.curve25519Legacy) { + options.curve = options.sign ? enums.curve.ed25519Legacy : enums.curve.curve25519Legacy; } if (options.sign) { options.algorithm = options.curve === enums.curve.ed25519Legacy ? enums.publicKey.eddsaLegacy : enums.publicKey.ecdsa; diff --git a/test/general/config.js b/test/general/config.js index cff7ecc0..10ba476b 100644 --- a/test/general/config.js +++ b/test/general/config.js @@ -296,7 +296,7 @@ n9/quqtmyOtYOA6gXNCw0Fal3iANKBmsPmYI })).to.be.eventually.rejectedWith(/ecdh keys are considered too weak/); await expect(openpgp.encrypt({ - message, encryptionKeys: [key], config: { rejectCurves: new Set([openpgp.enums.curve.x25519Legacy]) } + message, encryptionKeys: [key], config: { rejectCurves: new Set([openpgp.enums.curve.curve25519Legacy]) } })).to.be.eventually.rejectedWith(/Support for ecdh keys using curve curve25519 is disabled/); const echdEncrypted = await openpgp.encrypt({ diff --git a/test/general/key.js b/test/general/key.js index e2bab875..c75aaa3e 100644 --- a/test/general/key.js +++ b/test/general/key.js @@ -4070,7 +4070,7 @@ XvmoLueOOShu01X/kaylMqaT8w== const subkey = newPrivateKey.subkeys[total]; expect(subkey).to.exist; expect(subkey.getAlgorithmInfo().algorithm).to.be.equal('ecdh'); - expect(subkey.getAlgorithmInfo().curve).to.be.equal(openpgp.enums.curve.x25519Legacy); + expect(subkey.getAlgorithmInfo().curve).to.be.equal(openpgp.enums.curve.curve25519Legacy); await subkey.verify(); });