25 #ifndef CRYPTO3_HASH_STREAM_POSTPROCESSOR_HPP
26 #define CRYPTO3_HASH_STREAM_POSTPROCESSOR_HPP
30 #include <boost/assert.hpp>
31 #include <boost/concept_check.hpp>
33 #include <boost/range/concepts.hpp>
34 #include <boost/array.hpp>
36 #include <nil/crypto3/detail/pack.hpp>
44 template<
typename HashAccumulatorSet>
48 typename boost::mpl::front<typename accumulator_set_type::features_type>::type
accumulator_type;
50 typedef typename accumulator_type::hash_type
hash_type;
58 template<
typename HashAccumulatorSet>
62 typename boost::mpl::front<typename accumulator_set_type::features_type>::type
accumulator_type;
64 typedef typename accumulator_type::hash_type
hash_type;
73 template<
typename HashStateImpl>
80 typedef typename hash_state_impl_type::hash_type
hash_type;
82 typedef typename boost::mpl::apply<accumulator_set_type, accumulator_type>::type::result_type
85 template<
typename SinglePassRange>
88 BOOST_RANGE_CONCEPT_ASSERT((boost::SinglePassRangeConcept<const SinglePassRange>));
91 typename std::iterator_traits<typename SinglePassRange::iterator>::value_type value_type;
92 BOOST_STATIC_ASSERT(std::numeric_limits<value_type>::is_specialized);
93 typedef typename hash_type::template stream_processor<
95 std::numeric_limits<value_type>::digits + std::numeric_limits<value_type>::is_signed>::type
101 template<
typename InputIterator>
104 BOOST_CONCEPT_ASSERT((boost::InputIteratorConcept<InputIterator>));
106 typedef typename std::iterator_traits<InputIterator>::value_type value_type;
107 BOOST_STATIC_ASSERT(std::numeric_limits<value_type>::is_specialized);
108 typedef typename hash_type::template stream_processor<
110 std::numeric_limits<value_type>::digits + std::numeric_limits<value_type>::is_signed>::type
116 template<
typename T, std::
size_t Size>
117 inline operator std::array<T, Size>()
const {
119 boost::accumulators::extract_result<accumulator_type>(this->
accumulator_set);
120 std::array<T, Size> out;
121 std::copy(result.begin(), result.end(), out.end());
125 template<
typename T, std::
size_t Size>
126 inline operator boost::array<T, Size>()
const {
128 boost::accumulators::extract_result<accumulator_type>(this->
accumulator_set);
129 boost::array<T, Size> out;
130 std::copy(result.begin(), result.end(), out.end());
134 template<
typename OutputRange>
135 inline operator OutputRange()
const {
137 boost::accumulators::extract_result<accumulator_type>(this->
accumulator_set);
138 return OutputRange(result.begin(), result.end());
142 return boost::accumulators::extract_result<accumulator_type>(this->
accumulator_set);
149 template<
typename Integral,
150 typename =
typename std::enable_if<std::is_integral<Integral>::value &&
151 hash_type::digest_bits <=
152 std::numeric_limits<Integral>::digits>::type>
153 inline operator Integral()
const {
154 std::array<Integral, 1> out;
156 ::nil::crypto3::detail::pack_to<stream_endian::little_octet_big_bit>(res, out);
160 #ifndef CRYPTO3_RAW_HASH_STRING_OUTPUT
162 template<
typename Char,
typename CharTraits,
typename Alloc>
163 inline operator std::basic_string<Char, CharTraits, Alloc>()
const {
164 return std::to_string(
165 boost::accumulators::extract_result<accumulator_type>(this->
accumulator_set));
171 template<
typename HashStateImpl,
typename OutputIterator>
174 mutable OutputIterator out;
182 typedef typename hash_state_impl_type::hash_type
hash_type;
184 typedef typename boost::mpl::apply<accumulator_set_type, accumulator_type>::type::result_type
187 template<
typename SinglePassRange>
190 BOOST_CONCEPT_ASSERT((boost::SinglePassRangeConcept<const SinglePassRange>));
193 typename std::iterator_traits<typename SinglePassRange::iterator>::value_type value_type;
194 BOOST_STATIC_ASSERT(std::numeric_limits<value_type>::is_specialized);
195 typedef typename hash_type::template stream_processor<
197 std::numeric_limits<value_type>::digits + std::numeric_limits<value_type>::is_signed>::type
203 template<
typename InputIterator>
207 out(std::
move(out)) {
208 BOOST_CONCEPT_ASSERT((boost::InputIteratorConcept<InputIterator>));
210 typedef typename std::iterator_traits<InputIterator>::value_type value_type;
211 BOOST_STATIC_ASSERT(std::numeric_limits<value_type>::is_specialized);
212 typedef typename hash_type::template stream_processor<
214 std::numeric_limits<value_type>::digits + std::numeric_limits<value_type>::is_signed>::type
224 inline operator OutputIterator()
const {
226 boost::accumulators::extract_result<accumulator_type>(this->
accumulator_set);
227 return std::move(result.cbegin(), result.cend(), out);
boost::accumulators::accumulator_set< digest< ProcessingMode::block_bits >, boost::accumulators::features< accumulators::tag::block< ProcessingMode > >, std::size_t > accumulator_set
Accumulator set with pre-defined block cipher accumulator params.
Definition: block/include/nil/crypto3/block/cipher_state.hpp:51
OutputIterator move(const SinglePassRange &rng, OutputIterator result)
Definition: move.hpp:45
Definition: hash_state.hpp:43
Definition: hash_value.hpp:172
hash_state_impl_type::accumulator_set_type accumulator_set_type
Definition: hash_value.hpp:180
boost::mpl::apply< accumulator_set_type, accumulator_type >::type::result_type result_type
Definition: hash_value.hpp:185
HashStateImpl hash_state_impl_type
Definition: hash_value.hpp:177
itr_hash_impl(const SinglePassRange &range, OutputIterator out, accumulator_set_type &&ise)
Definition: hash_value.hpp:188
hash_state_impl_type::accumulator_type accumulator_type
Definition: hash_value.hpp:179
itr_hash_impl(InputIterator first, InputIterator last, OutputIterator out, accumulator_set_type &&ise)
Definition: hash_value.hpp:204
hash_state_impl_type::hash_type hash_type
Definition: hash_value.hpp:182
Definition: hash_value.hpp:74
hash_state_impl_type::accumulator_set_type accumulator_set_type
Definition: hash_value.hpp:78
range_hash_impl(const SinglePassRange &range, accumulator_set_type &&ise)
Definition: hash_value.hpp:86
boost::mpl::apply< accumulator_set_type, accumulator_type >::type::result_type result_type
Definition: hash_value.hpp:83
range_hash_impl(InputIterator first, InputIterator last, accumulator_set_type &&ise)
Definition: hash_value.hpp:102
hash_state_impl_type::hash_type hash_type
Definition: hash_value.hpp:80
hash_state_impl_type::accumulator_type accumulator_type
Definition: hash_value.hpp:77
HashStateImpl hash_state_impl_type
Definition: hash_value.hpp:75
Definition: hash_value.hpp:45
boost::mpl::front< typename accumulator_set_type::features_type >::type accumulator_type
Definition: hash_value.hpp:48
accumulator_set_type & accumulator_set
Definition: hash_value.hpp:55
ref_hash_impl(accumulator_set_type &&stream_hash)
Definition: hash_value.hpp:52
accumulator_type::hash_type hash_type
Definition: hash_value.hpp:50
HashAccumulatorSet accumulator_set_type
Definition: hash_value.hpp:46
Definition: hash_value.hpp:59
accumulator_set_type accumulator_set
Definition: hash_value.hpp:70
accumulator_type::hash_type hash_type
Definition: hash_value.hpp:64
value_hash_impl(accumulator_set_type &&stream_hash)
Definition: hash_value.hpp:66
boost::mpl::front< typename accumulator_set_type::features_type >::type accumulator_type
Definition: hash_value.hpp:62
HashAccumulatorSet accumulator_set_type
Definition: hash_value.hpp:60