summaryrefslogtreecommitdiff
path: root/keyDerivation.cpp
diff options
context:
space:
mode:
authorErwin Nindl <nine@wirdorange.org>2007-12-11 12:58:31 +0000
committerErwin Nindl <nine@wirdorange.org>2007-12-11 12:58:31 +0000
commit56bc3b4f9135fde1764e15046bf7799538aff18b (patch)
tree7457703e2f350144484ed2eb2e348b3f8d80cb0e /keyDerivation.cpp
parentserialisation working!!! (diff)
now set really key in KD
Diffstat (limited to 'keyDerivation.cpp')
-rw-r--r--keyDerivation.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/keyDerivation.cpp b/keyDerivation.cpp
index 2c3d84b..c9db305 100644
--- a/keyDerivation.cpp
+++ b/keyDerivation.cpp
@@ -52,26 +52,26 @@ void KeyDerivation::init(Buffer key, Buffer salt)
if( !gcry_control(GCRYCTL_ANY_INITIALIZATION_P) )
{
if( !gcry_check_version( MIN_GCRYPT_VERSION ) ) {
- cLog.msg(Log::PRIO_ERR) << "Invalid Version of libgcrypt, should be >= " << MIN_GCRYPT_VERSION;
+ cLog.msg(Log::PRIO_ERR) << "KeyDerivation::init: Invalid Version of libgcrypt, should be >= " << MIN_GCRYPT_VERSION;
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;
-// }
+ // /* 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);
if( err ) {
- cLog.msg(Log::PRIO_ERR) << "Failed to finish the initialization of libgcrypt: " << gpg_strerror( err );
+ cLog.msg(Log::PRIO_ERR) << "KeyDerivation::init: Failed to finish the initialization of libgcrypt: " << gpg_strerror( err );
return;
} else {
cLog.msg(Log::PRIO_NOTICE) << "KeyDerivation::init: libgcrypt init finished";
@@ -80,10 +80,15 @@ void KeyDerivation::init(Buffer key, Buffer salt)
err = gcry_cipher_open( &cipher_, GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_CTR, 0 );
if( err ) {
- cLog.msg(Log::PRIO_ERR) << "Failed to open cipher: " << gpg_strerror( err );
+ cLog.msg(Log::PRIO_ERR) << "KeyDerivation::init: Failed to open cipher: " << gpg_strerror( err );
return;
}
+ // FIXXME: hardcoded keysize!
+ err = gcry_cipher_setkey( cipher_, key.getBuf(), 16 );
+ if( err )
+ cLog.msg(Log::PRIO_ERR) << "KeyDerivation::init: Failed to set cipher key: " << gpg_strerror( err );
+
salt_ = SyncBuffer(salt);
}