From 62d31032352f8d857f31d89872fd42b98501e1c3 Mon Sep 17 00:00:00 2001 From: Erwin Nindl Date: Sat, 8 Dec 2007 17:57:31 +0000 Subject: * added AuthTag class * bugfixes in keyderivation, aesicmcypher * removed authtag functins temorarly from anytun.cpp --- keyDerivation.cpp | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'keyDerivation.cpp') diff --git a/keyDerivation.cpp b/keyDerivation.cpp index 5b7b739..2c8a646 100644 --- a/keyDerivation.cpp +++ b/keyDerivation.cpp @@ -53,14 +53,17 @@ void KeyDerivation::init(Buffer key, Buffer salt) return; } - /* Allocate a pool of 16k secure memory. This also drops priviliges - * on some systems. */ - err = gcry_control(GCRYCTL_INIT_SECMEM, 16384, 0); - if( err ) - { - std::cerr << "Failed to allocate 16k secure memory: " << gpg_strerror( err ) << std::endl; - return; - } + // do NOT allocate a pool of secure memory! + // this is NOT thread safe! + +// /* Allocate a pool of 16k secure memory. This also drops priviliges +// * on some systems. */ +// err = gcry_control(GCRYCTL_INIT_SECMEM, 16384, 0); +// if( err ) +// { +// std::cerr << "Failed to allocate 16k secure memory: " << gpg_strerror( err ) << std::endl; +// return; +// } /* Tell Libgcrypt that initialization has completed. */ err = gcry_control(GCRYCTL_INITIALIZATION_FINISHED); @@ -79,6 +82,8 @@ void KeyDerivation::init(Buffer key, Buffer salt) return; } + salt_ = salt; + initialized_ = true; } void KeyDerivation::setLogKDRate(const uint8_t log_rate) @@ -96,6 +101,11 @@ void KeyDerivation::generate(satp_prf_label label, seq_nr_t seq_nr, Buffer& key, u_int8_t tmp_key_id[16]; + if(!initialized_) { + std::cout << "ERROR: keyderivation::generate: keyderivation not initialized yet!" << std::endl; + return; + } + // see at: http://tools.ietf.org/html/rfc3711#section-4.3 // * Let r = index DIV key_derivation_rate (with DIV as defined above). // * Let key_id =