summaryrefslogtreecommitdiff
path: root/src/cipher.cpp
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2009-02-18 13:08:59 +0000
committerChristian Pointner <equinox@anytun.org>2009-02-18 13:08:59 +0000
commitd97760a781a793d35dfe75367dd8d80ab59bbb49 (patch)
tree362e1f7f198e2549b56dab7bf1eb564d15b48b91 /src/cipher.cpp
parentstatic build mostly fixed (diff)
added anytun02 compat runtime switch
Diffstat (limited to 'src/cipher.cpp')
-rw-r--r--src/cipher.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/cipher.cpp b/src/cipher.cpp
index 46865ab..e14860c 100644
--- a/src/cipher.cpp
+++ b/src/cipher.cpp
@@ -78,11 +78,22 @@ AesIcmCipher::AesIcmCipher(kd_dir_t d) : Cipher(d), key_(u_int32_t(DEFAULT_KEY_L
init();
}
+
+AesIcmCipher::AesIcmCipher(kd_dir_t d, bool a) : Cipher(d, a), key_(u_int32_t(DEFAULT_KEY_LENGTH/8)), salt_(u_int32_t(SALT_LENGTH))
+{
+ init();
+}
+
AesIcmCipher::AesIcmCipher(kd_dir_t d, u_int16_t key_length) : Cipher(d), key_(u_int32_t(key_length/8)), salt_(u_int32_t(SALT_LENGTH))
{
init(key_length);
}
+AesIcmCipher::AesIcmCipher(kd_dir_t d, bool a, u_int16_t key_length) : Cipher(d, a), key_(u_int32_t(key_length/8)), salt_(u_int32_t(SALT_LENGTH))
+{
+ init(key_length);
+}
+
void AesIcmCipher::init(u_int16_t key_length)
{
#ifndef USE_SSL_CRYPTO
@@ -130,10 +141,11 @@ void AesIcmCipher::calcCtr(KeyDerivation& kd, seq_nr_t seq_nr, sender_id_t sende
{
kd.generate(dir_, LABEL_SATP_SALT, seq_nr, salt_);
-#ifdef ANYTUN_02_COMPAT
- if(!salt_[u_int32_t(0)])
- salt_[u_int32_t(0)] = 1;
-#endif
+
+ if(anytun02_compat_) {
+ if(!salt_[u_int32_t(0)])
+ salt_[u_int32_t(0)] = 1;
+ }
std::memcpy(ctr_.salt_.buf_, salt_.getBuf(), SALT_LENGTH);
ctr_.salt_.zero_ = 0;