From 9ef6972b360e5e8dd8485d25f0727cafea5e5331 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sun, 24 Feb 2008 22:17:48 +0000 Subject: sorry forgot to add keyDerivatioFactory --- keyDerivation.cpp | 2 +- keyDerivationFactory.cpp | 47 ++++++++++++++++++++++++++++++++++++++++++++ keyDerivationFactory.h | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ options.cpp | 4 +++- 4 files changed, 102 insertions(+), 2 deletions(-) create mode 100644 keyDerivationFactory.cpp create mode 100644 keyDerivationFactory.h diff --git a/keyDerivation.cpp b/keyDerivation.cpp index 79086b2..ac69f80 100644 --- a/keyDerivation.cpp +++ b/keyDerivation.cpp @@ -80,7 +80,7 @@ void AesIcmKeyDerivation::init(Buffer key, Buffer salt) if(cipher_) gcry_cipher_close( cipher_ ); - // TODO: hardcoded cipher-type and keysize?? + // TODO: hardcoded size gcry_error_t err = gcry_cipher_open( &cipher_, GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_CTR, 0 ); if( err ) { cLog.msg(Log::PRIO_ERR) << "KeyDerivation::init: Failed to open cipher: " << gpg_strerror( err ); diff --git a/keyDerivationFactory.cpp b/keyDerivationFactory.cpp new file mode 100644 index 0000000..a70cbca --- /dev/null +++ b/keyDerivationFactory.cpp @@ -0,0 +1,47 @@ +/* + * 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 "keyDerivationFactory.h" +#include "keyDerivation.h" + + +KeyDerivation* KeyDerivationFactory::create(std::string const& type) +{ + if( type == "null" ) + return new NullKeyDerivation(); + else if( type == "aes-ctr" ) + return new AesIcmKeyDerivation(); + else + throw std::invalid_argument("key derivation prf not available"); +} + diff --git a/keyDerivationFactory.h b/keyDerivationFactory.h new file mode 100644 index 0000000..f422711 --- /dev/null +++ b/keyDerivationFactory.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 _KEYDERIVATION_FACTORY_H_ +#define _KEYDERIVATION_FACTORY_H_ + +#include + +#include "datatypes.h" +#include "keyDerivation.h" + +class KeyDerivationFactory +{ +public: + static KeyDerivation* create(std::string const& type); + +private: + KeyDerivationFactory(); + KeyDerivationFactory(const KeyDerivationFactory& src); + void operator=(const KeyDerivationFactory& src); + ~KeyDerivationFactory(); +}; + +#endif diff --git a/options.cpp b/options.cpp index 461e4f6..8bc4e77 100644 --- a/options.cpp +++ b/options.cpp @@ -71,7 +71,7 @@ i+=2; \ } -#define PARSE_SCALAR_CSLIST(SHORT, LONG, LIST) \ +#define PARSE_CSLIST_PARAM(SHORT, LONG, LIST) \ else if(str == SHORT || str == LONG) \ { \ if(argc < 1 || argv[i+1][0] == '-') \ @@ -174,6 +174,7 @@ void Options::printUsage() << " the remote address(tun) or netmask(tap)" << std::endl; std::cout << " [-w|--window-size] seqence number window size" << std::endl; std::cout << " [-c|--cipher] payload encryption algorithm" << std::endl; + std::cout << " [-k|--kd-prf] key derivation pseudo random function" << std::endl; std::cout << " [-a|--auth-algo] message authentication algorithm" << std::endl; } @@ -193,6 +194,7 @@ void Options::printOptions() std::cout << "ifconfig_param_remote_netmask='" << ifconfig_param_remote_netmask_ << "'" << std::endl; std::cout << "seq_window_size='" << seq_window_size_ << "'" << std::endl; std::cout << "cipher='" << cipher_ << "'" << std::endl; + std::cout << "kd-prf='" << kd_prf_ << "'" << std::endl; std::cout << "auth_algo='" << auth_algo_ << "'" << std::endl; } -- cgit v1.2.3