aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/examples/dsa_sign.cpp2
-rw-r--r--doc/examples/eax_test.cpp4
-rw-r--r--doc/examples/hash_quickly.cpp2
-rw-r--r--doc/examples/pqg_gen.cpp4
-rw-r--r--doc/examples/row_encryptor.cpp13
-rw-r--r--doc/examples/xor_ciph.cpp17
6 files changed, 28 insertions, 14 deletions
diff --git a/doc/examples/dsa_sign.cpp b/doc/examples/dsa_sign.cpp
index 1ef81d424..16b8acd5a 100644
--- a/doc/examples/dsa_sign.cpp
+++ b/doc/examples/dsa_sign.cpp
@@ -62,7 +62,7 @@ int main(int argc, char* argv[])
return 1;
}
- PK_Signer signer(*dsakey, "EMSA1(SHA-1)");
+ PK_Signer signer(*dsakey, get_emsa("EMSA1(SHA-1)"));
DataSource_Stream in(message);
byte buf[4096] = { 0 };
diff --git a/doc/examples/eax_test.cpp b/doc/examples/eax_test.cpp
index ea20bd0a6..07564c097 100644
--- a/doc/examples/eax_test.cpp
+++ b/doc/examples/eax_test.cpp
@@ -54,7 +54,7 @@ void eax_test(const std::string& algo,
EAX_Encryption* enc;
Pipe pipe(new Hex_Decoder,
- enc = new EAX_Encryption(algo),
+ enc = new EAX_Encryption(get_block_cipher(algo)),
new Hex_Encoder);
enc->set_key(key);
@@ -82,7 +82,7 @@ void eax_test(const std::string& algo,
{
EAX_Decryption* dec;
Pipe pipe2(new Hex_Decoder,
- dec = new EAX_Decryption(algo),
+ dec = new EAX_Decryption(get_block_cipher(algo)),
new Hex_Encoder);
dec->set_key(key);
diff --git a/doc/examples/hash_quickly.cpp b/doc/examples/hash_quickly.cpp
index d8d991d9e..e719a7178 100644
--- a/doc/examples/hash_quickly.cpp
+++ b/doc/examples/hash_quickly.cpp
@@ -63,7 +63,7 @@ int main(int argc, char* argv[])
const std::string hash = "SHA-1";
- //set_fastest_implementation(hash, rng);
+ set_fastest_implementation(hash, rng);
// Here we intentionally use the 'old style' lookup interface
// which will also respect the provider settings. Or can use:
diff --git a/doc/examples/pqg_gen.cpp b/doc/examples/pqg_gen.cpp
index 5cb3703d6..7e173c11b 100644
--- a/doc/examples/pqg_gen.cpp
+++ b/doc/examples/pqg_gen.cpp
@@ -97,7 +97,9 @@ bool check(RandomNumberGenerator& rng,
u32bit qbits = (p.bits() <= 1024) ? 160 : 256;
- bool found = generate_dsa_primes(rng, our_p, our_q,
+ Algorithm_Factory& af = global_state().algorithm_factory();
+
+ bool found = generate_dsa_primes(rng, af, our_p, our_q,
p.bits(), qbits, seed);
if(!found) /* bad seed */
diff --git a/doc/examples/row_encryptor.cpp b/doc/examples/row_encryptor.cpp
index f78332335..0960480c1 100644
--- a/doc/examples/row_encryptor.cpp
+++ b/doc/examples/row_encryptor.cpp
@@ -2,6 +2,7 @@
#include <memory>
#include <sstream>
#include <iostream>
+#include <stdexcept>
#include <botan/botan.h>
#include <botan/filters.h>
@@ -47,8 +48,16 @@ Row_Encryptor::Row_Encryptor(const std::string& passphrase,
/*
Save pointers to the EAX objects so we can change the IV as needed
*/
- enc_pipe.append(eax_enc = new EAX_Encryption("Serpent"));
- dec_pipe.append(eax_dec = new EAX_Decryption("Serpent"));
+
+ Algorithm_Factory& af = global_state().algorithm_factory();
+
+ const BlockCipher* proto = af.prototype_block_cipher("Serpent");
+
+ if(!proto)
+ throw std::runtime_error("Could not get a Serpent proto object");
+
+ enc_pipe.append(eax_enc = new EAX_Encryption(proto->clone()));
+ dec_pipe.append(eax_dec = new EAX_Decryption(proto->clone()));
eax_enc->set_key(key);
eax_dec->set_key(key);
diff --git a/doc/examples/xor_ciph.cpp b/doc/examples/xor_ciph.cpp
index a8632911c..670276802 100644
--- a/doc/examples/xor_ciph.cpp
+++ b/doc/examples/xor_ciph.cpp
@@ -3,10 +3,12 @@
and use your own cipher object. DO NOT make up your own ciphers. Please.
Written by Jack Lloyd ([email protected]) on Feb 17, 2004
+ Update November 21 2008 for new algorithm factory in 1.8
This file is in the public domain
*/
-#include <botan/base.h>
+
+#include <botan/stream_cipher.h>
#include <botan/init.h>
using namespace Botan;
@@ -24,7 +26,7 @@ class XOR_Cipher : public StreamCipher
XOR_Cipher() : StreamCipher(1, 32) { mask_pos = 0; }
private:
void cipher(const byte[], byte[], u32bit);
- void key(const byte[], u32bit);
+ void key_schedule(const byte[], u32bit);
SecureVector<byte> mask;
u32bit mask_pos;
@@ -39,7 +41,7 @@ void XOR_Cipher::cipher(const byte in[], byte out[], u32bit length)
}
}
-void XOR_Cipher::key(const byte key[], u32bit length)
+void XOR_Cipher::key_schedule(const byte key[], u32bit length)
{
mask.set(key, length);
}
@@ -50,15 +52,16 @@ void XOR_Cipher::key(const byte key[], u32bit length)
#include <vector>
#include <cstring>
-#include <botan/look_add.h>
#include <botan/lookup.h>
#include <botan/filters.h>
#include <botan/libstate.h>
int main()
{
- add_algorithm(global_state(), new XOR_Cipher); // make it available to use
- global_state().add_alias("Vernam", "XOR"); // make Vernam an alias for XOR
+
+ LibraryInitializer init;
+
+ global_state().algorithm_factory().add_stream_cipher(new XOR_Cipher, "app");
// a hex key value
SymmetricKey key("010203040506070809101112AAFF");
@@ -71,7 +74,7 @@ int main()
padding method, such as "/CBC/PKCS7".
*/
Pipe enc(get_cipher("XOR", key, ENCRYPTION), new Hex_Encoder);
- Pipe dec(new Hex_Decoder, get_cipher("Vernam", key, DECRYPTION));
+ Pipe dec(new Hex_Decoder, get_cipher("XOR", key, DECRYPTION));
// I think the pigeons are actually asleep at midnight...
std::string secret = "The pigeon flys at midnight.";