aboutsummaryrefslogtreecommitdiffstats
path: root/src/constructs
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-02-01 16:29:38 +0000
committerlloyd <[email protected]>2010-02-01 16:29:38 +0000
commit454e45b7c4fece11a7f43ffa412148b4a274c90f (patch)
tree5ae87c2104fba534548e59fa477d6a5f2f5a5e29 /src/constructs
parentae6a404ec14cc3c86a96cd3e5c67c9c23be38147 (diff)
Modify the S2K interface. Instead of being stateful in terms of the salt
and iteration count, force it to be passed to each call to derive_key. So remove current_salt, set_iterations, new_random_salt, and change_salt functions from S2K interface. Update examples and test application to match. While I was in there, change the passhash example to use 64 bit salts and 128 bit PBKDF2 outputs.
Diffstat (limited to 'src/constructs')
-rw-r--r--src/constructs/cryptobox/cryptobox.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/constructs/cryptobox/cryptobox.cpp b/src/constructs/cryptobox/cryptobox.cpp
index 20435fa59..c862b5c50 100644
--- a/src/constructs/cryptobox/cryptobox.cpp
+++ b/src/constructs/cryptobox/cryptobox.cpp
@@ -48,10 +48,10 @@ std::string encrypt(const byte input[], u32bit input_len,
rng.randomize(pbkdf_salt.begin(), pbkdf_salt.size());
PKCS5_PBKDF2 pbkdf(new HMAC(new SHA_512));
- pbkdf.change_salt(pbkdf_salt.begin(), pbkdf_salt.size());
- pbkdf.set_iterations(PBKDF_ITERATIONS);
- OctetString mk = pbkdf.derive_key(PBKDF_OUTPUT_LEN, passphrase);
+ OctetString mk = pbkdf.derive_key(PBKDF_OUTPUT_LEN, passphrase,
+ &pbkdf_salt[0], pbkdf_salt.size(),
+ PBKDF_ITERATIONS);
SymmetricKey cipher_key(mk.begin(), CIPHER_KEY_LEN);
SymmetricKey mac_key(mk.begin() + CIPHER_KEY_LEN, MAC_KEY_LEN);
@@ -109,10 +109,10 @@ std::string decrypt(const byte input[], u32bit input_len,
SecureVector<byte> pbkdf_salt(ciphertext + VERSION_CODE_LEN, PBKDF_SALT_LEN);
PKCS5_PBKDF2 pbkdf(new HMAC(new SHA_512));
- pbkdf.change_salt(pbkdf_salt.begin(), pbkdf_salt.size());
- pbkdf.set_iterations(PBKDF_ITERATIONS);
- OctetString mk = pbkdf.derive_key(PBKDF_OUTPUT_LEN, passphrase);
+ OctetString mk = pbkdf.derive_key(PBKDF_OUTPUT_LEN, passphrase,
+ &pbkdf_salt[0], pbkdf_salt.size(),
+ PBKDF_ITERATIONS);
SymmetricKey cipher_key(mk.begin(), CIPHER_KEY_LEN);
SymmetricKey mac_key(mk.begin() + CIPHER_KEY_LEN, MAC_KEY_LEN);