25 #ifndef CRYPTO3_PBKDF_VALUE_HPP
26 #define CRYPTO3_PBKDF_VALUE_HPP
28 #include <type_traits>
31 #include <boost/assert.hpp>
32 #include <boost/concept_check.hpp>
34 #include <boost/range/concepts.hpp>
40 template<
typename MacAccumulator>
41 struct ref_cipher_impl {
44 typename boost::mpl::front<typename accumulator_set_type::features_type>::type
accumulator_type;
46 typedef typename MacAccumulator::mode_type
mode_type;
55 template<
typename MacAccumulator>
56 struct value_cipher_impl {
59 typename boost::mpl::front<typename accumulator_set_type::features_type>::type
accumulator_type;
61 typedef typename MacAccumulator::mode_type
mode_type;
70 template<
typename MacStateImpl>
71 struct range_cipher_impl :
public MacStateImpl {
77 typedef typename cipher_state_impl_type::mode_type
mode_type;
78 typedef typename cipher_state_impl_type::cipher_type
cipher_type;
80 typedef typename boost::mpl::apply<accumulator_set_type, accumulator_type>::type::result_type
83 template<
typename SinglePassRange>
86 BOOST_RANGE_CONCEPT_ASSERT((boost::SinglePassRangeConcept<const SinglePassRange>));
89 typename std::iterator_traits<typename SinglePassRange::iterator>::value_type value_type;
90 BOOST_STATIC_ASSERT(std::numeric_limits<value_type>::is_specialized);
91 typedef typename cipher_type::template stream_processor<
93 std::numeric_limits<value_type>::digits + std::numeric_limits<value_type>::is_signed>::type
99 template<
typename InputIterator>
102 BOOST_CONCEPT_ASSERT((boost::InputIteratorConcept<InputIterator>));
104 typedef typename std::iterator_traits<InputIterator>::value_type value_type;
105 BOOST_STATIC_ASSERT(std::numeric_limits<value_type>::is_specialized);
106 typedef typename cipher_type::template stream_processor<
108 std::numeric_limits<value_type>::digits + std::numeric_limits<value_type>::is_signed>::type
114 template<
typename T, std::
size_t Size>
115 inline operator std::array<T, Size>()
const {
117 boost::accumulators::extract_result<accumulator_type>(this->
accumulator_set);
118 std::array<T, Size> out;
119 std::copy(result.begin(), result.end(), out.end());
123 template<
typename T, std::
size_t Size>
124 inline operator boost::array<T, Size>()
const {
126 boost::accumulators::extract_result<accumulator_type>(this->
accumulator_set);
127 boost::array<T, Size> out;
128 std::copy(result.begin(), result.end(), out.end());
132 template<
typename OutputRange>
133 operator OutputRange()
const {
135 boost::accumulators::extract_result<accumulator_type>(this->
accumulator_set);
136 return OutputRange(result.cbegin(), result.cend());
140 return boost::accumulators::extract_result<accumulator_type>(this->
accumulator_set);
147 #ifdef CRYPTO3_ASCII_STRING_CODEC_OUTPUT
149 template<
typename Char,
typename CharTraits,
typename Alloc>
150 operator std::basic_string<Char, CharTraits, Alloc>()
const {
151 return std::to_string(
152 boost::accumulators::extract_result<accumulator_type>(this->
accumulator_set));
158 template<
typename MacStateImpl,
typename OutputIterator>
159 struct itr_cipher_impl :
public MacStateImpl {
161 mutable OutputIterator out;
169 typedef typename cipher_state_impl_type::mode_type
mode_type;
172 typedef typename boost::mpl::apply<accumulator_set_type, accumulator_type>::type::result_type
175 template<
typename SinglePassRange>
177 MacStateImpl(ise), out(std::
move(out)) {
178 BOOST_CONCEPT_ASSERT((boost::SinglePassRangeConcept<const SinglePassRange>));
181 typename std::iterator_traits<typename SinglePassRange::iterator>::value_type value_type;
182 BOOST_STATIC_ASSERT(std::numeric_limits<value_type>::is_specialized);
183 typedef typename cipher_type::template stream_processor<
185 std::numeric_limits<value_type>::digits + std::numeric_limits<value_type>::is_signed>::type
191 template<
typename InputIterator>
195 out(std::
move(out)) {
196 BOOST_CONCEPT_ASSERT((boost::InputIteratorConcept<InputIterator>));
198 typedef typename std::iterator_traits<InputIterator>::value_type value_type;
199 BOOST_STATIC_ASSERT(std::numeric_limits<value_type>::is_specialized);
200 typedef typename cipher_type::template stream_processor<
202 std::numeric_limits<value_type>::digits + std::numeric_limits<value_type>::is_signed>::type
208 operator OutputIterator()
const {
210 boost::accumulators::extract_result<accumulator_type>(this->
accumulator_set);
212 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
cipher_state_impl_type::cipher_type cipher_type
Definition: pbkdf_value.hpp:170
cipher_state_impl_type::accumulator_type accumulator_type
Definition: pbkdf_value.hpp:166
itr_cipher_impl(InputIterator first, InputIterator last, OutputIterator out, const accumulator_set_type &ise)
Definition: pbkdf_value.hpp:192
cipher_state_impl_type::accumulator_set_type accumulator_set_type
Definition: pbkdf_value.hpp:167
itr_cipher_impl(const SinglePassRange &range, OutputIterator out, const accumulator_set_type &ise)
Definition: pbkdf_value.hpp:176
boost::mpl::apply< accumulator_set_type, accumulator_type >::type::result_type result_type
Definition: pbkdf_value.hpp:173
MacStateImpl cipher_state_impl_type
Definition: pbkdf_value.hpp:164
cipher_state_impl_type::mode_type mode_type
Definition: pbkdf_value.hpp:169
boost::mpl::apply< accumulator_set_type, accumulator_type >::type::result_type result_type
Definition: pbkdf_value.hpp:81
cipher_state_impl_type::cipher_type cipher_type
Definition: pbkdf_value.hpp:78
cipher_state_impl_type::accumulator_type accumulator_type
Definition: pbkdf_value.hpp:74
cipher_state_impl_type::mode_type mode_type
Definition: pbkdf_value.hpp:77
range_cipher_impl(const SinglePassRange &range, const accumulator_set_type &ise)
Definition: pbkdf_value.hpp:84
range_cipher_impl(InputIterator first, InputIterator last, const accumulator_set_type &ise)
Definition: pbkdf_value.hpp:100
MacStateImpl cipher_state_impl_type
Definition: pbkdf_value.hpp:72
cipher_state_impl_type::accumulator_set_type accumulator_set_type
Definition: pbkdf_value.hpp:75
ref_cipher_impl(const accumulator_set_type &acc)
Definition: pbkdf_value.hpp:49
accumulator_set_type & accumulator_set
Definition: passhash_value.hpp:52
MacAccumulator accumulator_set_type
Definition: pbkdf_value.hpp:42
MacAccumulator::mode_type mode_type
Definition: pbkdf_value.hpp:46
boost::mpl::front< typename accumulator_set_type::features_type >::type accumulator_type
Definition: pbkdf_value.hpp:44
mode_type::encoder_type cipher_type
Definition: pbkdf_value.hpp:47
boost::mpl::front< typename accumulator_set_type::features_type >::type accumulator_type
Definition: pbkdf_value.hpp:59
MacAccumulator accumulator_set_type
Definition: pbkdf_value.hpp:57
MacAccumulator::mode_type mode_type
Definition: pbkdf_value.hpp:61
accumulator_set_type accumulator_set
Definition: passhash_value.hpp:67
value_cipher_impl(const accumulator_set_type &acc)
Definition: pbkdf_value.hpp:64
mode_type::encoder_type cipher_type
Definition: pbkdf_value.hpp:62