From f190823f4afc60ffa255cc202b46a3d573047936 Mon Sep 17 00:00:00 2001
From: librelois <c@elo.tf>
Date: Thu, 1 Oct 2020 19:25:26 +0200
Subject: [PATCH] [fex] security: remove options --salt & --password

---
 app/modules/keypair/index.ts                  | 21 -------------------
 .../modules/keypair/keypair-module-test.ts    | 13 ------------
 2 files changed, 34 deletions(-)

diff --git a/app/modules/keypair/index.ts b/app/modules/keypair/index.ts
index a809f75fd..73d2b33df 100644
--- a/app/modules/keypair/index.ts
+++ b/app/modules/keypair/index.ts
@@ -27,11 +27,6 @@ export const KeypairDependency = {
     },
 
     cliOptions: [
-      { value: "--salt <salt>", desc: "Salt to generate the keypair" },
-      {
-        value: "--passwd <password>",
-        desc: "Password to generate the keypair",
-      },
       {
         value: "--keyN <N>",
         desc:
@@ -98,22 +93,6 @@ export const KeypairDependency = {
         logger: any,
         confDAL: any
       ) => {
-        if (
-          (program.keyN || program.keyr || program.keyp) &&
-          !(program.salt && program.passwd)
-        ) {
-          throw Error(
-            "Missing --salt and --passwd options along with --keyN|keyr|keyp option"
-          );
-        }
-
-        // If we have salt and password, convert it to keypair
-        if (program.salt || program.passwd) {
-          const salt = program.salt || "";
-          const key = program.passwd || "";
-          conf.pair = await Scrypt(salt, key);
-        }
-
         // If no keypair has been loaded, try the default .yml file
         if (!conf.pair || !conf.pair.pub || !conf.pair.sec) {
           const ymlContent = await confDAL.coreFS.read("keyring.yml");
diff --git a/test/fast/modules/keypair/keypair-module-test.ts b/test/fast/modules/keypair/keypair-module-test.ts
index 45998ad1e..1d755d1f5 100644
--- a/test/fast/modules/keypair/keypair-module-test.ts
+++ b/test/fast/modules/keypair/keypair-module-test.ts
@@ -18,19 +18,6 @@ const should = require('should');
 
 describe('Module usage', () => {
 
-  it('wrong options should throw', async () => {
-    let errMessage;
-    try {
-      const stack = Statics.minimalStack();
-      stack.registerDependency(KeypairDependency, 'duniter-keypair');
-      await stack.executeStack(['node', 'index.js', 'config', '--memory', '--keyN', '2048']);
-    } catch (e) {
-      errMessage = e.message;
-    }
-    should.exist(errMessage);
-    should.equal(errMessage, 'Missing --salt and --passwd options along with --keyN|keyr|keyp option');
-  })
-
   it('no options on brand new node should generate random key', async () => {
     const stack = Statics.minimalStack();
     stack.registerDependency(KeypairDependency, 'duniter-keypair');
-- 
GitLab