Adjust cli parameter definitions
This commit is contained in:
parent
0f46ed7115
commit
f28e510dba
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
build/
|
||||
*.swp
|
||||
*_/
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
#pragma once
|
||||
#define GHETTOCRYPTCLI_VERSION 0.1241
|
||||
#ifndef GCRYPTCLI_VERSION_H
|
||||
#define GCRYPTCLI_VERSION_H
|
||||
|
||||
#define GCRYPTCLI_VERSION 0.1241
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -12,10 +12,10 @@ void CommandlineInterface::Init(int argc, const char* const* argv)
|
||||
{
|
||||
/* General information */
|
||||
std::stringstream ss;
|
||||
ss << "CLI for the gcrypt cipher/obfuscator" << std::endl
|
||||
ss << "CLI for the GCrypt cipher/obfuscator" << std::endl
|
||||
<< "Copyright (c) 2022 Leon Etienne" << std::endl
|
||||
<< "GCrypt v" << GHETTOCRYPT_VERSION << std::endl
|
||||
<< "GCrypt CLI v" << GHETTOCRYPTCLI_VERSION << std::endl
|
||||
<< "GCrypt v" << GCRYPT_VERSION << std::endl
|
||||
<< "GCrypt CLI v" << GCRYPTCLI_VERSION << std::endl
|
||||
<< "THIS IS EXPERIMENTAL SOFTWARE AND MUST BE CONSIDERED INSECURE. DO NOT USE THIS TO ENCRYPT SENSITIVE DATA! READ THE README FILES ACCESSIBLE AT \"https://gitea.leonetienne.de/leonetienne/GCrypt\"";
|
||||
nupp.SetBriefDescription(ss.str());
|
||||
ss.str("");
|
||||
@ -28,29 +28,29 @@ void CommandlineInterface::Init(int argc, const char* const* argv)
|
||||
nupp.RegisterAbbreviation("-e", "--encrypt");
|
||||
|
||||
nupp.RegisterDescription("--decrypt", "Use decryption routine.");
|
||||
nupp.RegisterConstraint("--decrypt", ParamConstraint(true, DATA_TYPE::VOID, {}, false, { "--encrypt", "--hash" }));
|
||||
nupp.RegisterConstraint("--decrypt", ParamConstraint(true, DATA_TYPE::VOID, {}, false, { "--encrypt", "--hash", "--generate-keyfile" }));
|
||||
nupp.RegisterAbbreviation("-d", "--decrypt");
|
||||
|
||||
nupp.RegisterDescription("--hash", "Use the ghetto cipher as a hash digest.");
|
||||
nupp.RegisterConstraint("--hash", ParamConstraint(true, DATA_TYPE::VOID, {}, false, { "--encrypt", "--decrypt" }));
|
||||
nupp.RegisterDescription("--hash", "Use the GHash hash function to calculate a hashsum.");
|
||||
nupp.RegisterConstraint("--hash", ParamConstraint(true, DATA_TYPE::VOID, {}, false, { "--encrypt", "--decrypt", "--generate-keyfile" }));
|
||||
nupp.RegisterAbbreviation("-h", "--hash");
|
||||
|
||||
nupp.RegisterDescription("--intext", "Encrypt this string. Dumps to stdout.");
|
||||
nupp.RegisterDescription("--generate-keyfile", "Will generate a random keyfile, and exit.");
|
||||
nupp.RegisterConstraint("--generate-keyfile", ParamConstraint(true, DATA_TYPE::STRING, { "--encrypt", "--decrypt", "--hash" }, false, {}));
|
||||
|
||||
nupp.RegisterDescription("--intext", "Encrypt this string.");
|
||||
nupp.RegisterConstraint("--intext", ParamConstraint(true, DATA_TYPE::STRING, {}, false, { "--infile" }));
|
||||
nupp.RegisterAbbreviation("-it", "--intext");
|
||||
|
||||
nupp.RegisterDescription("--infile", "Encrypt this file. Saves as {filename}.crypt, if not specified otherwise.");
|
||||
nupp.RegisterDescription("--infile", "Encrypt this file.");
|
||||
nupp.RegisterConstraint("--infile", ParamConstraint(true, DATA_TYPE::STRING, {}, false, { "--intext" }));
|
||||
nupp.RegisterAbbreviation("-if", "--infile");
|
||||
|
||||
nupp.RegisterDescription("--ofile", "Use this filename for output if --infile is specified. Gets ignored otherwise.");
|
||||
nupp.RegisterDescription("--ofile", "Write output in this file.");
|
||||
nupp.RegisterConstraint("--ofile", ParamConstraint(true, DATA_TYPE::STRING, {}, false, { "--ostdout", "--hash" }));
|
||||
nupp.RegisterAbbreviation("-of", "--ofile");
|
||||
nupp.RegisterAbbreviation("-o", "--ofile");
|
||||
|
||||
nupp.RegisterDescription("--ostdout", "Output of digested files will be dumped to stdout instead of a file.");
|
||||
nupp.RegisterConstraint("--ostdout", ParamConstraint(true, DATA_TYPE::VOID, {}, false, { "--ofile", "--hash" }));
|
||||
|
||||
nupp.RegisterDescription("--key", "Use this value as a password to extrapolate the encryption key. WARNING: Arguments may be logged by the system!");
|
||||
nupp.RegisterConstraint("--key", ParamConstraint(true, DATA_TYPE::STRING, {}, false, { "--keyfile", "--keyask", "--hash" }));
|
||||
nupp.RegisterAbbreviation("-k", "--key");
|
||||
@ -69,30 +69,42 @@ void CommandlineInterface::Init(int argc, const char* const* argv)
|
||||
nupp.RegisterConstraint("--progress", ParamConstraint(true, DATA_TYPE::VOID, {}, false, {}));
|
||||
nupp.RegisterAbbreviation("-p", "--progress");
|
||||
|
||||
nupp.RegisterDescription("--iobase-bytes", "Interpret and output ciphertexts as raw bytes.");
|
||||
nupp.RegisterConstraint("--iobase-bytes", ParamConstraint(true, DATA_TYPE::VOID, {}, false, { "--iobase-2", "--iobase-8", "--iobase-10", "--iobase-16", "--iobase-64", "--iobase-uwu", "--iobase-ugh" }));
|
||||
|
||||
nupp.RegisterDescription("--iobase-2", "Interpret and format ciphertexts in base2");
|
||||
nupp.RegisterConstraint("--iobase-2", ParamConstraint(true, DATA_TYPE::VOID, {}, false, { "--iobase-8", "--iobase-10", "--iobase-64", "--iobase-uwu", "--iobase-ugh" }));
|
||||
nupp.RegisterConstraint("--iobase-2", ParamConstraint(true, DATA_TYPE::VOID, {}, false, { "--iobase-bytes", "--iobase-8", "--iobase-10", "--iobase-16",, "--iobase-64", "--iobase-uwu", "--iobase-ugh" }));
|
||||
|
||||
nupp.RegisterDescription("--iobase-8", "Interpret and format ciphertexts in base8");
|
||||
nupp.RegisterConstraint("--iobase-8", ParamConstraint(true, DATA_TYPE::VOID, {}, false, { "--iobase-2", "--iobase-10", "--iobase-64", "--iobase-uwu", "--iobase-ugh" }));
|
||||
nupp.RegisterConstraint("--iobase-8", ParamConstraint(true, DATA_TYPE::VOID, {}, false, { "--iobase-bytes", "--iobase-2", "--iobase-10", "--iobase-16",, "--iobase-64", "--iobase-uwu", "--iobase-ugh" }));
|
||||
|
||||
nupp.RegisterDescription("--iobase-10", "Interpret and format ciphertexts in base10");
|
||||
nupp.RegisterConstraint("--iobase-10", ParamConstraint(true, DATA_TYPE::VOID, {}, false, { "--iobase-2", "--iobase-8", "--iobase-64", "--iobase-uwu", "--iobase-ugh" }));
|
||||
nupp.RegisterConstraint("--iobase-10", ParamConstraint(true, DATA_TYPE::VOID, {}, false, { "--iobase-bytes", "--iobase-2", "--iobase-8", "--iobase-16",, "--iobase-64", "--iobase-uwu", "--iobase-ugh" }));
|
||||
|
||||
nupp.RegisterDescription("--iobase-16", "Interpret and format ciphertexts in base16 (hex)");
|
||||
nupp.RegisterConstraint("--iobase-16", ParamConstraint(true, DATA_TYPE::VOID, {}, false, { "--iobase-bytes", "--iobase-2", "--iobase-8", "--iobase-64", "--iobase-uwu", "--iobase-ugh" }));
|
||||
|
||||
nupp.RegisterDescription("--iobase-64", "Interpret and format ciphertexts in base64");
|
||||
nupp.RegisterConstraint("--iobase-64", ParamConstraint(true, DATA_TYPE::VOID, {}, false, { "--iobase-2", "--iobase-8", "--iobase-10", "--iobase-uwu", "--iobase-ugh" }));
|
||||
nupp.RegisterConstraint("--iobase-64", ParamConstraint(true, DATA_TYPE::VOID, {}, false, { "--iobase-bytes", "--iobase-2", "--iobase-8", "--iobase-10", "--iobase-16",, "--iobase-uwu", "--iobase-ugh" }));
|
||||
|
||||
nupp.RegisterDescription("--iobase-uwu", "Interpret and format ciphertexts in base uwu");
|
||||
nupp.RegisterConstraint("--iobase-uwu", ParamConstraint(true, DATA_TYPE::VOID, {}, false, { "--iobase-2", "--iobase-8", "--iobase-10", "--iobase-64", "--iobase-ugh" }));
|
||||
nupp.RegisterConstraint("--iobase-uwu", ParamConstraint(true, DATA_TYPE::VOID, {}, false, { "--iobase-bytes", "--iobase-2", "--iobase-8", "--iobase-10", "--iobase-16",, "--iobase-64", "--iobase-ugh" }));
|
||||
|
||||
nupp.RegisterDescription("--iobase-ugh", "Interpret and format ciphertexts in base ugh");
|
||||
nupp.RegisterConstraint("--iobase-ugh", ParamConstraint(true, DATA_TYPE::VOID, {}, false, { "--iobase-2", "--iobase-8", "--iobase-10", "--iobase-64", "--iobase-uwu" }));
|
||||
nupp.RegisterConstraint("--iobase-ugh", ParamConstraint(true, DATA_TYPE::VOID, {}, false, { "--iobase-bytes", "--iobase-2", "--iobase-8", "--iobase-10", "--iobase-16",, "--iobase-64", "--iobase-uwu" }));
|
||||
|
||||
nupp.RegisterDescription("--version", "Will supply the version of ghettocrypt used.");
|
||||
nupp.RegisterConstraint("--version", ParamConstraint(true, DATA_TYPE::VOID, {}, false, {}));
|
||||
nupp.RegisterAbbreviation("-v", "--version");
|
||||
nupp.RegisterDescription("--lib-version", "Will supply the version of GCryptLib used.");
|
||||
nupp.RegisterConstraint("--lib-version", ParamConstraint(true, DATA_TYPE::VOID, {}, false, {}));
|
||||
|
||||
nupp.RegisterDescription("--cli-version", "Will supply the version of ghettocrypt-cli used.");
|
||||
nupp.RegisterDescription("--cli-version", "Will supply the version of GCryptCLI used.");
|
||||
nupp.RegisterConstraint("--cli-version", ParamConstraint(true, DATA_TYPE::VOID, {}, false, {}));
|
||||
nupp.RegisterAbbreviation("-v", "--cli-version");
|
||||
|
||||
nupp.RegisterDescription("--puffer-input", "Will read the entire input before beginning any digestion.");
|
||||
nupp.RegisterConstraint("--puffer-input", ParamConstraint(true, DATA_TYPE::VOID, {}, false, {}));
|
||||
|
||||
nupp.RegisterDescription("--puffer-output", "Will digest the entire data before initiating any output.");
|
||||
nupp.RegisterConstraint("--puffer-output", ParamConstraint(true, DATA_TYPE::VOID, {}, false, {}));
|
||||
|
||||
/* Now parse */
|
||||
nupp.Parse(argc, argv);
|
||||
@ -111,31 +123,24 @@ Hazelnp::CmdArgsInterface& CommandlineInterface::Get()
|
||||
void CommandlineInterface::SpecialCompatibilityChecking()
|
||||
{
|
||||
// Encryption key
|
||||
// Do we have EITHER --hash (no key required), --key, --keyask or --keyfile given?
|
||||
// Do we have EITHER --hash (no key required), --generate-keyfile (no key required), --key, --keyask or --keyfile given?
|
||||
if (
|
||||
(!nupp.HasParam("--hash")) &&
|
||||
(!nupp.HasParam("--generate-keyfile")) &&
|
||||
(!nupp.HasParam("--key")) &&
|
||||
(!nupp.HasParam("--keyfile")) &&
|
||||
(!nupp.HasParam("--keyask"))
|
||||
)
|
||||
CrashWithMsg("No encryption key supplied! Please supply either --key, --keyfile, or --keyask!");
|
||||
|
||||
// Encryption input
|
||||
// Do we have EITHER --intext or --infile?
|
||||
if (
|
||||
(!nupp.HasParam("--intext")) &&
|
||||
(!nupp.HasParam("--infile"))
|
||||
)
|
||||
CrashWithMsg("No encryption input supplied! Please supply either --intext or --infile!");
|
||||
|
||||
// Encryption mode
|
||||
// Digestion mode
|
||||
// Do we have EITHER --encrypt or --decrypt or --hash?
|
||||
if (
|
||||
(!nupp.HasParam("--hash")) &&
|
||||
(!nupp.HasParam("--encrypt")) &&
|
||||
(!nupp.HasParam("--decrypt"))
|
||||
)
|
||||
CrashWithMsg("No encryption mode supplied! Please supply either --encrypt, --decrypt, or --hash!");
|
||||
CrashWithMsg("No digestion mode supplied! Please supply either --encrypt, --decrypt, or --hash!");
|
||||
|
||||
return;
|
||||
}
|
||||
@ -153,14 +158,16 @@ void CommandlineInterface::CrashWithMsg(const std::string& msg)
|
||||
|
||||
void CommandlineInterface::CatchVersionQueries()
|
||||
{
|
||||
if (nupp.HasParam("--version"))
|
||||
{
|
||||
std::cout << GHETTOCRYPT_VERSION << std::endl;
|
||||
if (
|
||||
(nupp.HasParam("--version")) ||
|
||||
(nupp.HasParam("--cli-version")
|
||||
) {
|
||||
std::cout << GCRYPTCLI_VERSION << std::endl;
|
||||
exit(0);
|
||||
}
|
||||
else if (nupp.HasParam("--cli-version"))
|
||||
else if (nupp.HasParam("--lib-version"))
|
||||
{
|
||||
std::cout << GHETTOCRYPTCLI_VERSION << std::endl;
|
||||
std::cout << GCRYPT_VERSION << std::endl;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user