@sebastienrousseau/crypto-cli 0.0.8 → 0.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +685 -3
- package/dist/cli.js +37 -196
- package/dist/commands/decrypt.command.js +2 -2
- package/dist/commands/encrypt.command.js +2 -2
- package/dist/commands/generate.command.js +2 -2
- package/dist/commands/modern/cbom.command.d.ts +2 -1
- package/dist/commands/modern/cbom.command.d.ts.map +1 -1
- package/dist/commands/modern/cbom.command.js +99 -146
- package/dist/commands/modern/cbom.core.d.ts +5 -0
- package/dist/commands/modern/cbom.core.d.ts.map +1 -0
- package/dist/commands/modern/cbom.core.js +57 -0
- package/dist/commands/modern/encrypt.command.d.ts.map +1 -1
- package/dist/commands/modern/encrypt.command.js +42 -63
- package/dist/commands/modern/hash.command.d.ts.map +1 -1
- package/dist/commands/modern/hash.command.js +1 -1
- package/dist/commands/modern/keygen.command.js +1 -1
- package/dist/commands/modern/password-hash.command.d.ts.map +1 -1
- package/dist/commands/modern/password-hash.command.js +28 -27
- package/dist/commands/modern/sign.command.d.ts.map +1 -1
- package/dist/commands/modern/sign.command.js +83 -73
- package/dist/commands/reformat.command.js +2 -2
- package/dist/commands/revoke.command.js +2 -2
- package/dist/commands/session.command.js +2 -2
- package/dist/commands/sign.command.js +2 -2
- package/dist/commands/verify.command.js +2 -2
- package/dist/menu.d.ts +12 -0
- package/dist/menu.d.ts.map +1 -0
- package/dist/menu.js +107 -0
- package/dist/program/cbom.d.ts +4 -0
- package/dist/program/cbom.d.ts.map +1 -0
- package/dist/program/cbom.js +49 -0
- package/dist/program/encrypt.d.ts +6 -0
- package/dist/program/encrypt.d.ts.map +1 -0
- package/dist/program/encrypt.js +73 -0
- package/dist/program/hash.d.ts +4 -0
- package/dist/program/hash.d.ts.map +1 -0
- package/dist/program/hash.js +21 -0
- package/dist/program/hpke.d.ts +4 -0
- package/dist/program/hpke.d.ts.map +1 -0
- package/dist/program/hpke.js +111 -0
- package/dist/program/index.d.ts +7 -0
- package/dist/program/index.d.ts.map +1 -0
- package/dist/program/index.js +77 -0
- package/dist/program/io.d.ts +35 -0
- package/dist/program/io.d.ts.map +1 -0
- package/dist/program/io.js +65 -0
- package/dist/program/keygen.d.ts +4 -0
- package/dist/program/keygen.d.ts.map +1 -0
- package/dist/program/keygen.js +32 -0
- package/dist/program/kms.d.ts +8 -0
- package/dist/program/kms.d.ts.map +1 -0
- package/dist/program/kms.js +247 -0
- package/dist/program/opaque.d.ts +4 -0
- package/dist/program/opaque.d.ts.map +1 -0
- package/dist/program/opaque.js +209 -0
- package/dist/program/password.d.ts +4 -0
- package/dist/program/password.d.ts.map +1 -0
- package/dist/program/password.js +73 -0
- package/dist/program/secrets.d.ts +30 -0
- package/dist/program/secrets.d.ts.map +1 -0
- package/dist/program/secrets.js +70 -0
- package/dist/program/sign.d.ts +18 -0
- package/dist/program/sign.d.ts.map +1 -0
- package/dist/program/sign.js +130 -0
- package/dist/program/stream-multi.d.ts +7 -0
- package/dist/program/stream-multi.d.ts.map +1 -0
- package/dist/program/stream-multi.js +163 -0
- package/dist/program/stream.d.ts +6 -0
- package/dist/program/stream.d.ts.map +1 -0
- package/dist/program/stream.js +102 -0
- package/dist/program/usage.d.ts +7 -0
- package/dist/program/usage.d.ts.map +1 -0
- package/dist/program/usage.js +36 -0
- package/package.json +21 -34
|
@@ -46,75 +46,54 @@ const ALGORITHMS = [
|
|
|
46
46
|
"aes-256-gcm-siv",
|
|
47
47
|
"aes-128-gcm-siv",
|
|
48
48
|
];
|
|
49
|
+
const QUESTIONS = [
|
|
50
|
+
{
|
|
51
|
+
type: "select",
|
|
52
|
+
name: "algorithm",
|
|
53
|
+
message: "Select encryption algorithm",
|
|
54
|
+
choices: ALGORITHMS.map((a) => ({ title: a, value: a })),
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
type: "password",
|
|
58
|
+
name: "key",
|
|
59
|
+
message: "Encryption key (hex, 32 bytes / 64 hex chars)",
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
type: "text",
|
|
63
|
+
name: "plaintext",
|
|
64
|
+
message: "Plaintext to encrypt",
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
type: "select",
|
|
68
|
+
name: "outputFormat",
|
|
69
|
+
message: "Output format",
|
|
70
|
+
choices: [
|
|
71
|
+
{ title: "JSON", value: "json" },
|
|
72
|
+
{ title: "Hex ciphertext only", value: "hex" },
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
];
|
|
76
|
+
async function encryptWith(algorithm, key, plaintext) {
|
|
77
|
+
const lib = await Promise.resolve().then(() => __importStar(require("@sebastienrousseau/crypto-lib/modern")));
|
|
78
|
+
if (algorithm === "xchacha20-poly1305") {
|
|
79
|
+
return lib.aeadEncrypt({ key, plaintext });
|
|
80
|
+
}
|
|
81
|
+
if (algorithm.includes("siv")) {
|
|
82
|
+
return lib.aesGcmSivEncrypt({ key, plaintext });
|
|
83
|
+
}
|
|
84
|
+
return lib.aesGcmEncrypt({ key, plaintext });
|
|
85
|
+
}
|
|
49
86
|
const handleModernEncrypt = async () => {
|
|
50
|
-
const response = await (0, prompts_1.default)(
|
|
51
|
-
{
|
|
52
|
-
type: "select",
|
|
53
|
-
name: "algorithm",
|
|
54
|
-
message: "Select encryption algorithm",
|
|
55
|
-
choices: ALGORITHMS.map((a) => ({ title: a, value: a })),
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
type: "password",
|
|
59
|
-
name: "key",
|
|
60
|
-
message: "Encryption key (hex, 32 bytes / 64 hex chars)",
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
type: "text",
|
|
64
|
-
name: "plaintext",
|
|
65
|
-
message: "Plaintext to encrypt",
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
type: "select",
|
|
69
|
-
name: "outputFormat",
|
|
70
|
-
message: "Output format",
|
|
71
|
-
choices: [
|
|
72
|
-
{ title: "JSON", value: "json" },
|
|
73
|
-
{ title: "Hex ciphertext only", value: "hex" },
|
|
74
|
-
],
|
|
75
|
-
},
|
|
76
|
-
]);
|
|
87
|
+
const response = await (0, prompts_1.default)(QUESTIONS);
|
|
77
88
|
if (!response.algorithm || !response.key || !response.plaintext)
|
|
78
89
|
return;
|
|
79
90
|
try {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
key: response.key,
|
|
84
|
-
plaintext: response.plaintext,
|
|
85
|
-
});
|
|
86
|
-
if (response.outputFormat === "json") {
|
|
87
|
-
write_utils_1.writeUtils.writeLn(kleur_1.default.green(JSON.stringify(result, null, 2)));
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
write_utils_1.writeUtils.writeLn(kleur_1.default.green(result.ciphertext));
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
else if (response.algorithm.includes("siv")) {
|
|
94
|
-
const { aesGcmSivEncrypt } = await Promise.resolve().then(() => __importStar(require("@sebastienrousseau/crypto-lib/dist/modern/aes")));
|
|
95
|
-
const result = aesGcmSivEncrypt({
|
|
96
|
-
key: response.key,
|
|
97
|
-
plaintext: response.plaintext,
|
|
98
|
-
});
|
|
99
|
-
if (response.outputFormat === "json") {
|
|
100
|
-
write_utils_1.writeUtils.writeLn(kleur_1.default.green(JSON.stringify(result, null, 2)));
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
write_utils_1.writeUtils.writeLn(kleur_1.default.green(result.ciphertext));
|
|
104
|
-
}
|
|
91
|
+
const result = await encryptWith(response.algorithm, response.key, response.plaintext);
|
|
92
|
+
if (response.outputFormat === "json") {
|
|
93
|
+
write_utils_1.writeUtils.writeLn(kleur_1.default.green(JSON.stringify(result, null, 2)));
|
|
105
94
|
}
|
|
106
95
|
else {
|
|
107
|
-
|
|
108
|
-
const result = aesGcmEncrypt({
|
|
109
|
-
key: response.key,
|
|
110
|
-
plaintext: response.plaintext,
|
|
111
|
-
});
|
|
112
|
-
if (response.outputFormat === "json") {
|
|
113
|
-
write_utils_1.writeUtils.writeLn(kleur_1.default.green(JSON.stringify(result, null, 2)));
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
write_utils_1.writeUtils.writeLn(kleur_1.default.green(result.ciphertext));
|
|
117
|
-
}
|
|
96
|
+
write_utils_1.writeUtils.writeLn(kleur_1.default.green(result.ciphertext));
|
|
118
97
|
}
|
|
119
98
|
}
|
|
120
99
|
catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash.command.d.ts","sourceRoot":"","sources":["../../../src/commands/modern/hash.command.ts"],"names":[],"mappings":"AA4BA,QAAA,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"hash.command.d.ts","sourceRoot":"","sources":["../../../src/commands/modern/hash.command.ts"],"names":[],"mappings":"AA4BA,QAAA,MAAM,gBAAgB,qBAuCrB,CAAC;AAGF,eAAe,gBAAgB,CAAC"}
|
|
@@ -74,7 +74,7 @@ const handleModernHash = async () => {
|
|
|
74
74
|
if (!response.algorithm || !response.data)
|
|
75
75
|
return;
|
|
76
76
|
try {
|
|
77
|
-
const { hash } = await Promise.resolve().then(() => __importStar(require("@sebastienrousseau/crypto-lib/
|
|
77
|
+
const { hash } = await Promise.resolve().then(() => __importStar(require("@sebastienrousseau/crypto-lib/modern")));
|
|
78
78
|
const result = hash({ algorithm: response.algorithm, data: response.data });
|
|
79
79
|
if (response.outputFormat === "json") {
|
|
80
80
|
write_utils_1.writeUtils.writeLn(kleur_1.default.green(JSON.stringify(result, null, 2)));
|
|
@@ -88,7 +88,7 @@ const handleModernKeygen = async () => {
|
|
|
88
88
|
if (!response.algorithm)
|
|
89
89
|
return;
|
|
90
90
|
try {
|
|
91
|
-
const { generateKeyPair } = await Promise.resolve().then(() => __importStar(require("@sebastienrousseau/crypto-lib/
|
|
91
|
+
const { generateKeyPair } = await Promise.resolve().then(() => __importStar(require("@sebastienrousseau/crypto-lib/keys")));
|
|
92
92
|
const metadata = {};
|
|
93
93
|
if (response.kid)
|
|
94
94
|
metadata.kid = response.kid;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"password-hash.command.d.ts","sourceRoot":"","sources":["../../../src/commands/modern/password-hash.command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"password-hash.command.d.ts","sourceRoot":"","sources":["../../../src/commands/modern/password-hash.command.ts"],"names":[],"mappings":"AA6CA,QAAA,MAAM,kBAAkB,qBAiDvB,CAAC;AAGF,eAAe,kBAAkB,CAAC"}
|
|
@@ -39,37 +39,38 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
const prompts_1 = __importDefault(require("prompts"));
|
|
40
40
|
const write_utils_1 = require("../../utils/write.utils");
|
|
41
41
|
const kleur_1 = __importDefault(require("kleur"));
|
|
42
|
+
const QUESTIONS = [
|
|
43
|
+
{
|
|
44
|
+
type: "select",
|
|
45
|
+
name: "action",
|
|
46
|
+
message: "Action",
|
|
47
|
+
choices: [
|
|
48
|
+
{ title: "Hash password", value: "hash" },
|
|
49
|
+
{ title: "Verify password", value: "verify" },
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
type: "password",
|
|
54
|
+
name: "password",
|
|
55
|
+
message: "Password",
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
type: "select",
|
|
59
|
+
name: "variant",
|
|
60
|
+
message: "Argon2 variant",
|
|
61
|
+
choices: [
|
|
62
|
+
{ title: "argon2id (recommended)", value: "argon2id" },
|
|
63
|
+
{ title: "argon2i (side-channel resistant)", value: "argon2i" },
|
|
64
|
+
{ title: "argon2d (GPU resistant)", value: "argon2d" },
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
];
|
|
42
68
|
const handlePasswordHash = async () => {
|
|
43
|
-
const response = await (0, prompts_1.default)(
|
|
44
|
-
{
|
|
45
|
-
type: "select",
|
|
46
|
-
name: "action",
|
|
47
|
-
message: "Action",
|
|
48
|
-
choices: [
|
|
49
|
-
{ title: "Hash password", value: "hash" },
|
|
50
|
-
{ title: "Verify password", value: "verify" },
|
|
51
|
-
],
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
type: "password",
|
|
55
|
-
name: "password",
|
|
56
|
-
message: "Password",
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
type: "select",
|
|
60
|
-
name: "variant",
|
|
61
|
-
message: "Argon2 variant",
|
|
62
|
-
choices: [
|
|
63
|
-
{ title: "argon2id (recommended)", value: "argon2id" },
|
|
64
|
-
{ title: "argon2i (side-channel resistant)", value: "argon2i" },
|
|
65
|
-
{ title: "argon2d (GPU resistant)", value: "argon2d" },
|
|
66
|
-
],
|
|
67
|
-
},
|
|
68
|
-
]);
|
|
69
|
+
const response = await (0, prompts_1.default)(QUESTIONS);
|
|
69
70
|
if (!response.action || !response.password)
|
|
70
71
|
return;
|
|
71
72
|
try {
|
|
72
|
-
const { hashPassword, verifyPasswordPhc } = await Promise.resolve().then(() => __importStar(require("@sebastienrousseau/crypto-lib/
|
|
73
|
+
const { hashPassword, verifyPasswordPhc } = await Promise.resolve().then(() => __importStar(require("@sebastienrousseau/crypto-lib/modern")));
|
|
73
74
|
if (response.action === "hash") {
|
|
74
75
|
const result = hashPassword({
|
|
75
76
|
password: response.password,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sign.command.d.ts","sourceRoot":"","sources":["../../../src/commands/modern/sign.command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sign.command.d.ts","sourceRoot":"","sources":["../../../src/commands/modern/sign.command.ts"],"names":[],"mappings":"AAyIA,QAAA,MAAM,gBAAgB,qBAgBrB,CAAC;AAGF,eAAe,gBAAgB,CAAC"}
|
|
@@ -49,83 +49,93 @@ const ALGORITHMS = [
|
|
|
49
49
|
"ml-dsa-65",
|
|
50
50
|
"ml-dsa-87",
|
|
51
51
|
];
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
52
|
+
const QUESTIONS = [
|
|
53
|
+
{
|
|
54
|
+
type: "select",
|
|
55
|
+
name: "algorithm",
|
|
56
|
+
message: "Select signing algorithm",
|
|
57
|
+
choices: ALGORITHMS.map((a) => ({ title: a, value: a })),
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
type: "select",
|
|
61
|
+
name: "action",
|
|
62
|
+
message: "Action",
|
|
63
|
+
choices: [
|
|
64
|
+
{ title: "Generate key pair + sign", value: "keygen-sign" },
|
|
65
|
+
{ title: "Sign with existing key", value: "sign" },
|
|
66
|
+
{ title: "Verify signature", value: "verify" },
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
type: "text",
|
|
71
|
+
name: "message",
|
|
72
|
+
message: "Message to sign/verify",
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
const KEYGEN_ALGORITHM = {
|
|
76
|
+
"ecdsa-p256": "p256",
|
|
77
|
+
"ecdsa-p384": "p384",
|
|
78
|
+
};
|
|
79
|
+
function printJson(value) {
|
|
80
|
+
write_utils_1.writeUtils.writeLn(kleur_1.default.green(JSON.stringify(value, null, 2)));
|
|
81
|
+
}
|
|
82
|
+
async function keygenAndSign(crypto, algorithm, message) {
|
|
83
|
+
if (algorithm === "schnorr") {
|
|
84
|
+
const { generateSchnorrKeyPair } = await Promise.resolve().then(() => __importStar(require("@sebastienrousseau/crypto-lib/modern")));
|
|
85
|
+
const kp = generateSchnorrKeyPair();
|
|
86
|
+
const sig = crypto.sign("schnorr", kp.privateKey, message);
|
|
87
|
+
printJson({
|
|
88
|
+
publicKey: kp.publicKey,
|
|
89
|
+
privateKey: kp.privateKey,
|
|
90
|
+
signature: sig,
|
|
91
|
+
algorithm: "schnorr",
|
|
92
|
+
});
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const { generateKeyPair } = await Promise.resolve().then(() => __importStar(require("@sebastienrousseau/crypto-lib/keys")));
|
|
96
|
+
const keyAlgo = KEYGEN_ALGORITHM[algorithm] ?? algorithm;
|
|
97
|
+
const kp = generateKeyPair(keyAlgo);
|
|
98
|
+
const sig = crypto.sign(algorithm, kp.privateKey, message);
|
|
99
|
+
printJson({
|
|
100
|
+
publicKey: kp.publicKey,
|
|
101
|
+
privateKey: kp.privateKey,
|
|
102
|
+
signature: sig,
|
|
103
|
+
algorithm,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
async function signWithKey(crypto, algorithm, message) {
|
|
107
|
+
const keyResp = await (0, prompts_1.default)({
|
|
108
|
+
type: "password",
|
|
109
|
+
name: "privateKey",
|
|
110
|
+
message: "Private key (hex)",
|
|
111
|
+
});
|
|
112
|
+
if (!keyResp.privateKey)
|
|
113
|
+
return;
|
|
114
|
+
const sig = crypto.sign(algorithm, keyResp.privateKey, message);
|
|
115
|
+
printJson({ signature: sig, algorithm });
|
|
116
|
+
}
|
|
117
|
+
async function verifySignature(crypto, algorithm, message) {
|
|
118
|
+
const verifyResp = await (0, prompts_1.default)([
|
|
119
|
+
{ type: "text", name: "publicKey", message: "Public key (hex)" },
|
|
120
|
+
{ type: "text", name: "signature", message: "Signature (hex)" },
|
|
75
121
|
]);
|
|
122
|
+
if (!verifyResp.publicKey || !verifyResp.signature)
|
|
123
|
+
return;
|
|
124
|
+
const valid = crypto.verify(algorithm, verifyResp.publicKey, message, verifyResp.signature);
|
|
125
|
+
printJson({ valid, algorithm });
|
|
126
|
+
}
|
|
127
|
+
const handleModernSign = async () => {
|
|
128
|
+
const response = await (0, prompts_1.default)(QUESTIONS);
|
|
76
129
|
if (!response.algorithm || !response.action || !response.message)
|
|
77
130
|
return;
|
|
78
131
|
try {
|
|
79
|
-
const { crypto } = await Promise.resolve().then(() => __importStar(require("@sebastienrousseau/crypto-lib
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
keyAlgo = "p384";
|
|
87
|
-
if (keyAlgo === "schnorr") {
|
|
88
|
-
const { generateSchnorrKeyPair } = await Promise.resolve().then(() => __importStar(require("@sebastienrousseau/crypto-lib/dist/modern/curves")));
|
|
89
|
-
const kp = generateSchnorrKeyPair();
|
|
90
|
-
const sig = crypto.sign("schnorr", kp.privateKey, response.message);
|
|
91
|
-
write_utils_1.writeUtils.writeLn(kleur_1.default.green(JSON.stringify({
|
|
92
|
-
publicKey: kp.publicKey,
|
|
93
|
-
privateKey: kp.privateKey,
|
|
94
|
-
signature: sig,
|
|
95
|
-
algorithm: "schnorr",
|
|
96
|
-
}, null, 2)));
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
const kp = generateKeyPair(keyAlgo);
|
|
100
|
-
const sig = crypto.sign(response.algorithm, kp.privateKey, response.message);
|
|
101
|
-
write_utils_1.writeUtils.writeLn(kleur_1.default.green(JSON.stringify({
|
|
102
|
-
publicKey: kp.publicKey,
|
|
103
|
-
privateKey: kp.privateKey,
|
|
104
|
-
signature: sig,
|
|
105
|
-
algorithm: response.algorithm,
|
|
106
|
-
}, null, 2)));
|
|
107
|
-
}
|
|
108
|
-
else if (response.action === "sign") {
|
|
109
|
-
const keyResp = await (0, prompts_1.default)({
|
|
110
|
-
type: "password",
|
|
111
|
-
name: "privateKey",
|
|
112
|
-
message: "Private key (hex)",
|
|
113
|
-
});
|
|
114
|
-
if (!keyResp.privateKey)
|
|
115
|
-
return;
|
|
116
|
-
const sig = crypto.sign(response.algorithm, keyResp.privateKey, response.message);
|
|
117
|
-
write_utils_1.writeUtils.writeLn(kleur_1.default.green(JSON.stringify({ signature: sig, algorithm: response.algorithm }, null, 2)));
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
const verifyResp = await (0, prompts_1.default)([
|
|
121
|
-
{ type: "text", name: "publicKey", message: "Public key (hex)" },
|
|
122
|
-
{ type: "text", name: "signature", message: "Signature (hex)" },
|
|
123
|
-
]);
|
|
124
|
-
if (!verifyResp.publicKey || !verifyResp.signature)
|
|
125
|
-
return;
|
|
126
|
-
const valid = crypto.verify(response.algorithm, verifyResp.publicKey, response.message, verifyResp.signature);
|
|
127
|
-
write_utils_1.writeUtils.writeLn(kleur_1.default.green(JSON.stringify({ valid, algorithm: response.algorithm }, null, 2)));
|
|
128
|
-
}
|
|
132
|
+
const { crypto } = await Promise.resolve().then(() => __importStar(require("@sebastienrousseau/crypto-lib")));
|
|
133
|
+
let run = verifySignature;
|
|
134
|
+
if (response.action === "keygen-sign")
|
|
135
|
+
run = keygenAndSign;
|
|
136
|
+
else if (response.action === "sign")
|
|
137
|
+
run = signWithKey;
|
|
138
|
+
await run(crypto, response.algorithm, response.message);
|
|
129
139
|
}
|
|
130
140
|
catch (err) {
|
|
131
141
|
write_utils_1.writeUtils.writeLn(kleur_1.default.red(`Operation failed: ${err.message}`));
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
6
|
+
const pgp_1 = require("@sebastienrousseau/crypto-lib/pgp");
|
|
7
7
|
const prompts_1 = __importDefault(require("prompts"));
|
|
8
8
|
const handleReformat = async () => {
|
|
9
9
|
const responseReformat = await (0, prompts_1.default)([
|
|
@@ -49,7 +49,7 @@ const handleReformat = async () => {
|
|
|
49
49
|
console.error("\n🔔 You must provide a value for each of the properties.\n");
|
|
50
50
|
}
|
|
51
51
|
else {
|
|
52
|
-
await (0,
|
|
52
|
+
await (0, pgp_1.reformat)(data);
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
exports.default = handleReformat;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
6
|
+
const pgp_1 = require("@sebastienrousseau/crypto-lib/pgp");
|
|
7
7
|
const prompts_1 = __importDefault(require("prompts"));
|
|
8
8
|
const handleRevoke = async () => {
|
|
9
9
|
const responseRevoke = await (0, prompts_1.default)([
|
|
@@ -33,7 +33,7 @@ const handleRevoke = async () => {
|
|
|
33
33
|
console.error("\n🔔 You must provide a value for each of the properties.\n");
|
|
34
34
|
}
|
|
35
35
|
else {
|
|
36
|
-
await (0,
|
|
36
|
+
await (0, pgp_1.revoke)(data);
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
39
|
exports.default = handleRevoke;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
6
|
+
const pgp_1 = require("@sebastienrousseau/crypto-lib/pgp");
|
|
7
7
|
const prompts_1 = __importDefault(require("prompts"));
|
|
8
8
|
const handleSession = async () => {
|
|
9
9
|
const responseSession = await (0, prompts_1.default)([
|
|
@@ -35,7 +35,7 @@ const handleSession = async () => {
|
|
|
35
35
|
}
|
|
36
36
|
else {
|
|
37
37
|
console.log(data);
|
|
38
|
-
await (0,
|
|
38
|
+
await (0, pgp_1.session)(data);
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
exports.default = handleSession;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
6
|
+
const pgp_1 = require("@sebastienrousseau/crypto-lib/pgp");
|
|
7
7
|
const prompts_1 = __importDefault(require("prompts"));
|
|
8
8
|
const handleSign = async () => {
|
|
9
9
|
const responseSign = await (0, prompts_1.default)([
|
|
@@ -42,7 +42,7 @@ const handleSign = async () => {
|
|
|
42
42
|
console.error("\n🔔 You must provide a value for each of the properties.\n");
|
|
43
43
|
}
|
|
44
44
|
else {
|
|
45
|
-
await (0,
|
|
45
|
+
await (0, pgp_1.sign)(data);
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
exports.default = handleSign;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
6
|
+
const pgp_1 = require("@sebastienrousseau/crypto-lib/pgp");
|
|
7
7
|
const prompts_1 = __importDefault(require("prompts"));
|
|
8
8
|
const handleVerify = async () => {
|
|
9
9
|
const responseVerify = await (0, prompts_1.default)([
|
|
@@ -35,7 +35,7 @@ const handleVerify = async () => {
|
|
|
35
35
|
}
|
|
36
36
|
else {
|
|
37
37
|
console.log(data);
|
|
38
|
-
await (0,
|
|
38
|
+
await (0, pgp_1.verify)(data);
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
exports.default = handleVerify;
|
package/dist/menu.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Command } from "./commands/index";
|
|
2
|
+
type Handler = keyof typeof Command;
|
|
3
|
+
export interface MenuEntry {
|
|
4
|
+
title: string;
|
|
5
|
+
description: string;
|
|
6
|
+
heading: string;
|
|
7
|
+
handler: Handler;
|
|
8
|
+
}
|
|
9
|
+
export declare const menuEntries: () => MenuEntry[];
|
|
10
|
+
export declare const runMenu: () => Promise<void>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=menu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu.d.ts","sourceRoot":"","sources":["../src/menu.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAM3C,KAAK,OAAO,GAAG,MAAM,OAAO,OAAO,CAAC;AAGpC,MAAM,WAAW,SAAS;IAExB,KAAK,EAAE,MAAM,CAAC;IAEd,WAAW,EAAE,MAAM,CAAC;IAEpB,OAAO,EAAE,MAAM,CAAC;IAEhB,OAAO,EAAE,OAAO,CAAC;CAClB;AA0DD,eAAO,MAAM,WAAW,QAAO,SAAS,EAcvC,CAAC;AAMF,eAAO,MAAM,OAAO,QAAa,OAAO,CAAC,IAAI,CA8B5C,CAAC"}
|
package/dist/menu.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.runMenu = exports.menuEntries = void 0;
|
|
7
|
+
const kleur_1 = __importDefault(require("kleur"));
|
|
8
|
+
const prompts_1 = __importDefault(require("prompts"));
|
|
9
|
+
const index_1 = require("./commands/index");
|
|
10
|
+
const index_2 = require("./constants/index");
|
|
11
|
+
const banner_1 = require("./helpers/banner");
|
|
12
|
+
const write_utils_1 = require("./utils/write.utils");
|
|
13
|
+
const LEGACY = [
|
|
14
|
+
[1, "handleGenerate"],
|
|
15
|
+
[2, "handleEncrypt"],
|
|
16
|
+
[3, "handleDecrypt"],
|
|
17
|
+
[4, "handleReformat"],
|
|
18
|
+
[5, "handleRevoke"],
|
|
19
|
+
[6, "handleSession"],
|
|
20
|
+
[7, "handleSign"],
|
|
21
|
+
[8, "handleVerify"],
|
|
22
|
+
];
|
|
23
|
+
const MODERN = [
|
|
24
|
+
{
|
|
25
|
+
title: "Modern Keygen",
|
|
26
|
+
description: "Generate keys (Ed25519, ML-DSA, ML-KEM, P-256, etc.)",
|
|
27
|
+
heading: "Modern Key Generation",
|
|
28
|
+
handler: "handleModernKeygen",
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
title: "Modern Hash",
|
|
32
|
+
description: "Hash data (SHA-2, SHA-3, BLAKE2b, BLAKE3)",
|
|
33
|
+
heading: "Modern Hashing",
|
|
34
|
+
handler: "handleModernHash",
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
title: "Modern Encrypt",
|
|
38
|
+
description: "Encrypt (XChaCha20, AES-GCM, AES-GCM-SIV)",
|
|
39
|
+
heading: "Modern Encryption",
|
|
40
|
+
handler: "handleModernEncrypt",
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
title: "Modern Sign",
|
|
44
|
+
description: "Sign/verify (Ed25519, ECDSA, Schnorr, ML-DSA)",
|
|
45
|
+
heading: "Modern Signing",
|
|
46
|
+
handler: "handleModernSign",
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
title: "Password Hash",
|
|
50
|
+
description: "Hash/verify passwords (Argon2id/i/d)",
|
|
51
|
+
heading: "Password Hashing (Argon2)",
|
|
52
|
+
handler: "handlePasswordHash",
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
title: "CBOM",
|
|
56
|
+
description: "Generate or audit Cryptographic Bill of Materials",
|
|
57
|
+
heading: "Cryptographic Bill of Materials (CBOM)",
|
|
58
|
+
handler: "handleModernCbom",
|
|
59
|
+
},
|
|
60
|
+
];
|
|
61
|
+
const menuEntries = () => [
|
|
62
|
+
...LEGACY.map(([n, handler]) => ({
|
|
63
|
+
title: index_2.constants[`CLI_FN_${n}_TTL`],
|
|
64
|
+
description: index_2.constants[`CLI_FN_${n}_DES`],
|
|
65
|
+
heading: index_2.constants.CLI_HDL_1_DES,
|
|
66
|
+
handler,
|
|
67
|
+
})),
|
|
68
|
+
...MODERN,
|
|
69
|
+
{
|
|
70
|
+
title: index_2.constants.CLI_FN_9_TTL,
|
|
71
|
+
description: index_2.constants.CLI_FN_9_DES,
|
|
72
|
+
heading: index_2.constants.CLI_FN_9_TTL,
|
|
73
|
+
handler: "handleHelp",
|
|
74
|
+
},
|
|
75
|
+
];
|
|
76
|
+
exports.menuEntries = menuEntries;
|
|
77
|
+
const runMenu = async () => {
|
|
78
|
+
(0, index_2.language)(index_2.locale);
|
|
79
|
+
console.clear();
|
|
80
|
+
(0, banner_1.welcome)(index_2.constants.CLI_TITLE);
|
|
81
|
+
write_utils_1.writeUtils.writeLn(index_2.constants.CLI_TITLE);
|
|
82
|
+
write_utils_1.writeUtils.writeLn("");
|
|
83
|
+
write_utils_1.writeUtils.writeLn(index_2.constants.CLI_DESCRIPTION);
|
|
84
|
+
write_utils_1.writeUtils.writeLn("");
|
|
85
|
+
const entries = (0, exports.menuEntries)();
|
|
86
|
+
const response = await (0, prompts_1.default)({
|
|
87
|
+
type: "select",
|
|
88
|
+
name: index_2.constants.PROMPT_SELECT_TTL,
|
|
89
|
+
message: index_2.constants.PROMPT_SELECT_DES + "\n\n",
|
|
90
|
+
choices: entries.map(({ title, description }) => ({
|
|
91
|
+
title,
|
|
92
|
+
description,
|
|
93
|
+
value: title,
|
|
94
|
+
})),
|
|
95
|
+
});
|
|
96
|
+
const selected = response[index_2.constants.PROMPT_SELECT_TTL];
|
|
97
|
+
const entry = entries.find((e) => e.title === selected);
|
|
98
|
+
write_utils_1.writeUtils.writeLn("");
|
|
99
|
+
if (!entry) {
|
|
100
|
+
write_utils_1.writeUtils.writeLn(kleur_1.default.red(index_2.constants.CLI_ERR_1));
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
write_utils_1.writeUtils.writeLn(kleur_1.default.green(entry.heading));
|
|
104
|
+
await index_1.Command[entry.handler]();
|
|
105
|
+
};
|
|
106
|
+
exports.runMenu = runMenu;
|
|
107
|
+
//# sourceMappingURL=menu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cbom.d.ts","sourceRoot":"","sources":["../../src/program/cbom.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAC;AAO5C,OAAO,EAAyB,KAAK,UAAU,EAAE,MAAM,MAAM,CAAC;AAiF9D,eAAO,MAAM,YAAY,GAAI,SAAS,OAAO,EAAE,KAAK,UAAU,YAQ7D,CAAC"}
|