aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-11-01 17:25:48 +0000
committerlloyd <[email protected]>2010-11-01 17:25:48 +0000
commit04cb06b11bbb64a6bf947abec8849d1bf02ec093 (patch)
treedc6508dfcc6084d7e52cfb2861462b8614a4dec4
parentba069386cdfb31720fa5a305c81baa18a0c8504d (diff)
Add new top-level algorithm which provides basic functionality: name
query, clearing, and cloning. Applies to ciphers, hashes, MACs, and PBKDFs. May extend to KDFs later as well. A single combined hierarchy in particular will make the algo_factory much simpler.
-rw-r--r--src/algo_base/buf_comp.h (renamed from src/utils/buf_comp/buf_comp.h)8
-rw-r--r--src/algo_base/info.txt (renamed from src/sym_algo/info.txt)0
-rw-r--r--src/algo_base/key_spec.h (renamed from src/sym_algo/key_spec.h)0
-rw-r--r--src/algo_base/sym_algo.h (renamed from src/sym_algo/sym_algo.h)18
-rw-r--r--src/algo_base/symkey.cpp (renamed from src/sym_algo/symkey.cpp)0
-rw-r--r--src/algo_base/symkey.h (renamed from src/sym_algo/symkey.h)0
-rw-r--r--src/benchmark/benchmark.cpp4
-rw-r--r--src/benchmark/info.txt2
-rw-r--r--src/block/info.txt2
-rw-r--r--src/cms/info.txt2
-rw-r--r--src/entropy/entropy_src.h9
-rw-r--r--src/entropy/info.txt2
-rw-r--r--src/filters/info.txt2
-rw-r--r--src/hash/hash.h15
-rw-r--r--src/hash/info.txt2
-rw-r--r--src/kdf/ssl_prf/info.txt2
-rw-r--r--src/mac/info.txt3
-rw-r--r--src/mac/mac.h2
-rw-r--r--src/pbkdf/info.txt2
-rw-r--r--src/pbkdf/pbkdf.h14
-rw-r--r--src/pubkey/info.txt2
-rw-r--r--src/stream/info.txt2
-rw-r--r--src/utils/buf_comp/info.txt3
23 files changed, 30 insertions, 66 deletions
diff --git a/src/utils/buf_comp/buf_comp.h b/src/algo_base/buf_comp.h
index 78955fe87..ec9b89152 100644
--- a/src/utils/buf_comp/buf_comp.h
+++ b/src/algo_base/buf_comp.h
@@ -1,5 +1,5 @@
/*
-* BufferedComputation
+* Buffered Computation
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
@@ -17,11 +17,9 @@ namespace Botan {
* This class represents any kind of computation which uses an internal
* state, such as hash functions or MACs
*/
-class BOTAN_DLL BufferedComputation
+class BOTAN_DLL Buffered_Computation
{
public:
- virtual ~BufferedComputation() {}
-
/**
* @return length of the output of this function in bytes
*/
@@ -130,8 +128,6 @@ class BOTAN_DLL BufferedComputation
return final();
}
private:
- BufferedComputation& operator=(const BufferedComputation&);
-
/**
* Add more data to the computation
* @param input is an input buffer
diff --git a/src/sym_algo/info.txt b/src/algo_base/info.txt
index cfdd9b691..cfdd9b691 100644
--- a/src/sym_algo/info.txt
+++ b/src/algo_base/info.txt
diff --git a/src/sym_algo/key_spec.h b/src/algo_base/key_spec.h
index 7788bb988..7788bb988 100644
--- a/src/sym_algo/key_spec.h
+++ b/src/algo_base/key_spec.h
diff --git a/src/sym_algo/sym_algo.h b/src/algo_base/sym_algo.h
index aea0d06ba..705c7d00a 100644
--- a/src/sym_algo/sym_algo.h
+++ b/src/algo_base/sym_algo.h
@@ -8,26 +8,20 @@
#ifndef BOTAN_SYMMETRIC_ALGORITHM_H__
#define BOTAN_SYMMETRIC_ALGORITHM_H__
-#include <botan/types.h>
+#include <botan/algo_base.h>
#include <botan/key_spec.h>
#include <botan/exceptn.h>
#include <botan/symkey.h>
+#include <botan/types.h>
namespace Botan {
/**
* This class represents a symmetric algorithm object.
*/
-class BOTAN_DLL SymmetricAlgorithm
+class BOTAN_DLL SymmetricAlgorithm : public Algorithm
{
public:
- virtual ~SymmetricAlgorithm() {}
-
- /**
- * Zeroize internal state
- */
- virtual void clear() = 0;
-
/**
* @return object describing limits on key size
*/
@@ -60,12 +54,6 @@ class BOTAN_DLL SymmetricAlgorithm
}
/**
- * The name of the algorithm.
- * @return name of the algorithm
- */
- virtual std::string name() const = 0;
-
- /**
* Set the symmetric key of this object.
* @param key the SymmetricKey to be set.
*/
diff --git a/src/sym_algo/symkey.cpp b/src/algo_base/symkey.cpp
index 56648d9c5..56648d9c5 100644
--- a/src/sym_algo/symkey.cpp
+++ b/src/algo_base/symkey.cpp
diff --git a/src/sym_algo/symkey.h b/src/algo_base/symkey.h
index 6735b2b87..6735b2b87 100644
--- a/src/sym_algo/symkey.h
+++ b/src/algo_base/symkey.h
diff --git a/src/benchmark/benchmark.cpp b/src/benchmark/benchmark.cpp
index 1a27cffac..dbccd45c1 100644
--- a/src/benchmark/benchmark.cpp
+++ b/src/benchmark/benchmark.cpp
@@ -19,9 +19,9 @@ namespace Botan {
namespace {
/**
-* Benchmark BufferedComputation (hash or MAC)
+* Benchmark Buffered_Computation (hash or MAC)
*/
-std::pair<u64bit, u64bit> bench_buf_comp(BufferedComputation* buf_comp,
+std::pair<u64bit, u64bit> bench_buf_comp(Buffered_Computation* buf_comp,
u64bit nanoseconds_max,
const byte buf[], size_t buf_len)
{
diff --git a/src/benchmark/info.txt b/src/benchmark/info.txt
index 3a817435a..30bb679ca 100644
--- a/src/benchmark/info.txt
+++ b/src/benchmark/info.txt
@@ -3,7 +3,7 @@ define RUNTIME_BENCHMARKING
<requires>
algo_factory
block
-buf_comp
+algo_base
hash
mac
rng
diff --git a/src/block/info.txt b/src/block/info.txt
index b4302a6d8..c9757cadc 100644
--- a/src/block/info.txt
+++ b/src/block/info.txt
@@ -1,5 +1,5 @@
define BLOCK_CIPHER
<requires>
-sym_algo
+algo_base
</requires>
diff --git a/src/cms/info.txt b/src/cms/info.txt
index 708f1d592..dc2110ae5 100644
--- a/src/cms/info.txt
+++ b/src/cms/info.txt
@@ -11,6 +11,6 @@ oid_lookup
pem
pubkey
sha1
-sym_algo
+algo_base
x509cert
</requires>
diff --git a/src/entropy/entropy_src.h b/src/entropy/entropy_src.h
index 97ebe8bd9..d713598d9 100644
--- a/src/entropy/entropy_src.h
+++ b/src/entropy/entropy_src.h
@@ -94,16 +94,17 @@ class BOTAN_DLL Entropy_Accumulator
};
/**
-* Entropy accumulator that puts the input into a BufferedComputation
+* Entropy accumulator that puts the input into a Buffered_Computation
*/
-class BOTAN_DLL Entropy_Accumulator_BufferedComputation : public Entropy_Accumulator
+class BOTAN_DLL Entropy_Accumulator_BufferedComputation :
+ public Entropy_Accumulator
{
public:
/**
* @param sink the hash or MAC we are feeding the poll data into
* @param goal is how many bits we want to collect in this poll
*/
- Entropy_Accumulator_BufferedComputation(BufferedComputation& sink,
+ Entropy_Accumulator_BufferedComputation(Buffered_Computation& sink,
size_t goal) :
Entropy_Accumulator(goal), entropy_sink(sink) {}
@@ -113,7 +114,7 @@ class BOTAN_DLL Entropy_Accumulator_BufferedComputation : public Entropy_Accumul
entropy_sink.update(bytes, length);
}
- BufferedComputation& entropy_sink;
+ Buffered_Computation& entropy_sink;
};
/**
diff --git a/src/entropy/info.txt b/src/entropy/info.txt
index a048df7d9..d991577f7 100644
--- a/src/entropy/info.txt
+++ b/src/entropy/info.txt
@@ -1,3 +1,3 @@
<requires>
-buf_comp
+algo_base
</requires>
diff --git a/src/filters/info.txt b/src/filters/info.txt
index 95d411c76..51c75017d 100644
--- a/src/filters/info.txt
+++ b/src/filters/info.txt
@@ -40,5 +40,5 @@ libstate
mac
rng
stream
-sym_algo
+algo_base
</requires>
diff --git a/src/hash/hash.h b/src/hash/hash.h
index af411fb87..366c929b5 100644
--- a/src/hash/hash.h
+++ b/src/hash/hash.h
@@ -9,6 +9,7 @@
#define BOTAN_HASH_FUNCTION_BASE_CLASS_H__
#include <botan/buf_comp.h>
+#include <botan/algo_base.h>
#include <string>
namespace Botan {
@@ -16,7 +17,8 @@ namespace Botan {
/**
* This class represents hash function (message digest) objects
*/
-class BOTAN_DLL HashFunction : public BufferedComputation
+class BOTAN_DLL HashFunction : public Buffered_Computation,
+ public Algorithm
{
public:
/**
@@ -25,21 +27,10 @@ class BOTAN_DLL HashFunction : public BufferedComputation
virtual HashFunction* clone() const = 0;
/**
- * Get the name of this algorithm.
- * @return name of this algorithm
- */
- virtual std::string name() const = 0;
-
- /**
* The hash block size as defined for this algorithm
*/
virtual size_t hash_block_size() const { return 0; }
- /**
- * Reset the internal state of this object.
- */
- virtual void clear() = 0;
-
private:
HashFunction& operator=(const HashFunction&);
};
diff --git a/src/hash/info.txt b/src/hash/info.txt
index a048df7d9..d991577f7 100644
--- a/src/hash/info.txt
+++ b/src/hash/info.txt
@@ -1,3 +1,3 @@
<requires>
-buf_comp
+algo_base
</requires>
diff --git a/src/kdf/ssl_prf/info.txt b/src/kdf/ssl_prf/info.txt
index 68355ff40..0ef297119 100644
--- a/src/kdf/ssl_prf/info.txt
+++ b/src/kdf/ssl_prf/info.txt
@@ -3,5 +3,5 @@ define SSL_V3_PRF
<requires>
md5
sha1
-sym_algo
+algo_base
</requires>
diff --git a/src/mac/info.txt b/src/mac/info.txt
index 6a74d8445..d991577f7 100644
--- a/src/mac/info.txt
+++ b/src/mac/info.txt
@@ -1,4 +1,3 @@
<requires>
-buf_comp
-sym_algo
+algo_base
</requires>
diff --git a/src/mac/mac.h b/src/mac/mac.h
index f46cd7e35..d42092908 100644
--- a/src/mac/mac.h
+++ b/src/mac/mac.h
@@ -17,7 +17,7 @@ namespace Botan {
/**
* This class represents Message Authentication Code (MAC) objects.
*/
-class BOTAN_DLL MessageAuthenticationCode : public BufferedComputation,
+class BOTAN_DLL MessageAuthenticationCode : public Buffered_Computation,
public SymmetricAlgorithm
{
public:
diff --git a/src/pbkdf/info.txt b/src/pbkdf/info.txt
index 861b6f760..d991577f7 100644
--- a/src/pbkdf/info.txt
+++ b/src/pbkdf/info.txt
@@ -1,3 +1,3 @@
<requires>
-sym_algo
+algo_base
</requires>
diff --git a/src/pbkdf/pbkdf.h b/src/pbkdf/pbkdf.h
index 91883f9e2..e8e841562 100644
--- a/src/pbkdf/pbkdf.h
+++ b/src/pbkdf/pbkdf.h
@@ -8,6 +8,7 @@
#ifndef BOTAN_PBKDF_H__
#define BOTAN_PBKDF_H__
+#include <botan/algo_base.h>
#include <botan/symkey.h>
namespace Botan {
@@ -17,7 +18,7 @@ namespace Botan {
* implementations. Converts a password into a key using a salt
* and iterated hashing to make brute force attacks harder.
*/
-class BOTAN_DLL PBKDF
+class BOTAN_DLL PBKDF : public Algorithm
{
public:
@@ -26,16 +27,7 @@ class BOTAN_DLL PBKDF
*/
virtual PBKDF* clone() const = 0;
- /**
- * Get the algorithm name.
- * @return name of this PBKDF algorithm
- */
- virtual std::string name() const = 0;
-
- /**
- * Clear this objects internal values.
- */
- virtual void clear() {}
+ void clear() {}
/**
* Derive a key from a passphrase
diff --git a/src/pubkey/info.txt b/src/pubkey/info.txt
index 956a5e369..5f36f63c4 100644
--- a/src/pubkey/info.txt
+++ b/src/pubkey/info.txt
@@ -39,5 +39,5 @@ pbe
pem
pk_pad
rng
-sym_algo
+algo_base
</requires>
diff --git a/src/stream/info.txt b/src/stream/info.txt
index 68d6c46d6..c242b47e7 100644
--- a/src/stream/info.txt
+++ b/src/stream/info.txt
@@ -1,5 +1,5 @@
define STREAM_CIPHER
<requires>
-sym_algo
+algo_base
</requires>
diff --git a/src/utils/buf_comp/info.txt b/src/utils/buf_comp/info.txt
deleted file mode 100644
index b91fe5082..000000000
--- a/src/utils/buf_comp/info.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-<requires>
-alloc
-</requires>