From 87735d1c20816e8c1c0092a86dc8d1ab80ab36db Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sun, 17 Jun 2007 16:14:34 +0000 Subject: added cypher and authalgo --- Makefile | 15 ++++++++++++--- anytun.cpp | 6 +++++- authAlgo.cpp | 36 ++++++++++++++++++++++++++++++++++++ authAlgo.h | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ buffer.cpp | 1 + buffer.h | 2 +- cypher.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ cypher.h | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 217 insertions(+), 5 deletions(-) create mode 100644 authAlgo.cpp create mode 100644 authAlgo.h create mode 100644 cypher.cpp create mode 100644 cypher.h diff --git a/Makefile b/Makefile index a577f5d..9714f79 100644 --- a/Makefile +++ b/Makefile @@ -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) diff --git a/anytun.cpp b/anytun.cpp index 56c23d5..f7fb19a 100644 --- a/anytun.cpp +++ b/anytun.cpp @@ -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 + * + * 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 + * + * 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 diff --git a/buffer.cpp b/buffer.cpp index 0c6a82a..676deae 100644 --- a/buffer.cpp +++ b/buffer.cpp @@ -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 diff --git a/buffer.h b/buffer.h index 349c8dd..b8841af 100644 --- a/buffer.h +++ b/buffer.h @@ -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 + * + * 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 + * + * 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 -- cgit v1.2.3