From 66b163323d39ac5c0be30fd0b1c0fd91b64a55f3 Mon Sep 17 00:00:00 2001 From: lloyd Date: Fri, 29 Oct 2010 15:15:30 +0000 Subject: Make MemoryRegion::set protected, change all callers --- src/pbe/pbes1/pbes1.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/pbe') 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 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); } /* -- cgit v1.2.3