summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--anytun.cpp48
-rw-r--r--keyDerivation.cpp2
2 files changed, 42 insertions, 8 deletions
diff --git a/anytun.cpp b/anytun.cpp
index b3ed30e..18308c0 100644
--- a/anytun.cpp
+++ b/anytun.cpp
@@ -84,7 +84,7 @@ void createConnection(const std::string & remote_host , u_int16_t remote_port, C
seq_nr_t seq_nr_=0;
KeyDerivation kd;
- kd.init(Buffer(key, sizeof(key)), Buffer(salt, sizeof(salt)));
+// kd.init(Buffer(key, sizeof(key)), Buffer(salt, sizeof(salt)));
cLog.msg(Log::PRIO_NOTICE) << "added connection remote host " << remote_host << ":" << remote_port;
ConnectionParam connparam ( kd, seq, seq_nr_, remote_host, remote_port);
cl.addConnection(connparam,std::string("default"));
@@ -95,10 +95,26 @@ void encryptPacket(Packet & pack, Cypher & c, ConnectionParam & conn, void* p)
{
Param* param = reinterpret_cast<Param*>(p);
// cypher the packet
- Buffer tmp_key(16), tmp_salt(14);
+ //Buffer tmp_key(16), tmp_salt(14);
//TODO fix key derivation!
- conn.kd_.generate(label_satp_encryption, conn.seq_nr_, tmp_key, tmp_key.getLength());
- conn.kd_.generate(label_satp_salt, conn.seq_nr_, tmp_salt, tmp_salt.getLength());
+// conn.kd_.generate(label_satp_encryption, conn.seq_nr_, tmp_key, tmp_key.getLength());
+// conn.kd_.generate(label_satp_salt, conn.seq_nr_, tmp_salt, tmp_salt.getLength());
+
+
+ uint8_t key[] = {
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
+ 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
+ 'q', 'r', 's', 't'
+ };
+
+ uint8_t salt[] = {
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
+ 'i', 'j', 'k', 'l', 'm', 'n'
+ };
+
+ Buffer tmp_key(key, sizeof(key));
+ Buffer tmp_salt(salt, sizeof(salt));
+
c.setKey(tmp_key);
c.setSalt(tmp_salt);
@@ -115,9 +131,27 @@ bool decryptPacket(Packet & pack, Cypher & c, ConnectionParam & conn)
u_int16_t seq = pack.getSeqNr();
// decypher the packet
- Buffer tmp_key(16), tmp_salt(14);
- conn.kd_.generate(label_satp_encryption, seq, tmp_key, tmp_key.getLength());
- conn.kd_.generate(label_satp_salt, seq, tmp_salt, tmp_salt.getLength());
+ //Buffer tmp_key(16), tmp_salt(14);
+// conn.kd_.generate(label_satp_encryption, seq, tmp_key, tmp_key.getLength());
+// conn.kd_.generate(label_satp_salt, seq, tmp_salt, tmp_salt.getLength());
+
+
+
+ uint8_t key[] = {
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
+ 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
+ 'q', 'r', 's', 't'
+ };
+
+ uint8_t salt[] = {
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
+ 'i', 'j', 'k', 'l', 'm', 'n'
+ };
+
+ Buffer tmp_key(key, sizeof(key));
+ Buffer tmp_salt(salt, sizeof(salt));
+
+
c.setKey(tmp_key);
c.setSalt(tmp_salt);
c.cypher(pack, seq, sid);
diff --git a/keyDerivation.cpp b/keyDerivation.cpp
index d3498b8..b068c0c 100644
--- a/keyDerivation.cpp
+++ b/keyDerivation.cpp
@@ -97,7 +97,7 @@ void KeyDerivation::setLogKDRate(const uint8_t log_rate)
void KeyDerivation::generate(satp_prf_label label, seq_nr_t seq_nr, Buffer& key, u_int32_t length)
{
- Lock lock(mutex_);
+ ////Lock lock(mutex_);
gcry_error_t err;
Mpi r;