summaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--CMakeLists.txt1
-rw-r--r--Cryptor.cpp66
-rw-r--r--Cryptor.h3
-rw-r--r--Socket.cpp46
-rw-r--r--Socket.h29
5 files changed, 19 insertions, 126 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e0fd0a8..263cd58 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,7 +13,6 @@ add_executable(compass
Help.cpp
Keychain.cpp
Options.cpp
- Socket.cpp
)
target_link_libraries(compass mbedtls)
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];
diff --git a/Cryptor.h b/Cryptor.h
index f1448b0..94af673 100644
--- a/Cryptor.h
+++ b/Cryptor.h
@@ -5,6 +5,7 @@
#include <string>
#include <fstream>
#include <vector>
+#include <cstring>
#ifdef WIN32
#include <windows.h>
@@ -18,8 +19,6 @@
#include "mbedtls/entropy.h"
#include "mbedtls/sha256.h"
-#include "Socket.h"
-
#define DEF_PASSWD_LENGTH 50
#define AES_BLOCK_LENGTH 16
diff --git a/Socket.cpp b/Socket.cpp
deleted file mode 100644
index c90a607..0000000
--- a/Socket.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-#include "Socket.h"
-
-Socket::Socket() {
- /*memset(&hostInfo, 0, sizeof(hostInfo));
- hostInfo.ai_family = AF_UNSPEC;
- hostInfo.ai_socktype = SOCK_STREAM;*/
-}
-
-Socket::~Socket() {
- /*freeaddrinfo(hostInfoList);
- clo();*/
-}
-
-void Socket::conn(std::string host, std::string port) {
- throw 1;
- /*int status;
- status = getaddrinfo(host.c_str(), port.c_str(), &hostInfo, &hostInfoList);
- if (status) throw 1;
-
- sockid = socket(hostInfoList->ai_family, hostInfoList->ai_socktype, hostInfoList->ai_protocol);
- if (sockid == -1) throw 1;
-
- status = connect(sockid, hostInfoList->ai_addr, hostInfoList->ai_addrlen);
- if (status) throw 1;*/
-}
-
-void Socket::sendline(std::string line) {
- throw 1;
- /*ssize_t bytesSent;
-
- do {
- int len = line.size();
- bytesSent = send(sockid, line.c_str(), len, 0);
-
- line = line.substr(bytesSent, line.size() - bytesSent);
- } while (line.size() > 0);
-
- send(sockid, "\n", 1, 0); // add \n*/
-}
-
-std::string Socket::readline() {
- throw 1;
-}
-
-void Socket::clo() {
-}
diff --git a/Socket.h b/Socket.h
deleted file mode 100644
index 86b6478..0000000
--- a/Socket.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef SOCKET_H
-#define SOCKET_H
-
-#include <string>
-#include <cstring>
-
-#ifdef WIN32
-#else
-#include <sys/socket.h>
-#include <netdb.h>
-#endif // WIN32
-
-class Socket {
-public:
- Socket();
- virtual ~Socket();
-
- void conn(std::string host, std::string port);
- void sendline(std::string line);
- std::string readline();
- void clo();
-
-private:
- /*int sockid;
- addrinfo hostInfo;
- addrinfo* hostInfoList;*/
-};
-
-#endif // SOCKET_H