aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorlloyd <[email protected]>2006-09-06 00:20:54 +0000
committerlloyd <[email protected]>2006-09-06 00:20:54 +0000
commit1877da91b1633e87c3326b7672e01ab387499588 (patch)
treeabfe8c5765ed89d5e0b65efffd50e7a4eb6fb3f8 /include
parentd65f9a38be079c52257dff6663b816de206ce99d (diff)
Remove the Algorithm class; the only members it exposed where name() and
clear(), which have been declared in the appropriate places in (former) subclasses of Algorithm
Diffstat (limited to 'include')
-rw-r--r--include/base.h44
-rw-r--r--include/mode_pad.h5
-rw-r--r--include/s2k.h4
3 files changed, 31 insertions, 22 deletions
diff --git a/include/base.h b/include/base.h
index bccf92e25..70c28ea02 100644
--- a/include/base.h
+++ b/include/base.h
@@ -17,27 +17,15 @@ namespace Botan {
static const u32bit DEFAULT_BUFFERSIZE = BOTAN_DEFAULT_BUFFER_SIZE;
/*************************************************
-* Algorithm *
-*************************************************/
-class Algorithm
- {
- public:
- virtual void clear() throw() {};
- virtual std::string name() const = 0;
- virtual ~Algorithm() {}
- Algorithm() {}
- private:
- Algorithm(const Algorithm&) {}
- Algorithm& operator=(const Algorithm&) { return (*this); }
- };
-
-/*************************************************
* Symmetric Algorithm *
*************************************************/
-class SymmetricAlgorithm : public virtual Algorithm
+class SymmetricAlgorithm
{
public:
const u32bit MAXIMUM_KEYLENGTH, MINIMUM_KEYLENGTH, KEYLENGTH_MULTIPLE;
+
+ virtual std::string name() const = 0;
+
void set_key(const SymmetricKey&) throw(Invalid_Key_Length);
void set_key(const byte[], u32bit) throw(Invalid_Key_Length);
bool valid_keylength(u32bit) const;
@@ -54,11 +42,15 @@ class BlockCipher : public SymmetricAlgorithm
{
public:
const u32bit BLOCK_SIZE;
+
void encrypt(const byte in[], byte out[]) const { enc(in, out); }
void decrypt(const byte in[], byte out[]) const { dec(in, out); }
void encrypt(byte block[]) const { enc(block, block); }
void decrypt(byte block[]) const { dec(block, block); }
+
virtual BlockCipher* clone() const = 0;
+ virtual void clear() throw() {};
+
BlockCipher(u32bit, u32bit, u32bit = 0, u32bit = 1);
virtual ~BlockCipher() {}
private:
@@ -82,6 +74,8 @@ class StreamCipher : public SymmetricAlgorithm
virtual void seek(u32bit);
virtual StreamCipher* clone() const = 0;
+ virtual void clear() throw() {};
+
StreamCipher(u32bit, u32bit = 0, u32bit = 1, u32bit = 0);
virtual ~StreamCipher() {}
private:
@@ -91,7 +85,7 @@ class StreamCipher : public SymmetricAlgorithm
/*************************************************
* Buffered Computation *
*************************************************/
-class BufferedComputation : public virtual Algorithm
+class BufferedComputation
{
public:
const u32bit OUTPUT_LENGTH;
@@ -118,7 +112,11 @@ class HashFunction : public BufferedComputation
{
public:
const u32bit HASH_BLOCK_SIZE;
+
virtual HashFunction* clone() const = 0;
+ virtual std::string name() const = 0;
+ virtual void clear() throw() {};
+
HashFunction(u32bit, u32bit = 0);
virtual ~HashFunction() {}
};
@@ -130,9 +128,12 @@ class MessageAuthenticationCode : public BufferedComputation,
public SymmetricAlgorithm
{
public:
- virtual std::string name() const = 0;
- virtual MessageAuthenticationCode* clone() const = 0;
virtual bool verify_mac(const byte[], u32bit);
+
+ virtual MessageAuthenticationCode* clone() const = 0;
+ virtual std::string name() const = 0;
+ virtual void clear() throw() {};
+
MessageAuthenticationCode(u32bit, u32bit, u32bit = 0, u32bit = 1);
virtual ~MessageAuthenticationCode() {}
};
@@ -151,13 +152,16 @@ class EntropySource
/*************************************************
* Random Number Generator *
*************************************************/
-class RandomNumberGenerator : public Algorithm
+class RandomNumberGenerator
{
public:
virtual void randomize(byte[], u32bit) throw(PRNG_Unseeded) = 0;
virtual bool is_seeded() const { return true; }
+ virtual void clear() throw() {};
+
void add_entropy(const byte[], u32bit);
u32bit add_entropy(EntropySource&, bool = true);
+
virtual ~RandomNumberGenerator() {}
private:
virtual void add_randomness(const byte[], u32bit) = 0;
diff --git a/include/mode_pad.h b/include/mode_pad.h
index 38cb55487..a2c56f2eb 100644
--- a/include/mode_pad.h
+++ b/include/mode_pad.h
@@ -14,13 +14,16 @@ namespace Botan {
/*************************************************
* Block Cipher Mode Padding Method *
*************************************************/
-class BlockCipherModePaddingMethod : public Algorithm
+class BlockCipherModePaddingMethod
{
public:
+ virtual std::string name() const = 0;
+
virtual void pad(byte[], u32bit, u32bit) const = 0;
virtual u32bit unpad(const byte[], u32bit) const = 0;
virtual u32bit pad_bytes(u32bit, u32bit) const;
virtual bool valid_blocksize(u32bit) const = 0;
+ virtual ~BlockCipherModePaddingMethod() {}
};
/*************************************************
diff --git a/include/s2k.h b/include/s2k.h
index 0b1eb0b50..b2db53e8c 100644
--- a/include/s2k.h
+++ b/include/s2k.h
@@ -13,10 +13,12 @@ namespace Botan {
/*************************************************
* S2K Interface *
*************************************************/
-class S2K : public Algorithm
+class S2K
{
public:
virtual S2K* clone() const = 0;
+ virtual std::string name() const = 0;
+ virtual void clear() {}
OctetString derive_key(u32bit, const std::string&) const;