diff options
author | Erwin Nindl <nine@wirdorange.org> | 2007-08-15 13:19:31 +0000 |
---|---|---|
committer | Erwin Nindl <nine@wirdorange.org> | 2007-08-15 13:19:31 +0000 |
commit | 3543f2a6c9034db63af9a0ec8681bc03d5532d48 (patch) | |
tree | 0c711aa3ab2f327fac9bd7ed6e6044e1cfbc5b7c | |
parent | added diagramm (diff) |
* set cypher to aes_icm
* changed cypher
-rw-r--r-- | anytun.cpp | 30 | ||||
-rw-r--r-- | cypher.cpp | 1 | ||||
-rw-r--r-- | cypher.h | 6 |
3 files changed, 18 insertions, 19 deletions
@@ -66,14 +66,14 @@ void* sender(void* p) { Packet pack(1600); // fix me... mtu size - // read packet from device + // read packet from device int len = param->dev.read(pack); pack.resizeBack(len); if(param->opt.getRemoteAddr() == "") continue; - // add payload type + // add payload type if(param->dev.getType() == TunDevice::TYPE_TUN) pack.addPayloadType(PAYLOAD_TYPE_TUN); else if(param->dev.getType() == TunDevice::TYPE_TAP) @@ -81,18 +81,18 @@ void* sender(void* p) else pack.addPayloadType(0); - // cypher the packet + // cypher the packet param->c.cypher(pack, seq, param->opt.getSenderId()); - // add header to packet + // add header to packet pack.addHeader(seq, param->opt.getSenderId()); seq++; - // calc auth_tag and add it to the packet + // calc auth_tag and add it to the packet auth_tag_t at = param->a.calc(pack); pack.addAuthTag(at); - // send it out to remote host + // send it out to remote host param->src.send(pack, param->opt.getRemoteAddr(), param->opt.getRemotePort()); } pthread_exit(NULL); @@ -108,39 +108,39 @@ void* receiver(void* p) u_int16_t remote_port; Packet pack(1600); // fix me... mtu size - // read packet from socket + // read packet from socket u_int32_t len = param->src.recv(pack, remote_host, remote_port); pack.resizeBack(len); pack.withPayloadType(true).withHeader(true).withAuthTag(true); - // check auth_tag and remove it + // check auth_tag and remove it auth_tag_t at = pack.getAuthTag(); pack.removeAuthTag(); if(at != param->a.calc(pack)) continue; - // autodetect peer + // autodetect peer if(param->opt.getRemoteAddr() == "") { param->opt.setRemoteAddrPort(remote_host, remote_port); cLog.msg(Log::PRIO_NOTICE) << "autodetected remote host " << remote_host << ":" << remote_port; } - // compare sender_id and seq with window + // compare sender_id and seq with window if(param->seq.hasSeqNr(pack.getSenderId(), pack.getSeqNr())) continue; param->seq.addSeqNr(pack.getSenderId(), pack.getSeqNr()); pack.removeHeader(); - // decypher the packet + // decypher the packet param->c.cypher(pack, pack.getSeqNr(), pack.getSenderId()); - // check payload_type and remove it + // check payload_type and remove it if((param->dev.getType() == TunDevice::TYPE_TUN && pack.getPayloadType() != PAYLOAD_TYPE_TUN) || (param->dev.getType() == TunDevice::TYPE_TAP && pack.getPayloadType() != PAYLOAD_TYPE_TAP)) continue; pack.removePayloadType(); - // write it on the device + // write it on the device param->dev.write(pack); } pthread_exit(NULL); @@ -162,8 +162,8 @@ int main(int argc, char* argv[]) TunDevice dev(opt.getDevName().c_str(), opt.getIfconfigParamLocal().c_str(), opt.getIfconfigParamRemoteNetmask().c_str()); SeqWindow seq(opt.getSeqWindowSize()); - NullCypher c; -// AesIcmCypher c; +// NullCypher c; + AesIcmCypher c; NullAuthAlgo a; PacketSource* src; if(opt.getLocalAddr() == "") @@ -106,4 +106,3 @@ void AesIcmCypher::cypher(Buffer& buf, seq_nr_t seq_nr, sender_id_t sender_id) status = cipher_dealloc(cipher); } - @@ -57,12 +57,12 @@ protected: class AesIcmCypher : public Cypher { public: +// AesIcmCypher() {}; +// ~AesIcmCypher() {}; void cypher(Buffer& buf, seq_nr_t seq_nr, sender_id_t sender_id); protected: - Buffer getBitStream(u_int32_t length, seq_nr_t seq_nr, sender_id_t sender_id); - -private: + Buffer getBitStream(u_int32_t length, seq_nr_t seq_nr, sender_id_t sender_id) { return Buffer(); }; }; |