aboutsummaryrefslogtreecommitdiffstats
path: root/doc/examples/encrypt2.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2011-04-04 03:43:52 +0000
committerlloyd <[email protected]>2011-04-04 03:43:52 +0000
commit3b9bfbd07c3723662832caf5b1efe04de28b656d (patch)
treeee2a9324f384efead6e5bb87ac8374e7e8734c90 /doc/examples/encrypt2.cpp
parent04db054f1ae8de572ee9c0cfe227e76f84096bd6 (diff)
Convert most of the documentation to reStructured Text, adding
a makefile to build it with Sphinx (http://sphinx.pocoo.org/). Previously credits.txt listed public domain code sources; instead directly credit the authors in the relevant files and delete that file. Drop the draft FIPS 140 security policy; I can't imagine FIPS 140 validation will ever happen, and if it does, I don't want anything to do with it. Also drop the internals doc, which was so out of date (and incomplete) as to be worthless. Move the tutorials and InSiTo pdfs into old/ for the time being, until anything relevant from them can be filtered out and converted into RST.
Diffstat (limited to 'doc/examples/encrypt2.cpp')
-rw-r--r--doc/examples/encrypt2.cpp66
1 files changed, 0 insertions, 66 deletions
diff --git a/doc/examples/encrypt2.cpp b/doc/examples/encrypt2.cpp
deleted file mode 100644
index 41f4fb478..000000000
--- a/doc/examples/encrypt2.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
-* (C) 2009 Jack Lloyd
-*
-* Distributed under the terms of the Botan license
-*/
-
-#include <botan/botan.h>
-#include <botan/pbkdf2.h>
-#include <botan/hmac.h>
-#include <botan/sha160.h>
-
-#include <fstream>
-
-using namespace Botan;
-
-int main()
- {
- Botan::LibraryInitializer init;
-
- AutoSeeded_RNG rng;
-
- std::string passphrase = "secret";
-
- std::ifstream infile("readme.txt");
- std::ofstream outfile("readme.txt.enc");
-
- PKCS5_PBKDF2 pbkdf2(new HMAC(new SHA_160));
-
- const u32bit PBKDF2_ITERATIONS = 8192;
-
- SecureVector<byte> salt(8);
- rng.randomize(&salt[0], salt.size());
-
- SecureVector<byte> master_key = pbkdf2.derive_key(48, passphrase,
- &salt[0], salt.size(),
- PBKDF2_ITERATIONS).bits_of();
-
- KDF* kdf = get_kdf("KDF2(SHA-1)");
-
- SymmetricKey key = kdf->derive_key(20, master_key, "cipher key");
-
- SymmetricKey mac_key = kdf->derive_key(20, master_key, "hmac key");
-
- InitializationVector iv = kdf->derive_key(8, master_key, "cipher iv");
-
- Pipe pipe(new Fork(
- new Chain(
- get_cipher("Blowfish/CBC/PKCS7", key, iv, ENCRYPTION),
- new Base64_Encoder,
- new DataSink_Stream(outfile)
- ),
- new Chain(
- new MAC_Filter("HMAC(SHA-1)", mac_key),
- new Hex_Encoder)
- )
- );
-
- outfile.write((const char*)salt.begin(), salt.size());
-
- pipe.start_msg();
- infile >> pipe;
- pipe.end_msg();
-
- SecureVector<byte> hmac = pipe.read_all(1);
- outfile.write((const char*)hmac.begin(), hmac.size());
- }