summaryrefslogtreecommitdiff
path: root/src/keyDerivation.cpp
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2009-01-14 15:58:35 +0000
committerChristian Pointner <equinox@anytun.org>2009-01-14 15:58:35 +0000
commit0b7b9d4be886f28440ac2a192fe278267e69e072 (patch)
tree6e2a47eab27cc78788cf19f37188468c9c91ad72 /src/keyDerivation.cpp
parentported uAnytun sequence window to anytun (diff)
ported cipher from uanytun to anytun
Diffstat (limited to 'src/keyDerivation.cpp')
-rw-r--r--src/keyDerivation.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/keyDerivation.cpp b/src/keyDerivation.cpp
index ed29fca..0bf74a7 100644
--- a/src/keyDerivation.cpp
+++ b/src/keyDerivation.cpp
@@ -53,9 +53,10 @@ void KeyDerivation::setLogKDRate(const u_int8_t log_rate)
//****** NullKeyDerivation ******
-void NullKeyDerivation::generate(satp_prf_label label, seq_nr_t seq_nr, Buffer& key)
+bool NullKeyDerivation::generate(satp_prf_label label, seq_nr_t seq_nr, Buffer& key)
{
for(u_int32_t i=0; i < key.getLength(); ++i) key[i] = 0;
+ return true;
}
#ifndef NOCRYPT
@@ -102,13 +103,13 @@ void AesIcmKeyDerivation::init(Buffer key, Buffer salt)
updateMasterKey();
}
-void AesIcmKeyDerivation::generate(satp_prf_label label, seq_nr_t seq_nr, Buffer& key)
+bool AesIcmKeyDerivation::generate(satp_prf_label label, seq_nr_t seq_nr, Buffer& key)
{
Lock lock(mutex_);
if(!cipher_)
{
cLog.msg(Log::PRIO_ERR) << "KeyDerivation::generate: cipher not opened";
- return;
+ return false;
}
gcry_error_t err = gcry_cipher_reset( cipher_ );
@@ -158,6 +159,7 @@ void AesIcmKeyDerivation::generate(satp_prf_label label, seq_nr_t seq_nr, Buffer
char buf[STERROR_TEXT_MAX];
buf[0] = 0;
cLog.msg(Log::PRIO_ERR) << "KeyDerivation::generate: Failed to set CTR: " << gpg_strerror_r(err, buf, STERROR_TEXT_MAX);
+ return false;
}
for(u_int32_t i=0; i < key.getLength(); ++i) key[i] = 0;
@@ -167,6 +169,7 @@ void AesIcmKeyDerivation::generate(satp_prf_label label, seq_nr_t seq_nr, Buffer
buf[0] = 0;
cLog.msg(Log::PRIO_ERR) << "KeyDerivation::generate: Failed to generate cipher bitstream: " << gpg_strerror_r(err, buf, STERROR_TEXT_MAX);
}
+ return true;
}
#endif