summaryrefslogtreecommitdiff
path: root/src/authAlgo.h
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2009-01-14 16:49:42 +0000
committerChristian Pointner <equinox@anytun.org>2009-01-14 16:49:42 +0000
commitb5fc5e6e2136280e4d8c0526fe960e07a73f2e32 (patch)
tree5c8f3f3895dff94ad3f200de966f81c99dfc67f2 /src/authAlgo.h
parentported cipher from uanytun to anytun (diff)
ported authAlgo from uanytun to anytun
Diffstat (limited to 'src/authAlgo.h')
-rw-r--r--src/authAlgo.h44
1 files changed, 19 insertions, 25 deletions
diff --git a/src/authAlgo.h b/src/authAlgo.h
index 3085673..be8d158 100644
--- a/src/authAlgo.h
+++ b/src/authAlgo.h
@@ -37,8 +37,13 @@
#include "encryptedPacket.h"
#ifndef NOCRYPT
+#ifndef USE_SSL_CRYPTO
#include <gcrypt.h>
+#else
+#include <openssl/hmac.h>
#endif
+#endif
+#include "keyDerivation.h"
class AuthAlgo
{
@@ -47,27 +52,16 @@ public:
virtual ~AuthAlgo() {};
/**
- * set the key for the auth algo
- * @param key key for hmac calculation
- */
- virtual void setKey(Buffer& key) = 0;
-
- /**
* generate the mac
* @param packet the packet to be authenticated
*/
- virtual void generate(EncryptedPacket& packet) = 0;
+ virtual void generate(KeyDerivation& kd, EncryptedPacket& packet) = 0;
/**
* check the mac
* @param packet the packet to be authenticated
*/
- virtual bool checkTag(EncryptedPacket& packet) = 0;
-
- /**
- * get the maximum size of the auth algo
- */
- virtual u_int32_t getMaxLength() = 0;
+ virtual bool checkTag(KeyDerivation& kd, EncryptedPacket& packet) = 0;
};
//****** NullAuthAlgo ******
@@ -75,12 +69,8 @@ public:
class NullAuthAlgo : public AuthAlgo
{
public:
- void setKey(Buffer& key) {};
- void generate(EncryptedPacket& packet);
- bool checkTag(EncryptedPacket& packet);
- u_int32_t getMaxLength();
-
- static const u_int32_t MAX_LENGTH_ = 0;
+ void generate(KeyDerivation& kd, EncryptedPacket& packet);
+ bool checkTag(KeyDerivation& kd, EncryptedPacket& packet);
};
#ifndef NOCRYPT
@@ -93,15 +83,19 @@ public:
Sha1AuthAlgo();
~Sha1AuthAlgo();
- void setKey(Buffer& key);
- void generate(EncryptedPacket& packet);
- bool checkTag(EncryptedPacket& packet);
- u_int32_t getMaxLength();
+ void generate(KeyDerivation& kd, EncryptedPacket& packet);
+ bool checkTag(KeyDerivation& kd, EncryptedPacket& packet);
- static const u_int32_t MAX_LENGTH_ = 20;
+ static const u_int32_t DIGEST_LENGTH = 20;
private:
- gcry_md_hd_t ctx_;
+#ifndef USE_SSL_CRYPTO
+ gcry_md_hd_t handle_;
+#else
+ HMAC_CTX ctx_;
+#endif
+
+ Buffer key_;
};
#endif