diff options
-rw-r--r-- | Makefile | 15 | ||||
-rw-r--r-- | anytun.cpp | 6 | ||||
-rw-r--r-- | authAlgo.cpp | 36 | ||||
-rw-r--r-- | authAlgo.h | 52 | ||||
-rw-r--r-- | buffer.cpp | 1 | ||||
-rw-r--r-- | buffer.h | 2 | ||||
-rw-r--r-- | cypher.cpp | 55 | ||||
-rw-r--r-- | cypher.h | 55 |
8 files changed, 217 insertions, 5 deletions
@@ -31,7 +31,7 @@ OPENVPNDEPS = openvpn/tun.o \ -OBJS = anytun.o tunDevice.o buffer.o $(OPENVPNDEPS) +OBJS = anytun.o tunDevice.o buffer.o cypher.o authAlgo.o $(OPENVPNDEPS) EXECUTABLE = anytun all: $(EXECUTABLE) @@ -42,7 +42,16 @@ anytun: $(OBJS) tunDevice.o: tunDevice.cpp tunDevice.h $(C++) $(CCFLAGS) $< -c -Buffer.o: buffer.cpp buffer.h +buffer.o: buffer.cpp buffer.h + $(C++) $(CCFLAGS) $< -c + +cypher.o: cypher.cpp cypher.h buffer.h + $(C++) $(CCFLAGS) $< -c + +cypher.o: cypher.cpp cypher.h buffer.h + $(C++) $(CCFLAGS) $< -c + +authAlgo.o: authAlgo.cpp authAlgo.h buffer.h $(C++) $(CCFLAGS) $< -c anytun.o: anytun.cpp @@ -50,4 +59,4 @@ anytun.o: anytun.cpp clean: rm -f *.o - rm -f $(EXECUTABLE)
\ No newline at end of file + rm -f $(EXECUTABLE) @@ -34,6 +34,8 @@ #include "tunDevice.h" #include "buffer.h" +#include "cypher.h" +#include "authAlgo.h" int main(int argc, char* argv[]) { @@ -82,6 +84,8 @@ int main(int argc, char* argv[]) sleep(10); delete dev; std::cout << "dev destroyed" << std::endl; - + + NullAuthAlgo au; + return 0; } diff --git a/authAlgo.cpp b/authAlgo.cpp new file mode 100644 index 0000000..90fc4a2 --- /dev/null +++ b/authAlgo.cpp @@ -0,0 +1,36 @@ +/* + * 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 <satp@wirdorange.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 "authAlgo.h" + +auth_tag_t NullAuthAlgo::calc(Buffer& buf) +{ + return 0; +} diff --git a/authAlgo.h b/authAlgo.h new file mode 100644 index 0000000..8cf05e5 --- /dev/null +++ b/authAlgo.h @@ -0,0 +1,52 @@ +/* + * 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 <satp@wirdorange.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 _AUTHALGO_H_ +#define _AUTHALGO_H_ + +#include "datatypes.h" +#include "buffer.h" + +class AuthAlgo +{ +public: + AuthAlgo() {}; + virtual ~AuthAlgo() {}; + + virtual auth_tag_t calc(Buffer& buf) = 0; +}; + +class NullAuthAlgo : AuthAlgo +{ +public: + auth_tag_t calc(Buffer& buf); +}; + +#endif @@ -102,6 +102,7 @@ u_int32_t Buffer::resize(u_int32_t new_length) length_ = new_length; buf_ = tmp; + return length_; } u_int32_t Buffer::getLength() const @@ -48,8 +48,8 @@ public: protected: - u_int32_t length_; u_int8_t *buf_; + u_int32_t length_; }; diff --git a/cypher.cpp b/cypher.cpp new file mode 100644 index 0000000..8711862 --- /dev/null +++ b/cypher.cpp @@ -0,0 +1,55 @@ +/* + * 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 <satp@wirdorange.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 "datatypes.h" + +#include "cypher.h" + +void Cypher::cypher(Buffer& buf) +{ + Buffer stream = getBitStream(buf.getLength()); + calc(buf, stream, buf.getLength()); +} + +void Cypher::calc(u_int8_t* buf, u_int8_t* bit_stream, u_int32_t length) +{ + for(u_int32_t i; i<length; ++i) + buf[i] ^= bit_stream[i]; +} + + +Buffer NullCypher::getBitStream(u_int32_t length) +{ + Buffer buf(length); + for(u_int32_t i; i<length; ++i) + buf[i] = 0; + return buf; +} + diff --git a/cypher.h b/cypher.h new file mode 100644 index 0000000..f1ef8bf --- /dev/null +++ b/cypher.h @@ -0,0 +1,55 @@ +/* + * 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 <satp@wirdorange.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 _CYPHER_H_ +#define _CYPHER_H_ + +#include "buffer.h" + +class Cypher +{ +public: + Cypher() {}; + virtual ~Cypher() {}; + + void cypher(Buffer& buf); + +protected: + void calc(u_int8_t* buf, u_int8_t* bit_stream, u_int32_t length); + virtual Buffer getBitStream(u_int32_t length) = 0; +}; + +class NullCypher : Cypher +{ +protected: + Buffer getBitStream(u_int32_t length); +}; + +#endif |