[hash] Is there any interest in cryptographic hash functions?

Hi to all, I have looked at the current state of the crypto namespace. The current code is not really modular so I propose the following new/modified features: we have a defenition for "cipher" that is "some thing" that encrypts/decrypts message within a stream. This thing could perform this operation on any arbitary message length. for block ciphers the use of mode of operation implements this stream encasulation of the underlying block_cipher. stream ciphers easily allow for such encapsulations. wipe algorithms that are used to wipe streams/buffers with specified patterns i.e. Gutmann wipe algorithm secure allocator would use a default wipe algorithm i.e. all zero for wipe of buffers. namespace boost { namespace crypto { template < ... > class block_cipher // abstract class for ALL block ciphers to inherit from { public: virtual void setkey(...) = 0; virtual void encrypt(...) = 0; virtual void decrypt(...) = 0; }; template < ... > class padding // abstract class for ALL padding algos to inherit from { public: virtual bool allways() = 0; // if the padding allways pads/unpads virtual size_t padsize(size_t count) = 0; virtual size_t unpadsize(size_t count) = 0; virtual size_t pad(T*dest, const T*src, size_t count) = 0; virtual size_t unpad(T*dest, const T*src, size_t count) = 0; }; enum wipe_mode { random = 0x2, pattern = 0x4, unknown = ~(random | pattern) }; typedef struct wipe_method_t { const wipe_mode mode; const void *pattern; const size_t length; }; template < ... > class wipe_algorithm { private: int counter; std::vector < wipe_method_t > pass; public: wipe_method_t& next() { return pass[counter++]; } ; wipe_method_t& previous() { return pass[--counter]; } ; wipe_method_t& at(int pass) { return pass[pass]; } ; }; template < ... , class wipe_algorithm> class basic_wipe : public wipe_algorithm < ... > { }; template < ... , class wipe_algorithm > // we allready have it, modifications need to be minor class secure_alocator { }; template < class cipher > class basic_crypto_stream : public std::basic_ios <...> { /* * This class allows for transparent encryption/decryption * and clears buffer (or even wipes) buffers used during the process */ public: . . . }; typedef basic_crypto_stream< char, ... > crypto_stream; template < ... > class basic_hash { . . . protected: virtual void transform_create() = 0; virtual void transform_add(const void* data, size_t data_bits) { // this class managed a bit-maped buffering using word oriented // operations, thus it would comply with new standards while being // efficient. the classes which inherit from this do not need to // re-implement this function }; virtual void transform_finalise() = 0; public: . . . }; TODO: implement : Hash algorithms: SHA-2 family, Whirlpool, (future : SHA-3) Stream ciphers : salsa20, and some of the ECRYPT finalysts }} // crypto , boost namespaces Optomisation: the AES (Rijndael) uses a very slow code, the speed could be increases by up to a factor of 5 if pre-computed s-box tables are used, this would cause for an increase of ~4KB in the class size, however, i think the speed penalties are to high for the current implementation. I think it is enought for now open for comments, suggestions and anything else

Hello Kasra and thanks for your interest in the crypto library,
I have looked at the current state of the crypto namespace. The current code is not really modular so I propose the following new/modified features:
I contest that statement, it is in fact quite modular, you are merely adding abstract base classes to impose an interface for the different models which is not necessary when using templates to compose objects.
wipe algorithms that are used to wipe streams/buffers with specified patterns i.e. Gutmann wipe algorithm secure allocator would use a default wipe algorithm i.e. all zero for wipe of buffers.
Okay, wipe algorithms are interesting but I don't see added value in clearing memory to zeros vs clearing the memory with some other pattern or random data. For current RAM technologies the original data is destroyed with a simple memset to zero.
namespace boost { namespace crypto {
template < ... > class block_cipher // abstract class for ALL block ciphers to inherit from { public: virtual void setkey(...) = 0; virtual void encrypt(...) = 0; virtual void decrypt(...) = 0; };
How is that better than template<class Cipher, class Mode, class Padding> struct block_cipher; ?
template < class cipher > class basic_crypto_stream : public std::basic_ios <...>
I think that's a good idea.
the AES (Rijndael) uses a very slow code, the speed could be increases by up to a factor of 5 if pre-computed s-box tables are used, this would cause for an increase of ~4KB in the class size, however, i think the speed penalties are to high for the current implementation.
I am interested in that optimization, I have deliberately chosen the 'slower' variant as it follows the original paper more closely and made it a little easier for me to implement. I would like to see benchmarks of this variant. Btw, I don't remember if the version in the vault has copyright tags but it is available as public domain code from me. Kevin
participants (2)
-
Kasra (Math & ComSci)
-
Kevin Sopp