[gsoc] Range/Iterator in Boost.Crypto

Hi all, I have got more excited about GSoc so I have been working ahead of schedule to get boost.crypto going. At this time I have completed my schedule until 05/05/2009. Here I need some advice on the design principles for my interface. I have decided to implemented a generic buffer called crypto_buffer, this buffer is intended to implement bufferings for a stream (stream ciphers/hash algorithms). The class head is as follows: // this class manages 1 block of state_size that the stream is deposited on // also arbitary numbers of buffers that the underlying transformer // wished to include. // when the buffer # 1 is filled in with data the transformer is called // to process the buffer and this is continue untill the end of buffer template< class Transformer, // the algorithm that will transform the buffer size_t Buffers, // the # of buffers this transformer will manage bool FixedOutput, // if the output buffer is constant bool BitBuffered // byte or bit buffered? > class crypto_buffer { public: typedef Transformer transformer_type; typedef BOOST_DEDUCED_TYPENAME transformer_type::size_type size_type; ... // the size of input block which ensured optimal buffering performance static constexpr size_type transform_size = transformer_type::transform_size; // the size of blocks which is stored between transition states static constexpr size_type state_size = transformer_type::state_size; private: transformer_type m_transformer; public: // create a new stream void create(); // transform all but the final stream block template<CryptoBuffer bufferT> size_type transform(bufferT& , const bufferT&); // transform the final block of our stream template<CryptoBuffer bufferT> size_type transform_final(bufferT& , const bufferT&); }; Notice the 'CryptoBuffer' concept. The question is how to implement this concept. Iterators and Ranges is suggested by other previously, however, how could we impelemnt them for the above interface? The reason for my question is I am not sure if I could implement a library that doesn't require for example a block-cipher to have 1-block of input in contiguous memory. For hash functions and stream ciphers is much easier since the contiguity requirement could be a byte or a bit which could be done easily. Any suggestions?? With Best Regards -- Kasra Nassiri
participants (1)
-
Kasra