x919_mac_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_X919_MAC_POLICY_HPP
26 #define CRYPTO3_MAC_X919_MAC_POLICY_HPP
27 
28 #include <boost/container/static_vector.hpp>
29 #include <boost/integer.hpp>
30 
31 namespace nil {
32  namespace crypto3 {
33  namespace mac {
34  namespace detail {
35  template<typename BlockCipher>
36  struct x919_mac_policy {
38 
39  typedef typename boost::uint_t<CHAR_BIT>::exact byte_type;
40 
41  constexpr static const std::size_t word_bits = cipher_type::word_bits;
42  typedef typename cipher_type::word_type word_type;
43 
44  constexpr static const std::size_t key_bits = cipher_type::key_bits;
45  constexpr static const std::size_t key_words = cipher_type::key_words;
46  typedef boost::container::static_vector<word_type, 2 * key_words> key_type;
47 
48  constexpr static const std::size_t key_schedule_bits = cipher_type::key_schedule_bits;
49  constexpr static const std::size_t key_schedule_words = cipher_type::key_schedule_words;
50  typedef typename cipher_type::key_schedule_type key_schedule_type;
51 
52  constexpr static const std::size_t digest_size = 8;
53  constexpr static const std::size_t digest_bits = 8 * CHAR_BIT;
54  typedef std::array<byte_type, digest_size> digest_type;
55  };
56  } // namespace detail
57  } // namespace mac
58  } // namespace crypto3
59 } // namespace nil
60 
61 #endif // CRYPTO3_X919_MAC_POLICY_HPP
boost::mpl::apply< AccumulatorSet, tag::mac< ProcessingPolicy > >::type::result_type mac(const AccumulatorSet &acc)
Definition: accumulators/mac.hpp:99
boost::accumulators::accumulator_set< mac::digest< MessageAuthenticationCode::input_block_bits >, boost::accumulators::features< accumulators::tag::mac< MessageAuthenticationCode > >> BlockCipher
Definition: cbc_mac_state.hpp:40
Definition: pair.hpp:31
Definition: x919_mac_policy.hpp:36
BlockCipher cipher_type
Definition: x919_mac_policy.hpp:37
constexpr static const std::size_t key_words
Definition: x919_mac_policy.hpp:45
constexpr static const std::size_t key_schedule_bits
Definition: x919_mac_policy.hpp:48
boost::uint_t< CHAR_BIT >::exact byte_type
Definition: x919_mac_policy.hpp:39
constexpr static const std::size_t key_schedule_words
Definition: x919_mac_policy.hpp:49
constexpr static const std::size_t digest_size
Definition: x919_mac_policy.hpp:52
cipher_type::key_schedule_type key_schedule_type
Definition: x919_mac_policy.hpp:50
constexpr static const std::size_t word_bits
Definition: x919_mac_policy.hpp:41
std::array< byte_type, digest_size > digest_type
Definition: x919_mac_policy.hpp:54
cipher_type::word_type word_type
Definition: x919_mac_policy.hpp:42
constexpr static const std::size_t digest_bits
Definition: x919_mac_policy.hpp:53
constexpr static const std::size_t key_bits
Definition: x919_mac_policy.hpp:44
boost::container::static_vector< word_type, 2 *key_words > key_type
Definition: x919_mac_policy.hpp:46