From 490d36e65ac24e34e3021c2a0947384aee138c88 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Wed, 13 Apr 2016 21:05:14 -0400 Subject: Root commit for new Compass repository This is the Alpha version of ComPASS, originally developed sometime in 2014. --- Cryptor.h | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 Cryptor.h (limited to 'Cryptor.h') diff --git a/Cryptor.h b/Cryptor.h new file mode 100644 index 0000000..8ba1c16 --- /dev/null +++ b/Cryptor.h @@ -0,0 +1,62 @@ +#ifndef CRYPTOR_H +#define CRYPTOR_H + +#include +#include +#include + +#ifdef WIN32 +#include +#else +#include +#include +#endif // WIN32 + +#include "cryptopp562/osrng.h" +#include "cryptopp562/cryptlib.h" +#include "cryptopp562/hex.h" +#include "cryptopp562/filters.h" +#include "cryptopp562/aes.h" +#include "cryptopp562/ccm.h" + +#include "Socket.h" + +#define DEF_PASSWD_LENGTH 50 + +#define KEYCHAIN_FILE ".compasskeychain" +#define PASSWORD_PROMPT "ComPASS Password: " +#define PASSWORD_CONF "Confirm Password: " +#define PASSWORD_ERROR "Passwords do not match..." + +struct PasswordSpec { + PasswordSpec() { // Default Values + ml = DEF_PASSWD_LENGTH; + ns = nc = nn = false; + } + + int ml; // max length + bool ns; // no special chars + bool nc; // no caps + bool nn; // no numeric chars +}; + +class Cryptor { +public: + static void encryptAndSave(std::string remoteHost, std::string port, std::string directory, std::string payload); + static std::string loadAndDecrypt(std::string remoteHost, std::string port, std::string directory); + static std::string createRandomPassword(PasswordSpec spec); + static void rekey(); + +private: + static bool haveKey; + static unsigned char key[CryptoPP::AES::DEFAULT_KEYLENGTH]; + + static void sha256(std::string str); + static std::string readPassword(bool confirm); + static std::string readPassword(); + static void assembleKey(bool confirm); + static void assembleKey(); + static std::string promptPassword(bool confirm); +}; + +#endif // CRYPTOR_H -- cgit v1.2.3