Boost logo

Boost :

Subject: [boost] [gsoc] Range/Iterator in Boost.Crypto
From: Kasra (kasra_n500_at_[hidden])
Date: 2009-04-04 11:50:37


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

      


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk