Function encode_length

Synopsis

#include "breeze/cryptography/merkle_damgard_engine.hpp"

static void encode_length(word_type const (&len)[max_words], byte_type *dest)

Description

No description yet.

Source

Lines 98-119 in breeze/cryptography/merkle_damgard_engine.hpp.

static void encode_length( word_type const ( &len )[ max_words ],
                           byte_type * dest )
{
    typedef word_type len_type[ max_words ] ;
    //      Note:
    //          a) len[ 0 ] is always the *least* significant word
    //          b) the order in which the words will "appear" in
    //             [dest, end), and the order of the bytes within
    //             each word, follow EndianPolicy
    // -------------------------------------------------------------------
    int const           step = word_width / byte_width ;
    for ( int i = 0 ; i < max_words ; ++ i ) {
        std::ptrdiff_t const
                        index =
            step * EndianPolicy::template index< len_type,
                                                 word_type >( i ) ;
        breeze::endian_store< EndianPolicy >(
            len[ max_words - 1 - i ], dest + index ) ;
    }
}