summaryrefslogtreecommitdiffstats
path: root/Cryptor.cpp
diff options
context:
space:
mode:
authorMalfurious <m@lfurio.us>2024-10-24 08:44:36 -0400
committerMalfurious <m@lfurio.us>2024-10-25 03:31:18 -0400
commit6285b4d8b283fb38112ec04b1cc570a8c0c9844b (patch)
tree765bd8b0334bd4781e804258a7b7f57925fc3e3b /Cryptor.cpp
parent512aa4c77b3dc0d72db713a9215ff65a98a99ec3 (diff)
downloadcompass-6285b4d8b283fb38112ec04b1cc570a8c0c9844b.tar.gz
compass-6285b4d8b283fb38112ec04b1cc570a8c0c9844b.zip
Remove Socket class
The remote socket functionality was only stub code, never fully implemented. A network architecture for compass keychains is no longer a design goal, so the dead code is removed. Signed-off-by: Malfurious <m@lfurio.us>
Diffstat (limited to 'Cryptor.cpp')
-rw-r--r--Cryptor.cpp66
1 files changed, 18 insertions, 48 deletions
diff --git a/Cryptor.cpp b/Cryptor.cpp
index 9db2bdc..1cce31e 100644
--- a/Cryptor.cpp
+++ b/Cryptor.cpp
@@ -61,62 +61,32 @@ void Cryptor::encryptAndSave(std::string remoteHost, std::string port, std::stri
delete[] encCipher;
delete[] ciphertext;
- if (remoteHost == "") {
- if (directory[directory.size() - 1] != '/') {
- directory += "/";
- }
- directory += KEYCHAIN_FILE;
- std::ofstream f(directory.c_str());
- f << _encIV << std::endl;
- f << _encCipher << std::endl;
- f.close();
- } else {
- Socket s;
- std::string err = "";
- s.conn(remoteHost, port);
- s.sendline("store");
- s.sendline(directory);
- s.sendline(_encIV);
- s.sendline(_encCipher);
- err = s.readline();
- s.clo();
- if (err != "OK") {
- throw 1;
- }
+ if (directory[directory.size() - 1] != '/') {
+ directory += "/";
}
+ directory += KEYCHAIN_FILE;
+ std::ofstream f(directory.c_str());
+ f << _encIV << std::endl;
+ f << _encCipher << std::endl;
+ f.close();
}
std::string Cryptor::loadAndDecrypt(std::string remoteHost, std::string port, std::string directory) {
// Load Data
std::string encIV, encCipher;
- if (remoteHost == "") {
- if (directory[directory.size() - 1] != '/') {
- directory += "/";
- }
- directory += KEYCHAIN_FILE;
- std::ifstream f(directory.c_str());
- if (!f.good()) {
- f.close();
- throw 1;
- }
- f >> encIV;
- f >> encCipher;
+
+ if (directory[directory.size() - 1] != '/') {
+ directory += "/";
+ }
+ directory += KEYCHAIN_FILE;
+ std::ifstream f(directory.c_str());
+ if (!f.good()) {
f.close();
- } else {
- Socket s;
- std::string err = "";
- s.conn(remoteHost, port);
- s.sendline("fetch");
- s.sendline(directory);
- err = s.readline();
- if (err != "OK") {
- s.clo();
- throw 1;
- }
- encIV = s.readline();
- encCipher = s.readline();
- s.clo();
+ throw 1;
}
+ f >> encIV;
+ f >> encCipher;
+ f.close();
// Decode data
unsigned char *ciphertext = new unsigned char[encCipher.size() / 2];