From 9892ee273eefa9a2a2f55d9b52893bb8d3322679 Mon Sep 17 00:00:00 2001 From: n1474335 Date: Mon, 1 Feb 2021 11:10:04 +0000 Subject: [PATCH] Bugfix: ECC mode now works correctly in 'Generate PGP Key Pair' --- src/core/operations/GeneratePGPKeyPair.mjs | 9 ++++++--- tests/node/tests/operations.mjs | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/core/operations/GeneratePGPKeyPair.mjs b/src/core/operations/GeneratePGPKeyPair.mjs index 7176d526..bb366b6f 100644 --- a/src/core/operations/GeneratePGPKeyPair.mjs +++ b/src/core/operations/GeneratePGPKeyPair.mjs @@ -33,7 +33,7 @@ class GeneratePGPKeyPair extends Operation { { "name": "Key type", "type": "option", - "value": ["RSA-1024", "RSA-2048", "RSA-4096", "ECC-256", "ECC-384"] + "value": ["RSA-1024", "RSA-2048", "RSA-4096", "ECC-256", "ECC-384", "ECC-521"] }, { "name": "Password (optional)", @@ -59,12 +59,15 @@ class GeneratePGPKeyPair extends Operation { * @returns {string} */ async run(input, args) { - const [keyType, keySize] = args[0].split("-"), - password = args[1], + let [keyType, keySize] = args[0].split("-"); + const password = args[1], name = args[2], email = args[3]; let userIdentifier = ""; + keyType = keyType.toLowerCase(); + keySize = parseInt(keySize, 10); + if (name) userIdentifier += name; if (email) userIdentifier += ` <${email}>`; diff --git a/tests/node/tests/operations.mjs b/tests/node/tests/operations.mjs index 0a9d74e4..bc4ccb56 100644 --- a/tests/node/tests/operations.mjs +++ b/tests/node/tests/operations.mjs @@ -588,7 +588,7 @@ Password: 034148`; const result = await chef.generatePGPKeyPair("Back To the Drawing Board", { keyType: "ECC-256", }); - assert.strictEqual(result.toString().length, 2007); + assert.strictEqual(result.toString().length, 2560); }), it("Generate UUID", () => {