diff options
author | Malfurious <m@lfurio.us> | 2024-10-24 06:44:24 -0400 |
---|---|---|
committer | Malfurious <m@lfurio.us> | 2024-10-24 06:44:24 -0400 |
commit | 512aa4c77b3dc0d72db713a9215ff65a98a99ec3 (patch) | |
tree | 6db82e0109dc987b5b021f81d4e8a0926eb75ff7 /Cryptor.h | |
parent | 428471d39fb8c205a9fad899c88c30a2cb7df685 (diff) | |
parent | 10affea371406c0ae4c080e5a19390a8e9bd154b (diff) | |
download | compass-512aa4c77b3dc0d72db713a9215ff65a98a99ec3.tar.gz compass-512aa4c77b3dc0d72db713a9215ff65a98a99ec3.zip |
Merge branch 'mbedtls'
Replace Crypto++ 5.6.2 with Mbed TLS 3.6.0
Newer compilers are starting to show the age of the crypto library we've
been using, as it is sometimes a pain to recompile compass lately. So,
the tracked version of Crypto++ was at least due for an upgrade.
However, I plan to soon begin reimplementing compass in C. So, I'm
taking this opportunity to first just migrate the cryptography library
to a newer C alternative. This branch does so, and integrates its use
into the current C++ version of compass.
* mbedtls:
Remove unnecessary exception handler catch block
Refactor random password generation to use mbedtls entropy source
Refactor SHA256 function to use mbedtls
Refactor AES functions to use mbedtls
Add Mbedtls library
Remove Crypto++ library
Diffstat (limited to 'Cryptor.h')
-rw-r--r-- | Cryptor.h | 16 |
1 files changed, 9 insertions, 7 deletions
@@ -4,6 +4,7 @@ #include <iostream>
#include <string>
#include <fstream>
+#include <vector>
#ifdef WIN32
#include <windows.h>
@@ -12,17 +13,17 @@ #include <unistd.h>
#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 "mbedtls/cipher.h"
+#include "mbedtls/ctr_drbg.h"
+#include "mbedtls/entropy.h"
+#include "mbedtls/sha256.h"
#include "Socket.h"
#define DEF_PASSWD_LENGTH 50
+#define AES_BLOCK_LENGTH 16
+
#define KEYCHAIN_FILE ".compasskeychain"
#define PASSWORD_PROMPT "ComPASS Password: "
#define PASSWORD_CONF "Confirm Password: "
@@ -49,9 +50,10 @@ public: private:
static bool haveKey;
- static unsigned char key[CryptoPP::AES::DEFAULT_KEYLENGTH];
+ static unsigned char key[AES_BLOCK_LENGTH];
static void sha256(std::string str);
+ static void generateRandom(void *output, size_t size);
static std::string readPassword(bool confirm);
static std::string readPassword();
static void assembleKey(bool confirm);
|