summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErwin Nindl <nine@wirdorange.org>2007-12-11 14:23:53 +0000
committerErwin Nindl <nine@wirdorange.org>2007-12-11 14:23:53 +0000
commit823af1bc3a10e1df0b3d86856dfcd652d5d6b881 (patch)
tree4960f160029ce5d2a850cc555518e3a9af9eede5
parentfixed sync crash, when no active connections (diff)
recever gets seq and sid now
-rw-r--r--anytun.cpp6
-rw-r--r--packet.cpp1
2 files changed, 4 insertions, 3 deletions
diff --git a/anytun.cpp b/anytun.cpp
index d2500ec..d6e0dbf 100644
--- a/anytun.cpp
+++ b/anytun.cpp
@@ -106,7 +106,7 @@ void encryptPacket(Packet & pack, Cypher & c, ConnectionParam & conn, void* p)
c.setSalt(tmp_salt);
cLog.msg(Log::PRIO_NOTICE) << "Send Package: seq: " << conn.seq_nr_
- << "sID: " << param->opt.getSenderId();
+ << ", sID: " << param->opt.getSenderId();
//cLog.msg(Log::PRIO_NOTICE) << "Package dump: " << pack.getHexDump();
c.cypher(pack, conn.seq_nr_, param->opt.getSenderId());
@@ -117,6 +117,8 @@ bool decryptPacket(Packet & pack, Cypher & c, ConnectionParam & conn)
u_int16_t sid = pack.getSenderId();
u_int16_t seq = pack.getSeqNr();
+ pack.removeHeader();
+
// decypher the packet
//Buffer tmp_key(16), tmp_salt(14);
// conn.kd_.generate(label_satp_encryption, seq, tmp_key, tmp_key.getLength());
@@ -125,7 +127,6 @@ bool decryptPacket(Packet & pack, Cypher & c, ConnectionParam & conn)
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);
@@ -281,7 +282,6 @@ void* receiver(void* p)
//Replay Protection
//if (!checkPacketSeqNr(pack,conn))
// continue;
- pack.removeHeader();
if (!decryptPacket(pack, c, conn))
continue;
diff --git a/packet.cpp b/packet.cpp
index 156e02a..d592e1e 100644
--- a/packet.cpp
+++ b/packet.cpp
@@ -29,6 +29,7 @@
*/
#include <stdexcept>
+#include <iostream>
#include <arpa/inet.h>
#include <cstdio> // for std::memcpy