diff options
Diffstat (limited to 'src/pbe/pbes1/pbes1.cpp')
-rw-r--r-- | src/pbe/pbes1/pbes1.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/pbe/pbes1/pbes1.cpp b/src/pbe/pbes1/pbes1.cpp index 994b02d0a..ec5ebb253 100644 --- a/src/pbe/pbes1/pbes1.cpp +++ b/src/pbe/pbes1/pbes1.cpp @@ -80,12 +80,14 @@ void PBE_PKCS5v15::set_key(const std::string& passphrase) { PKCS5_PBKDF1 pbkdf(hash_function->clone()); - SymmetricKey key_and_iv = pbkdf.derive_key(16, passphrase, - &salt[0], salt.size(), - iterations); - - key.set(key_and_iv.begin(), 8); - iv.set(key_and_iv.begin() + 8, 8); + SecureVector<byte> key_and_iv = pbkdf.derive_key(16, passphrase, + &salt[0], salt.size(), + iterations).bits_of(); + + key.resize(8); + iv.resize(8); + copy_mem(&key[0], &key_and_iv[0], 8); + copy_mem(&iv[0], &key_and_iv[8], 8); } /* |