From 00febb25de92b1cd01309cc0f253ed4c3a761b13 Mon Sep 17 00:00:00 2001 From: Erwin Nindl Date: Mon, 24 Dec 2007 17:05:26 +0000 Subject: weihnachtlicher checkin * packet processing now with less memory operations than before * todo: * testing * set cipher / authalgo via commandline * set key operations for hmac calculation --- cypher.h | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'cypher.h') diff --git a/cypher.h b/cypher.h index ae56881..e408cd4 100644 --- a/cypher.h +++ b/cypher.h @@ -31,14 +31,10 @@ #ifndef _CYPHER_H_ #define _CYPHER_H_ - - #include "datatypes.h" #include "buffer.h" -extern "C" { #include -} class Cypher @@ -49,17 +45,16 @@ public: void setKey(Buffer key) {}; void setSalt(Buffer salt) {}; - void cypher(Buffer& buf, seq_nr_t seq_nr, sender_id_t sender_id); - -protected: - void exor(Buffer& buf, const Buffer& bit_stream); - virtual Buffer getBitStream(u_int32_t length, seq_nr_t seq_nr, sender_id_t sender_id) = 0; + virtual void cypher(Buffer& in, Buffer& out, u_int32_t length, seq_nr_t seq_nr, sender_id_t sender_id) {}; }; class NullCypher : public Cypher { +public: + NullCypher() {}; + ~NullCypher() {}; protected: - Buffer getBitStream(u_int32_t length, seq_nr_t seq_nr, sender_id_t sender_id); + void cypher(Buffer& in, Buffer& out, u_int32_t length, seq_nr_t seq_nr, sender_id_t sender_id); }; class AesIcmCypher : public Cypher @@ -69,17 +64,14 @@ public: ~AesIcmCypher(); void setKey(Buffer key); void setSalt(Buffer salt); + void cypher(Buffer& in, Buffer& out, u_int32_t length, seq_nr_t seq_nr, sender_id_t sender_id); static const char* MIN_GCRYPT_VERSION; static const u_int32_t GCRYPT_SEC_MEM = 16384; // 16k secure memory protected: - Buffer getBitStream(u_int32_t length, seq_nr_t seq_nr, sender_id_t sender_id); gcry_cipher_hd_t cipher_; Buffer salt_; - -private: - static bool gcrypt_initialized_; }; -- cgit v1.2.3