poly1305_policy.hpp
Go to the documentation of this file.
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2019 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_MAC_POLY1305_POLICY_HPP
26 #define CRYPTO3_MAC_POLY1305_POLICY_HPP
27 
28 #include <boost/integer.hpp>
29 
30 #include <boost/container/static_vector.hpp>
31 
33 
34 namespace nil {
35  namespace crypto3 {
36  namespace mac {
37  namespace detail {
38  struct poly1305_policy : public basic_functions<64> {
40 
42 
43  constexpr static const std::size_t word_bits = policy_type::word_bits;
45 
46  constexpr static const std::size_t block_words = 2;
47  constexpr static const std::size_t block_bits = block_words * word_bits;
48  typedef std::array<word_type, block_words> block_type;
49 
50  constexpr static const std::size_t key_words = 32;
51  constexpr static const std::size_t key_bits = key_words * CHAR_BIT;
52  typedef std::array<byte_type, key_words> key_type;
53 
54  constexpr static const std::size_t key_schedule_words = 8;
55  constexpr static const std::size_t key_schedule_bits = key_schedule_words * word_bits;
56  typedef std::array<word_type, key_schedule_words> key_schedule_type;
57 
58  constexpr static const std::size_t state_size = 16;
59  typedef std::array<byte_type, state_size> state_type;
60  };
61  } // namespace detail
62  } // namespace mac
63  } // namespace crypto3
64 } // namespace nil
65 
66 #endif // CRYPTO3_POLY1305_POLICY_HPP
boost::mpl::apply< AccumulatorSet, tag::mac< ProcessingPolicy > >::type::result_type mac(const AccumulatorSet &acc)
Definition: accumulators/mac.hpp:99
Definition: pair.hpp:31
Definition: mac/include/nil/crypto3/mac/detail/basic_functions.hpp:36
boost::uint_t< CHAR_BIT >::exact byte_type
Definition: mac/include/nil/crypto3/mac/detail/basic_functions.hpp:37
constexpr static const std::size_t word_bits
Definition: mac/include/nil/crypto3/mac/detail/basic_functions.hpp:39
boost::uint_t< word_bits >::exact word_type
Definition: mac/include/nil/crypto3/mac/detail/basic_functions.hpp:40
Definition: poly1305_policy.hpp:38
constexpr static const std::size_t key_schedule_bits
Definition: poly1305_policy.hpp:55
std::array< byte_type, key_words > key_type
Definition: poly1305_policy.hpp:52
constexpr static const std::size_t key_bits
Definition: poly1305_policy.hpp:51
policy_type::word_type word_type
Definition: poly1305_policy.hpp:44
policy_type::byte_type byte_type
Definition: poly1305_policy.hpp:41
constexpr static const std::size_t block_words
Definition: poly1305_policy.hpp:46
constexpr static const std::size_t word_bits
Definition: poly1305_policy.hpp:43
constexpr static const std::size_t key_words
Definition: poly1305_policy.hpp:50
basic_functions< 64 > policy_type
Definition: poly1305_policy.hpp:39
constexpr static const std::size_t block_bits
Definition: poly1305_policy.hpp:47
constexpr static const std::size_t key_schedule_words
Definition: poly1305_policy.hpp:54
std::array< word_type, key_schedule_words > key_schedule_type
Definition: poly1305_policy.hpp:56
constexpr static const std::size_t state_size
Definition: poly1305_policy.hpp:58
std::array< word_type, block_words > block_type
Definition: poly1305_policy.hpp:48
std::array< byte_type, state_size > state_type
Definition: poly1305_policy.hpp:59