diff options
-rw-r--r-- | checks/block.cpp | 13 | ||||
-rw-r--r-- | checks/dolook.cpp | 10 | ||||
-rw-r--r-- | doc/log.txt | 1 | ||||
-rw-r--r-- | src/cms/cms_algo.cpp | 2 | ||||
-rw-r--r-- | src/filters/base64/base64.h | 4 | ||||
-rw-r--r-- | src/filters/basefilt.cpp | 10 | ||||
-rw-r--r-- | src/filters/basefilt.h | 6 | ||||
-rw-r--r-- | src/filters/buf_filt.h | 5 | ||||
-rw-r--r-- | src/filters/bzip2/bzip2.h | 4 | ||||
-rw-r--r-- | src/filters/filter.h | 4 | ||||
-rw-r--r-- | src/filters/filters.h | 6 | ||||
-rw-r--r-- | src/filters/hex/hex.h | 4 | ||||
-rw-r--r-- | src/filters/pipe.cpp | 2 | ||||
-rw-r--r-- | src/filters/secqueue.h | 2 | ||||
-rw-r--r-- | src/filters/zlib/zlib.h | 4 | ||||
-rw-r--r-- | src/pbe/pbes1/pbes1.cpp | 6 | ||||
-rw-r--r-- | src/pbe/pbes1/pbes1.h | 2 | ||||
-rw-r--r-- | src/pbe/pbes2/pbes2.cpp | 6 | ||||
-rw-r--r-- | src/pbe/pbes2/pbes2.h | 2 |
19 files changed, 86 insertions, 7 deletions
diff --git a/checks/block.cpp b/checks/block.cpp index c90e3e499..d2a38f216 100644 --- a/checks/block.cpp +++ b/checks/block.cpp @@ -24,8 +24,13 @@ using namespace Botan; class ECB_Encryption_ErrorCheck : public Filter { public: + std::string name() const + { return "ECB_ErrCheck(" + cipher->name() + ")"; } + void write(const byte[], u32bit); + void end_msg(); + ECB_Encryption_ErrorCheck(const std::string& cipher_name, const std::string&, const SymmetricKey& key) : @@ -40,8 +45,14 @@ class ECB_Encryption_ErrorCheck : public Filter cipher->set_key(key); position = 0; } + ~ECB_Encryption_ErrorCheck() - { delete cipher; delete input_hash; delete decrypt_hash; } + { + delete cipher; + delete input_hash; + delete decrypt_hash; + } + private: const u32bit BLOCKSIZE; BlockCipher* cipher; diff --git a/checks/dolook.cpp b/checks/dolook.cpp index e9be25614..1eecfa9fc 100644 --- a/checks/dolook.cpp +++ b/checks/dolook.cpp @@ -62,8 +62,11 @@ using namespace Botan; class S2K_Filter : public Filter { public: + std::string name() const { return s2k->name(); } + void write(const byte in[], u32bit len) { passphrase += std::string(reinterpret_cast<const char*>(in), len); } + void end_msg() { SymmetricKey x = s2k->derive_key(outlen, passphrase, @@ -71,14 +74,15 @@ class S2K_Filter : public Filter iterations); send(x.bits_of()); } + S2K_Filter(S2K* algo, const SymmetricKey& s, u32bit o, u32bit i) { s2k = algo; outlen = o; iterations = i; salt = s.bits_of(); - } + ~S2K_Filter() { delete s2k; } private: std::string passphrase; @@ -91,6 +95,8 @@ class S2K_Filter : public Filter class RNG_Filter : public Filter { public: + std::string name() const { return rng->name(); } + void write(const byte[], u32bit); RNG_Filter(RandomNumberGenerator* r) : rng(r) {} @@ -102,6 +108,8 @@ class RNG_Filter : public Filter class KDF_Filter : public Filter { public: + std::string name() const { return "KDF_Filter"; } + void write(const byte in[], u32bit len) { secret.append(in, len); } void end_msg() diff --git a/doc/log.txt b/doc/log.txt index 447f6dc0a..d47fbbb42 100644 --- a/doc/log.txt +++ b/doc/log.txt @@ -1,6 +1,7 @@ * 1.9.9-dev, ????-??-?? - Add new X509::BER_encode and PKCS8::BER_encode + - Give all Filter objects a name() function - Add Keyed_Filter::valid_iv_length - Increase default iteration counts for private key encryption - Fix compilation of mp_asm64 on 64-bit MIPS with GCC 4.4 and later diff --git a/src/cms/cms_algo.cpp b/src/cms/cms_algo.cpp index 748aa73da..686a79b4e 100644 --- a/src/cms/cms_algo.cpp +++ b/src/cms/cms_algo.cpp @@ -31,6 +31,8 @@ SecureVector<byte> do_rfc3217_wrap(RandomNumberGenerator& rng, class Flip_Bytes : public Filter { public: + std::string name() const { return "Fip_Bytes"; } + void write(const byte data[], u32bit length) { buf.append(data, length); diff --git a/src/filters/base64/base64.h b/src/filters/base64/base64.h index aca02da14..0f35859cc 100644 --- a/src/filters/base64/base64.h +++ b/src/filters/base64/base64.h @@ -20,6 +20,8 @@ class BOTAN_DLL Base64_Encoder : public Filter public: static void encode(const byte in[3], byte out[4]); + std::string name() const { return "Base64_Encoder"; } + /** * Input a part of a message to the encoder. * @param input the message to input as a byte array @@ -61,6 +63,8 @@ class BOTAN_DLL Base64_Decoder : public Filter static bool is_valid(byte); + std::string name() const { return "Base64_Decoder"; } + /** * Input a part of a message to the decoder. * @param input the message to input as a byte array diff --git a/src/filters/basefilt.cpp b/src/filters/basefilt.cpp index 124c0a887..008d04b02 100644 --- a/src/filters/basefilt.cpp +++ b/src/filters/basefilt.cpp @@ -39,6 +39,11 @@ Chain::Chain(Filter* filters[], u32bit count) } } +std::string Chain::name() const + { + return "Chain"; + } + /* * Fork Constructor */ @@ -56,4 +61,9 @@ Fork::Fork(Filter* filters[], u32bit count) set_next(filters, count); } +std::string Fork::name() const + { + return "Fork"; + } + } diff --git a/src/filters/basefilt.h b/src/filters/basefilt.h index 81e897bc4..a5c3dcd41 100644 --- a/src/filters/basefilt.h +++ b/src/filters/basefilt.h @@ -18,6 +18,8 @@ namespace Botan { struct BOTAN_DLL BitBucket : public Filter { void write(const byte[], u32bit) {} + + std::string name() const { return "BitBucket"; } }; /** @@ -31,6 +33,8 @@ class BOTAN_DLL Chain : public Fanout_Filter public: void write(const byte input[], u32bit length) { send(input, length); } + std::string name() const; + /** * Construct a chain of up to four filters. The filters are set * up in the same order as the arguments. @@ -56,6 +60,8 @@ class BOTAN_DLL Fork : public Fanout_Filter void write(const byte input[], u32bit length) { send(input, length); } void set_port(u32bit n) { Fanout_Filter::set_port(n); } + std::string name() const; + /** * Construct a Fork filter with up to four forks. */ diff --git a/src/filters/buf_filt.h b/src/filters/buf_filt.h index 3acf1f809..1f5d7dae8 100644 --- a/src/filters/buf_filt.h +++ b/src/filters/buf_filt.h @@ -26,11 +26,6 @@ class BOTAN_DLL Buffered_Filter virtual ~Buffered_Filter() {} protected: - /** - * @return name of this filter object - */ - virtual std::string name() const = 0; - virtual void buffered_block(const byte input[], u32bit length) = 0; virtual void buffered_final(const byte input[], u32bit length) = 0; diff --git a/src/filters/bzip2/bzip2.h b/src/filters/bzip2/bzip2.h index 3b40dbe40..aacec8fa9 100644 --- a/src/filters/bzip2/bzip2.h +++ b/src/filters/bzip2/bzip2.h @@ -19,6 +19,8 @@ namespace Botan { class BOTAN_DLL Bzip_Compression : public Filter { public: + std::string name() const { return "Bzip_Compression"; } + void write(const byte input[], u32bit length); void start_msg(); void end_msg(); @@ -41,6 +43,8 @@ class BOTAN_DLL Bzip_Compression : public Filter class BOTAN_DLL Bzip_Decompression : public Filter { public: + std::string name() const { return "Bzip_Decompression"; } + void write(const byte input[], u32bit length); void start_msg(); void end_msg(); diff --git a/src/filters/filter.h b/src/filters/filter.h index 62c67b922..d5aa9725b 100644 --- a/src/filters/filter.h +++ b/src/filters/filter.h @@ -19,6 +19,10 @@ namespace Botan { class BOTAN_DLL Filter { public: + /** + * @return descriptive name for this filter + */ + virtual std::string name() const = 0; /** * Write a portion of a message to this filter. diff --git a/src/filters/filters.h b/src/filters/filters.h index 5953518d3..e2c7cb5ec 100644 --- a/src/filters/filters.h +++ b/src/filters/filters.h @@ -37,6 +37,8 @@ class BOTAN_DLL StreamCipher_Filter : public Keyed_Filter { public: + std::string name() const { return cipher->name(); } + /** * Write input data * @param input data @@ -108,6 +110,8 @@ class BOTAN_DLL Hash_Filter : public Filter void write(const byte input[], u32bit len) { hash->update(input, len); } void end_msg(); + std::string name() const { return hash->name(); } + /** * Construct a hash filter. * @param hash_fun the hash function to use @@ -144,6 +148,8 @@ class BOTAN_DLL MAC_Filter : public Keyed_Filter void write(const byte input[], u32bit len) { mac->update(input, len); } void end_msg(); + std::string name() const { return mac->name(); } + /** * Set the key of this filter. * @param key the key to set diff --git a/src/filters/hex/hex.h b/src/filters/hex/hex.h index b03b933bc..6698a61be 100644 --- a/src/filters/hex/hex.h +++ b/src/filters/hex/hex.h @@ -28,6 +28,8 @@ class BOTAN_DLL Hex_Encoder : public Filter */ static void encode(byte in, byte out[2], Case the_case = Uppercase); + std::string name() const { return "Hex_Encoder"; } + void write(const byte in[], u32bit length); void end_msg(); @@ -77,6 +79,8 @@ class BOTAN_DLL Hex_Decoder : public Filter */ static bool is_valid(byte c); + std::string name() const { return "Hex_Decoder"; } + void write(const byte[], u32bit); void end_msg(); diff --git a/src/filters/pipe.cpp b/src/filters/pipe.cpp index 77e4ae283..22718cd8c 100644 --- a/src/filters/pipe.cpp +++ b/src/filters/pipe.cpp @@ -22,6 +22,8 @@ class Null_Filter : public Filter public: void write(const byte input[], u32bit length) { send(input, length); } + + std::string name() const { return "Null"; } }; } diff --git a/src/filters/secqueue.h b/src/filters/secqueue.h index 3cb486024..483a31d60 100644 --- a/src/filters/secqueue.h +++ b/src/filters/secqueue.h @@ -19,6 +19,8 @@ namespace Botan { class BOTAN_DLL SecureQueue : public Fanout_Filter, public DataSource { public: + std::string name() const { return "Queue"; } + void write(const byte[], u32bit); u32bit read(byte[], u32bit); diff --git a/src/filters/zlib/zlib.h b/src/filters/zlib/zlib.h index 2aa83aadf..e1645e1ee 100644 --- a/src/filters/zlib/zlib.h +++ b/src/filters/zlib/zlib.h @@ -19,6 +19,8 @@ namespace Botan { class BOTAN_DLL Zlib_Compression : public Filter { public: + std::string name() const { return "Zlib_Compression"; } + void write(const byte input[], u32bit length); void start_msg(); void end_msg(); @@ -48,6 +50,8 @@ class BOTAN_DLL Zlib_Compression : public Filter class BOTAN_DLL Zlib_Decompression : public Filter { public: + std::string name() const { return "Zlib_Decompression"; } + void write(const byte input[], u32bit length); void start_msg(); void end_msg(); diff --git a/src/pbe/pbes1/pbes1.cpp b/src/pbe/pbes1/pbes1.cpp index a3e08d679..6e4c3f54d 100644 --- a/src/pbe/pbes1/pbes1.cpp +++ b/src/pbe/pbes1/pbes1.cpp @@ -153,6 +153,12 @@ OID PBE_PKCS5v15::get_oid() const throw Internal_Error("PBE-PKCS5 v1.5: get_oid() has run out of options"); } +std::string PBE_PKCS5v15::name() const + { + return "PBE-PKCS5v15(" + block_cipher->name() + "," + + hash_function->name() + ")"; + } + /* * PKCS#5 v1.5 PBE Constructor */ diff --git a/src/pbe/pbes1/pbes1.h b/src/pbe/pbes1/pbes1.h index d50c01f53..dcce38e24 100644 --- a/src/pbe/pbes1/pbes1.h +++ b/src/pbe/pbes1/pbes1.h @@ -21,6 +21,8 @@ namespace Botan { class BOTAN_DLL PBE_PKCS5v15 : public PBE { public: + std::string name() const; + void write(const byte[], u32bit); void start_msg(); void end_msg(); diff --git a/src/pbe/pbes2/pbes2.cpp b/src/pbe/pbes2/pbes2.cpp index 1ac16af8d..5b77acff5 100644 --- a/src/pbe/pbes2/pbes2.cpp +++ b/src/pbe/pbes2/pbes2.cpp @@ -207,6 +207,12 @@ bool PBE_PKCS5v20::known_cipher(const std::string& algo) return false; } +std::string PBE_PKCS5v20::name() const + { + return "PBE-PKCS5v20(" + block_cipher->name() + "," + + hash_function->name() + ")"; + } + /* * PKCS#5 v2.0 PBE Constructor */ diff --git a/src/pbe/pbes2/pbes2.h b/src/pbe/pbes2/pbes2.h index f24d572d0..4a021840a 100644 --- a/src/pbe/pbes2/pbes2.h +++ b/src/pbe/pbes2/pbes2.h @@ -27,6 +27,8 @@ class BOTAN_DLL PBE_PKCS5v20 : public PBE */ static bool known_cipher(const std::string& cipher); + std::string name() const; + void write(const byte[], u32bit); void start_msg(); void end_msg(); |