aboutsummaryrefslogtreecommitdiffstats
path: root/doc/examples/encrypt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'doc/examples/encrypt.cpp')
-rw-r--r--doc/examples/encrypt.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/doc/examples/encrypt.cpp b/doc/examples/encrypt.cpp
index 4999fa086..b5568ca50 100644
--- a/doc/examples/encrypt.cpp
+++ b/doc/examples/encrypt.cpp
@@ -124,22 +124,24 @@ int main(int argc, char* argv[])
AutoSeeded_RNG rng;
- std::auto_ptr<S2K> s2k(get_s2k("PBKDF2(SHA-1)"));
+ std::auto_ptr<PBKDF> pbkdf(get_pbkdf("PBKDF2(SHA-1)"));
SecureVector<byte> salt(8);
rng.randomize(&salt[0], salt.size());
const u32bit PBKDF2_ITERATIONS = 8192;
- SymmetricKey bc_key = s2k->derive_key(key_len, "BLK" + passphrase,
- &salt[0], salt.size(),
- PBKDF2_ITERATIONS);
- InitializationVector iv = s2k->derive_key(iv_len, "IVL" + passphrase,
- &salt[0], salt.size(),
- PBKDF2_ITERATIONS);
- SymmetricKey mac_key = s2k->derive_key(16, "MAC" + passphrase,
- &salt[0], salt.size(),
- PBKDF2_ITERATIONS);
+ SymmetricKey bc_key = pbkdf->derive_key(key_len, "BLK" + passphrase,
+ &salt[0], salt.size(),
+ PBKDF2_ITERATIONS);
+
+ InitializationVector iv = pbkdf->derive_key(iv_len, "IVL" + passphrase,
+ &salt[0], salt.size(),
+ PBKDF2_ITERATIONS);
+
+ SymmetricKey mac_key = pbkdf->derive_key(16, "MAC" + passphrase,
+ &salt[0], salt.size(),
+ PBKDF2_ITERATIONS);
// Just to be all fancy we even write a (simple) header.
out << "-------- ENCRYPTED FILE --------" << std::endl;