eme_raw.hpp
Go to the documentation of this file.
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2020 Mikhail Komarov <nemo@nil.foundation>
3 //
4 // MIT License
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
7 // of this software and associated documentation files (the "Software"), to deal
8 // in the Software without restriction, including without limitation the rights
9 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 // copies of the Software, and to permit persons to whom the Software is
11 // furnished to do so, subject to the following conditions:
12 //
13 // The above copyright notice and this permission notice shall be included in all
14 // copies or substantial portions of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 // SOFTWARE.
23 //---------------------------------------------------------------------------//
24 
25 #ifndef CRYPTO3_EME_RAW_HPP
26 #define CRYPTO3_EME_RAW_HPP
27 
29 
30 namespace nil {
31  namespace crypto3 {
32  namespace pubkey {
33  namespace padding {
34  template<typename Scheme, typename Hash>
35  class eme_raw : public eme<Scheme, Hash> {
36  public:
37  virtual size_t maximum_input_size(std::size_t key_bits) const override {
38  return key_bits / 8;
39  }
40 
41  template<typename UniformRandomBitGenerator, typename RandomNumberDistribution,
42  typename InputIterator, typename OutputIterator>
43  OutputIterator pad(InputIterator first, InputIterator last, OutputIterator out,
44  std::size_t key_length,
45  UniformRandomBitGenerator rand = UniformRandomBitGenerator()) {
46  return std::move(first, last, out);
47  }
48 
49  template<typename InputIterator, typename OutputIterator>
50  OutputIterator unpad(InputIterator first, InputIterator last, OutputIterator out) {
51  return ct::strip_leading_zeros(first, static_cast<size_t>(std::distance(first, last)));
52  }
53  };
54  } // namespace padding
55  } // namespace pubkey
56  } // namespace crypto3
57 } // namespace nil
58 
59 #endif
Definition: eme_raw.hpp:35
OutputIterator unpad(InputIterator first, InputIterator last, OutputIterator out)
Definition: eme_raw.hpp:50
virtual size_t maximum_input_size(std::size_t key_bits) const override
Definition: eme_raw.hpp:37
OutputIterator pad(InputIterator first, InputIterator last, OutputIterator out, std::size_t key_length, UniformRandomBitGenerator rand=UniformRandomBitGenerator())
Definition: eme_raw.hpp:43
OutputIterator move(const SinglePassRange &rng, OutputIterator result)
Definition: move.hpp:45
boost::mpl::apply< AccumulatorSet, tag::pubkey< ProcessingMode > >::type::result_type pubkey(const AccumulatorSet &acc)
Definition: accumulators/pubkey.hpp:106
Definition: pair.hpp:31
Encoding Method for Encryption.
Definition: eme.hpp:38