From 2c55bc987c93a1857e3cdaf8c8f1cea60483ab1e Mon Sep 17 00:00:00 2001 From: Othmar Gsenger Date: Tue, 11 Dec 2007 09:09:48 +0000 Subject: added syncbuffer --- Makefile | 4 ++++ buffer.cpp | 7 ------- buffer.h | 10 ---------- connectionParam.cpp | 2 -- connectionParam.h | 7 ++----- keyDerivation.cpp | 2 +- keyDerivation.h | 10 ++++------ seqWindow.h | 9 ++------- syncBuffer.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ syncBuffer.h | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 10 files changed, 108 insertions(+), 38 deletions(-) create mode 100644 syncBuffer.cpp create mode 100644 syncBuffer.h diff --git a/Makefile b/Makefile index 4cc2469..336c2d6 100644 --- a/Makefile +++ b/Makefile @@ -48,6 +48,7 @@ OBJS = anytun.o \ tunDevice.o \ packetSource.o \ buffer.o \ + syncBuffer.o \ packet.o \ cypher.o \ authAlgo.o \ @@ -82,6 +83,9 @@ packetSource.o: packetSource.cpp packetSource.h buffer.o: buffer.cpp buffer.h $(C++) $(CCFLAGS) $< -c +syncBuffer.o: syncBuffer.cpp syncBuffer.h + $(C++) $(CCFLAGS) $< -c + packet.o: packet.cpp packet.h buffer.h $(C++) $(CCFLAGS) $< -c diff --git a/buffer.cpp b/buffer.cpp index e85500d..11387da 100644 --- a/buffer.cpp +++ b/buffer.cpp @@ -225,10 +225,3 @@ Buffer Buffer::rightByteShift(u_int32_t width) const return res; } -template -void Buffer::serialize(Archive & ar, const unsigned int version) -{ - ar & length_; - ar & buf_; -} - diff --git a/buffer.h b/buffer.h index a9601fe..17e1154 100644 --- a/buffer.h +++ b/buffer.h @@ -36,12 +36,6 @@ class TunDevice; class UDPPacketSource; -namespace boost { - namespace serialization { - class access; - } -} - class Buffer { public: @@ -75,10 +69,6 @@ protected: u_int8_t *buf_; u_int32_t length_; -private: - friend class boost::serialization::access; - template - void serialize(Archive & ar, const unsigned int version); }; #endif diff --git a/connectionParam.cpp b/connectionParam.cpp index 13c0737..ca3d767 100644 --- a/connectionParam.cpp +++ b/connectionParam.cpp @@ -29,8 +29,6 @@ */ #include "connectionParam.h" -#include -#include ConnectionParam::ConnectionParam(KeyDerivation& kd, SeqWindow& seq_window,seq_nr_t seq_nr, std::string remote_host, u_int16_t remote_port) : kd_(kd),seq_window_(seq_window),seq_nr_(seq_nr),remote_host_(remote_host), remote_port_(remote_port) { diff --git a/connectionParam.h b/connectionParam.h index 770c3bd..98eab34 100644 --- a/connectionParam.h +++ b/connectionParam.h @@ -37,11 +37,8 @@ #include "authAlgo.h" #include "seqWindow.h" -namespace boost { - namespace serialization { - class access; - } -} +#include +#include class ConnectionParam { diff --git a/keyDerivation.cpp b/keyDerivation.cpp index 2c8a646..b74f459 100644 --- a/keyDerivation.cpp +++ b/keyDerivation.cpp @@ -82,7 +82,7 @@ void KeyDerivation::init(Buffer key, Buffer salt) return; } - salt_ = salt; + salt_ = SyncBuffer(salt); initialized_ = true; } diff --git a/keyDerivation.h b/keyDerivation.h index aae6c3e..d155934 100644 --- a/keyDerivation.h +++ b/keyDerivation.h @@ -33,7 +33,10 @@ #include "datatypes.h" #include "buffer.h" +#include "syncBuffer.h" +#include +#include extern "C" { @@ -47,11 +50,6 @@ typedef enum { label_satp_salt = 0x02, } satp_prf_label; -namespace boost { - namespace serialization { - class access; - } -} class KeyDerivation { @@ -69,7 +67,7 @@ private: protected: int8_t ld_kdr_; // ld(key_derivation_rate) - Buffer salt_; + SyncBuffer salt_; static const char* MIN_GCRYPT_VERSION; gcry_cipher_hd_t cipher_; diff --git a/seqWindow.h b/seqWindow.h index 074ecb5..8f94b7c 100644 --- a/seqWindow.h +++ b/seqWindow.h @@ -33,16 +33,11 @@ #include #include - +#include +#include #include "threadUtils.hpp" #include "datatypes.h" -namespace boost { - namespace serialization { - class access; - } -} - class SeqWindow { public: diff --git a/syncBuffer.cpp b/syncBuffer.cpp new file mode 100644 index 0000000..5af8cb5 --- /dev/null +++ b/syncBuffer.cpp @@ -0,0 +1,44 @@ +/* + * anytun + * + * The secure anycast tunneling protocol (satp) defines a protocol used + * for communication between any combination of unicast and anycast + * tunnel endpoints. It has less protocol overhead than IPSec in Tunnel + * mode and allows tunneling of every ETHER TYPE protocol (e.g. + * ethernet, ip, arp ...). satp directly includes cryptography and + * message authentication based on the methodes used by SRTP. It is + * intended to deliver a generic, scaleable and secure solution for + * tunneling and relaying of packets of any protocol. + * + * + * Copyright (C) 2007 anytun.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program (see the file COPYING included with this + * distribution); if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include "datatypes.h" +#include "syncBuffer.h" + +template +void SyncBuffer::serialize(Archive & ar, const unsigned int version) +{ + ar & length_; + ar & buf_; +} + diff --git a/syncBuffer.h b/syncBuffer.h new file mode 100644 index 0000000..1d4fc9f --- /dev/null +++ b/syncBuffer.h @@ -0,0 +1,51 @@ +/* + * anytun + * + * The secure anycast tunneling protocol (satp) defines a protocol used + * for communication between any combination of unicast and anycast + * tunnel endpoints. It has less protocol overhead than IPSec in Tunnel + * mode and allows tunneling of every ETHER TYPE protocol (e.g. + * ethernet, ip, arp ...). satp directly includes cryptography and + * message authentication based on the methodes used by SRTP. It is + * intended to deliver a generic, scaleable and secure solution for + * tunneling and relaying of packets of any protocol. + * + * + * Copyright (C) 2007 anytun.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program (see the file COPYING included with this + * distribution); if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _SYNCBUFFER_H_ +#define _SYNCBUFFER_H_ + +#include +#include +#include "buffer.h" + +class SyncBuffer : public Buffer +{ +public: + SyncBuffer() : Buffer(){}; + SyncBuffer(u_int32_t length) : Buffer(length){}; + SyncBuffer(Buffer b): Buffer(b) {}; + SyncBuffer(u_int8_t* data, u_int32_t length): Buffer(data,length) {}; +private: + friend class boost::serialization::access; + template + void serialize(Archive & ar, const unsigned int version); +}; + +#endif -- cgit v1.2.3