diff options
-rw-r--r-- | Makefile | 8 | ||||
-rw-r--r-- | anytun.cpp | 10 | ||||
-rw-r--r-- | buffer.h | 2 | ||||
-rw-r--r-- | cipher.cpp (renamed from cypher.cpp) | 38 | ||||
-rw-r--r-- | cipher.h (renamed from cypher.h) | 32 | ||||
-rw-r--r-- | cipherFactory.cpp (renamed from cypherFactory.cpp) | 12 | ||||
-rw-r--r-- | cipherFactory.h (renamed from cypherFactory.h) | 18 | ||||
-rw-r--r-- | connectionParam.h | 2 | ||||
-rw-r--r-- | encryptedPacket.h | 4 | ||||
-rw-r--r-- | mpi.cpp | 2 | ||||
-rw-r--r-- | options.cpp | 16 | ||||
-rw-r--r-- | options.h | 6 | ||||
-rw-r--r-- | plainPacket.h | 4 |
13 files changed, 77 insertions, 77 deletions
@@ -52,12 +52,12 @@ OBJS = anytun.o \ syncCommand.o \ plainPacket.o \ encryptedPacket.o \ - cypher.o \ + cipher.o \ authAlgo.o \ authTag.o \ keyDerivation.o \ mpi.o \ - cypherFactory.o \ + cipherFactory.o \ authAlgoFactory.o \ connectionList.o \ connectionParam.o \ @@ -100,7 +100,7 @@ plainPacket.o: plainPacket.cpp plainPacket.h buffer.h encryptedPacket.o: encryptedPacket.cpp encryptedPacket.h buffer.h $(C++) $(CCFLAGS) $< -c -cypher.o: cypher.cpp cypher.h buffer.h +cipher.o: cipher.cpp cipher.h buffer.h $(C++) $(CCFLAGS) $< -c authAlgo.o: authAlgo.cpp authAlgo.h buffer.h @@ -115,7 +115,7 @@ keyDerivation.o: keyDerivation.cpp keyDerivation.h mpi.o: mpi.cpp mpi.h $(C++) $(CCFLAGS) $< -c -cypherFactory.o: cypherFactory.cpp cypherFactory.h cypher.h +cipherFactory.o: cipherFactory.cpp cipherFactory.h cipher.h $(C++) $(CCFLAGS) $< -c authAlgoFactory.o: authAlgoFactory.cpp authAlgoFactory.h authAlgo.h @@ -40,11 +40,11 @@ #include "buffer.h" #include "plainPacket.h" #include "encryptedPacket.h" -#include "cypher.h" +#include "cipher.h" #include "keyDerivation.h" #include "authAlgo.h" #include "authTag.h" -#include "cypherFactory.h" +#include "cipherFactory.h" #include "authAlgoFactory.h" #include "signalController.h" #include "packetSource.h" @@ -125,7 +125,7 @@ void* sender(void* p) { ThreadParam* param = reinterpret_cast<ThreadParam*>(p); - std::auto_ptr<Cypher> c(CypherFactory::create(param->opt.getCypher())); + std::auto_ptr<Cipher> c(CipherFactory::create(param->opt.getCipher())); std::auto_ptr<AuthAlgo> a(AuthAlgoFactory::create(param->opt.getAuthAlgo()) ); PlainPacket plain_packet(1600); // TODO: fix me... mtu size @@ -220,7 +220,7 @@ void* receiver(void* p) { ThreadParam* param = reinterpret_cast<ThreadParam*>(p); - std::auto_ptr<Cypher> c( CypherFactory::create(param->opt.getCypher()) ); + std::auto_ptr<Cipher> c( CipherFactory::create(param->opt.getCipher()) ); std::auto_ptr<AuthAlgo> a( AuthAlgoFactory::create(param->opt.getAuthAlgo()) ); EncryptedPacket packet(1600); // TODO: dynamic mtu size @@ -318,7 +318,7 @@ bool initLibGCrypt() } // do NOT allocate a pool uof secure memory! Q@NINE? - // this is NOT thread safe! ?????????????????????????????????? + // this is NOT thread safe! ?????????????????????????????????? why secure memory???????? /* Allocate a pool of 16k secure memory. This also drops priviliges * on some systems. */ @@ -65,7 +65,7 @@ public: protected: friend class TunDevice; friend class UDPPacketSource; - friend class AesIcmCypher; + friend class AesIcmCipher; friend class KeyDerivation; // friend class Mpi; @@ -34,70 +34,70 @@ #include <cstdio> #include <gcrypt.h> -#include "cypher.h" +#include "cipher.h" #include "mpi.h" #include "log.h" -void Cypher::encrypt(const PlainPacket & in,EncryptedPacket & out, seq_nr_t seq_nr, sender_id_t sender_id) +void Cipher::encrypt(const PlainPacket & in,EncryptedPacket & out, seq_nr_t seq_nr, sender_id_t sender_id) { - cypher(out.payload_, in.complete_payload_ , in.complete_payload_length_, seq_nr, sender_id); + cipher(out.payload_, in.complete_payload_ , in.complete_payload_length_, seq_nr, sender_id); out.setSenderId(sender_id); out.setSeqNr(seq_nr); out.setPayloadLength(in.complete_payload_length_); } -void Cypher::decrypt(const EncryptedPacket & in,PlainPacket & out) +void Cipher::decrypt(const EncryptedPacket & in,PlainPacket & out) { - cypher(out.complete_payload_, in.payload_ , in.payload_length_, in.getSeqNr(), in.getSenderId()); + cipher(out.complete_payload_, in.payload_ , in.payload_length_, in.getSeqNr(), in.getSenderId()); out.setCompletePayloadLength(in.payload_length_); } -//****** NullCypher ****** +//****** NullCipher ****** -void NullCypher::cypher(u_int8_t * out, u_int8_t * in, u_int32_t length, seq_nr_t seq_nr, sender_id_t sender_id) +void NullCipher::cipher(u_int8_t * out, u_int8_t * in, u_int32_t length, seq_nr_t seq_nr, sender_id_t sender_id) { std::memcpy(out, in, length ); } -//****** AesIcmCypher ****** +//****** AesIcmCipher ****** -AesIcmCypher::AesIcmCypher() : salt_(Buffer(14)) // Q@NINE 14?????? +AesIcmCipher::AesIcmCipher() : salt_(Buffer(14)) // Q@NINE 14?????? { gcry_error_t err; // TODO: hardcoded keysize!!!!! err = gcry_cipher_open( &cipher_, GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_CTR, 0 ); if( err ) - cLog.msg(Log::PRIO_CRIT) << "AesIcmCypher::AesIcmCypher: Failed to open cipher"; + cLog.msg(Log::PRIO_CRIT) << "AesIcmCipher::AesIcmCipher: Failed to open cipher"; } -AesIcmCypher::~AesIcmCypher() +AesIcmCipher::~AesIcmCipher() { gcry_cipher_close( cipher_ ); - cLog.msg(Log::PRIO_DEBUG) << "AesIcmCypher::~AesIcmCypher: closed cipher"; + cLog.msg(Log::PRIO_DEBUG) << "AesIcmCipher::~AesIcmCipher: closed cipher"; } -void AesIcmCypher::setKey(Buffer key) +void AesIcmCipher::setKey(Buffer key) { gcry_error_t err; err = gcry_cipher_setkey( cipher_, key.getBuf(), key.getLength() ); if( err ) - cLog.msg(Log::PRIO_ERR) << "AesIcmCypher::setKey: Failed to set cipher key: " << gpg_strerror( err ); + cLog.msg(Log::PRIO_ERR) << "AesIcmCipher::setKey: Failed to set cipher key: " << gpg_strerror( err ); } -void AesIcmCypher::setSalt(Buffer salt) +void AesIcmCipher::setSalt(Buffer salt) { salt_ = salt; } -void AesIcmCypher::cypher(u_int8_t * out, u_int8_t * in, u_int32_t length, seq_nr_t seq_nr, sender_id_t sender_id) +void AesIcmCipher::cipher(u_int8_t * out, u_int8_t * in, u_int32_t length, seq_nr_t seq_nr, sender_id_t sender_id) { gcry_error_t err; @@ -123,7 +123,7 @@ void AesIcmCypher::cypher(u_int8_t * out, u_int8_t * in, u_int32_t length, seq_ err = gcry_cipher_setiv( cipher_, iv_buf, 16 ); // TODO: hardcoded size delete[] iv_buf; if( err ) { - cLog.msg(Log::PRIO_ERR) << "AesIcmCypher: Failed to set cipher IV: " << gpg_strerror( err ); + cLog.msg(Log::PRIO_ERR) << "AesIcmCipher: Failed to set cipher IV: " << gpg_strerror( err ); return; } @@ -131,13 +131,13 @@ void AesIcmCypher::cypher(u_int8_t * out, u_int8_t * in, u_int32_t length, seq_ err = gcry_cipher_reset( cipher_ ); if( err ) { - cLog.msg(Log::PRIO_ERR) << "AesIcmCypher: Failed to reset cipher: " << gpg_strerror( err ); + cLog.msg(Log::PRIO_ERR) << "AesIcmCipher: Failed to reset cipher: " << gpg_strerror( err ); return; } err = gcry_cipher_encrypt( cipher_, out, length, in, length ); if( err ) { - cLog.msg(Log::PRIO_ERR) << "AesIcmCypher: Failed to generate cipher bitstream: " << gpg_strerror( err ); + cLog.msg(Log::PRIO_ERR) << "AesIcmCipher: Failed to generate cipher bitstream: " << gpg_strerror( err ); return; } } @@ -28,8 +28,8 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _CYPHER_H_ -#define _CYPHER_H_ +#ifndef _CIPHER_H_ +#define _CIPHER_H_ #include "datatypes.h" #include "buffer.h" @@ -39,43 +39,43 @@ #include <gcrypt.h> -class Cypher +class Cipher { public: - Cypher() {}; - virtual ~Cypher() {}; + Cipher() {}; + virtual ~Cipher() {}; void setKey(Buffer key) {}; void setSalt(Buffer salt) {}; void encrypt(const PlainPacket & in,EncryptedPacket & out, seq_nr_t seq_nr, sender_id_t sender_id); void decrypt(const EncryptedPacket & in,PlainPacket & out); private: - virtual void cypher(u_int8_t * in, u_int8_t * out, u_int32_t length, seq_nr_t seq_nr, sender_id_t sender_id) {}; + virtual void cipher(u_int8_t * in, u_int8_t * out, u_int32_t length, seq_nr_t seq_nr, sender_id_t sender_id) {}; }; -//****** NullCypher ****** +//****** NullCipher ****** -class NullCypher : public Cypher +class NullCipher : public Cipher { public: - NullCypher() {}; - ~NullCypher() {}; + NullCipher() {}; + ~NullCipher() {}; protected: - void cypher(u_int8_t * in, u_int8_t * out, u_int32_t length, seq_nr_t seq_nr, sender_id_t sender_id); + void cipher(u_int8_t * in, u_int8_t * out, u_int32_t length, seq_nr_t seq_nr, sender_id_t sender_id); }; -//****** AesIcmCypher ****** +//****** AesIcmCipher ****** -class AesIcmCypher : public Cypher +class AesIcmCipher : public Cipher { public: - AesIcmCypher(); - ~AesIcmCypher(); + AesIcmCipher(); + ~AesIcmCipher(); void setKey(Buffer key); void setSalt(Buffer salt); protected: - void cypher(u_int8_t * in, u_int8_t * out, u_int32_t length, seq_nr_t seq_nr, sender_id_t sender_id); + void cipher(u_int8_t * in, u_int8_t * out, u_int32_t length, seq_nr_t seq_nr, sender_id_t sender_id); gcry_cipher_hd_t cipher_; Buffer salt_; }; diff --git a/cypherFactory.cpp b/cipherFactory.cpp index e554fd2..4271600 100644 --- a/cypherFactory.cpp +++ b/cipherFactory.cpp @@ -31,17 +31,17 @@ #include <string> #include <stdexcept> -#include "cypherFactory.h" -#include "cypher.h" +#include "cipherFactory.h" +#include "cipher.h" -Cypher* CypherFactory::create(std::string const& type) +Cipher* CipherFactory::create(std::string const& type) { if( type == "null" ) - return new NullCypher(); + return new NullCipher(); else if( type == "aes" ) - return new AesIcmCypher(); + return new AesIcmCipher(); else - throw std::invalid_argument("cypher not available"); + throw std::invalid_argument("cipher not available"); } diff --git a/cypherFactory.h b/cipherFactory.h index 002d741..b48d7d0 100644 --- a/cypherFactory.h +++ b/cipherFactory.h @@ -28,24 +28,24 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _CYPHER_FACTORY_H_ -#define _CYPHER_FACTORY_H_ +#ifndef _CIPHER_FACTORY_H_ +#define _CIPHER_FACTORY_H_ #include <string> #include "datatypes.h" -#include "cypher.h" +#include "cipher.h" -class CypherFactory +class CipherFactory { public: - static Cypher* create(std::string const& type); + static Cipher* create(std::string const& type); private: - CypherFactory(); - CypherFactory(const CypherFactory& src); - void operator=(const CypherFactory& src); - ~CypherFactory(); + CipherFactory(); + CipherFactory(const CipherFactory& src); + void operator=(const CipherFactory& src); + ~CipherFactory(); }; #endif diff --git a/connectionParam.h b/connectionParam.h index 5e00e25..0861a6c 100644 --- a/connectionParam.h +++ b/connectionParam.h @@ -33,7 +33,7 @@ #include "options.h" #include "keyDerivation.h" -#include "cypher.h" +#include "cipher.h" #include "authAlgo.h" #include "seqWindow.h" #include "threadUtils.hpp" diff --git a/encryptedPacket.h b/encryptedPacket.h index 0535454..afc7d0e 100644 --- a/encryptedPacket.h +++ b/encryptedPacket.h @@ -34,7 +34,7 @@ #include "datatypes.h" #include "buffer.h" #include "authTag.h" -class Cypher; +class Cipher; class EncryptedPacket : public Buffer { public: @@ -137,7 +137,7 @@ private: static const u_int32_t AUTHTAG_SIZE = 10; // 10byte protected: - friend class Cypher; + friend class Cipher; u_int8_t * payload_; u_int32_t payload_length_; }; @@ -31,7 +31,7 @@ #include "mpi.h" #include "datatypes.h" -#include "cypher.h" +#include "cipher.h" #include <stdexcept> #include <gcrypt.h> diff --git a/options.cpp b/options.cpp index 1158c98..4803cd2 100644 --- a/options.cpp +++ b/options.cpp @@ -103,7 +103,7 @@ Options::Options() ifconfig_param_local_ = "192.168.200.1"; ifconfig_param_remote_netmask_ = "255.255.255.0"; seq_window_size_ = 100; - cypher_ = "aes"; + cipher_ = "aes"; auth_algo_ = "sha1"; } @@ -133,7 +133,7 @@ bool Options::parse(int argc, char* argv[]) PARSE_SCALAR_PARAM("-t","--type", dev_type_) PARSE_SCALAR_PARAM2("-n","--ifconfig", ifconfig_param_local_, ifconfig_param_remote_netmask_) PARSE_SCALAR_PARAM("-w","--window-size", seq_window_size_) - PARSE_SCALAR_PARAM("-c","--cypher", cypher_) + PARSE_SCALAR_PARAM("-c","--cipher", cipher_) PARSE_SCALAR_PARAM("-a","--auth-algo", auth_algo_) PARSE_SCALAR_CSLIST("-M","--sync-hosts", host_port_queue) else @@ -171,7 +171,7 @@ void Options::printUsage() std::cout << " [-n|--ifconfig] <local> the local address for the tun/tap device" << std::endl << " <remote|netmask> the remote address(tun) or netmask(tap)" << std::endl; std::cout << " [-w|--window-size] <window size> seqence number window size" << std::endl; - std::cout << " [-c|--cypher] <cypher type> payload encryption algorithm" << std::endl; + std::cout << " [-c|--cipher] <cipher type> payload encryption algorithm" << std::endl; std::cout << " [-a|--auth-algo] <algo type> message authentication algorithm" << std::endl; } @@ -190,7 +190,7 @@ void Options::printOptions() std::cout << "ifconfig_param_local='" << ifconfig_param_local_ << "'" << std::endl; std::cout << "ifconfig_param_remote_netmask='" << ifconfig_param_remote_netmask_ << "'" << std::endl; std::cout << "seq_window_size='" << seq_window_size_ << "'" << std::endl; - std::cout << "cypher='" << cypher_ << "'" << std::endl; + std::cout << "cipher='" << cipher_ << "'" << std::endl; std::cout << "auth_algo='" << auth_algo_ << "'" << std::endl; } @@ -392,16 +392,16 @@ Options& Options::setSeqWindowSize(window_size_t s) return *this; } -std::string Options::getCypher() +std::string Options::getCipher() { Lock lock(mutex); - return cypher_; + return cipher_; } -Options& Options::setCypher(std::string c) +Options& Options::setCipher(std::string c) { Lock lock(mutex); - cypher_ = c; + cipher_ = c; return *this; } @@ -82,8 +82,8 @@ public: Options& setIfconfigParamRemoteNetmask(std::string i); window_size_t getSeqWindowSize(); Options& setSeqWindowSize(window_size_t s); - std::string getCypher(); - Options& setCypher(std::string c); + std::string getCipher(); + Options& setCipher(std::string c); std::string getAuthAlgo(); Options& setAuthAlgo(std::string a); ConnectToList getConnectTo(); @@ -107,7 +107,7 @@ private: std::string ifconfig_param_local_; std::string ifconfig_param_remote_netmask_; window_size_t seq_window_size_; - std::string cypher_; + std::string cipher_; std::string auth_algo_; }; diff --git a/plainPacket.h b/plainPacket.h index 39029c2..176d841 100644 --- a/plainPacket.h +++ b/plainPacket.h @@ -34,7 +34,7 @@ #include "datatypes.h" #include "buffer.h" -class Cypher; +class Cipher; /** * plain SATP packet class<br> * includes payload_type and payload @@ -97,7 +97,7 @@ private: u_int32_t max_length_; payload_type_t* payload_type_; protected: - friend class Cypher; + friend class Cipher; u_int8_t * complete_payload_; u_int32_t complete_payload_length_; }; |