Boost logo

Boost :

Subject: [boost] [gsoc] Concept check
From: Kasra (kasra_n500_at_[hidden])
Date: 2009-04-01 08:20:02


Hi,

I have decided to use the following concept for my gsco proposal regarding boost.crypto.

The dilema at the moment what is the minimum contiguous ranges concept?

Any suggestiong over the design?

concept CryptoBuffer // which is a variable sized buffer that
                     // uses an allocator that securely deletes.

concept BlockCipher
{
        typename value_type;
        typename size_type;
        typename traits_type;

        auto key(void) const throw();

        template<CryptoBuffer CB>
        void key(const CB& ) const throw(invalid_key_size);

        template<CryptoBuffer CB>
        void encrypt(CB&, const CB& ) const throw(bad_state);

        template<CryptoBuffer CB>
        void decrypt(CB&, const CB& ) const throw(bad_state);
};

struct crypto_stream_parallel_encryption { };
struct crypto_stream_parallel_decryption { };

struct crypto_stream_parallel
        : crypto_stream_parallel_encryption,
        crypto_stream_parallel_decryption{ };

concept ModeOfOperation
{
        typename value_type;
        typename size_type;
        typename block_cipher_type;
        typename category;
        
        static constexpr size_type transform_size;
        static constexpr size_type state_size;

        const auto cipher() const throw();

        void create() throw();

        template<CryptoBuffer CB0, CryptoBuffer CB1>
        size_type update(CB0& , const CB1&);

        template<CryptoBuffer CB0, CryptoBuffer CB1>
        size_type update_final_block(CB0& , const CB1&);
};

concept StreamCipher
{
        typename value_type;
        typename size_type;
        typename block_cipher_type;
        typename category;

        static constexpr size_type transform_size;
        static constexpr size_type state_size;

        const auto cipher() const throw();

        void create() throw();

        template<CryptoBuffer CB0, CryptoBuffer CB1>
        size_type update(CB0& , const CB1&);

        template<CryptoBuffer CB0, CryptoBuffer CB1>
        size_type update_final_block(CB0& , const CB1&);
};

concept HashAlgorithm
{
        typename value_type;
        typename size_type;
        typename block_cipher_type;
        typename category;

        static constexpr size_type state_size;
        static constexpr size_type transform_size;

        void create() throw();

        template<CryptoBuffer CB0, CryptoBuffer CB1>
        size_type update(const CB1&);

        template<CryptoBuffer CB0, CryptoBuffer CB1>
        size_type finalise(const CB1&);
};

Any suggestiong over the design?

-- Kasra

      


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