From d97760a781a793d35dfe75367dd8d80ab59bbb49 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Wed, 18 Feb 2009 13:08:59 +0000 Subject: added anytun02 compat runtime switch --- src/cipher.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src/cipher.cpp') 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; -- cgit v1.2.3