blake2b_policy.hpp
Go to the documentation of this file.
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2018-2020 Mikhail Komarov <nemo@nil.foundation>
3 // Copyright (c) 2020 Nikita Kaskov <nbering@nil.foundation>
4 //
5 // MIT License
6 //
7 // Permission is hereby granted, free of charge, to any person obtaining a copy
8 // of this software and associated documentation files (the "Software"), to deal
9 // in the Software without restriction, including without limitation the rights
10 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 // copies of the Software, and to permit persons to whom the Software is
12 // furnished to do so, subject to the following conditions:
13 //
14 // The above copyright notice and this permission notice shall be included in all
15 // copies or substantial portions of the Software.
16 //
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 // SOFTWARE.
24 //---------------------------------------------------------------------------//
25 
26 #ifndef CRYPTO3_BLAKE2B_POLICY_HPP
27 #define CRYPTO3_BLAKE2B_POLICY_HPP
28 
29 #include <nil/crypto3/detail/static_digest.hpp>
30 #include <nil/crypto3/detail/basic_functions.hpp>
31 #include <nil/crypto3/detail/inject.hpp>
32 
33 namespace nil {
34  namespace crypto3 {
35  namespace hashes {
36  namespace detail {
37  template<std::size_t DigestBits>
39 
40  constexpr static const std::size_t state_bits = 512;
41  constexpr static const std::size_t state_words = state_bits / word_bits;
42  typedef std::array<word_type, state_words> state_type;
43 
44  constexpr static const std::size_t block_bits = 1024;
45  constexpr static const std::size_t block_words = block_bits / word_bits;
46  typedef std::array<word_type, block_words> block_type;
47 
48  constexpr static const std::size_t length_bits = word_bits;
49 
51 
52  constexpr static const std::size_t digest_bits = DigestBits;
54 
55  constexpr static const std::size_t rounds = 12;
56 
57  struct iv_generator {
58  state_type const &operator()() const {
59  constexpr static const state_type H0 = {
60  {0x6a09e667f3bcc908, 0xbb67ae8584caa73b, 0x3c6ef372fe94f82b, 0xa54ff53a5f1d36f1,
61  0x510e527fade682d1, 0x9b05688c2b3e6c1f, 0x1f83d9abfb41bd6b, 0x5be0cd19137e2179}};
62  return H0;
63  }
64  };
65 
66  constexpr static const std::size_t salt_bits = 64;
67  typedef typename boost::uint_t<salt_bits>::exact salt_type;
68  constexpr static const salt_type salt_value = 0xFFFFFFFFFFFFFFFF;
69  };
70  } // namespace detail
71  } // namespace hashes
72  } // namespace crypto3
73 } // namespace nil
74 
75 #endif // CRYPTO3_BLAKE2B_POLICY_HPP
Definition: block/include/nil/crypto3/detail/static_digest.hpp:72
Definition: pair.hpp:31
Definition: block/include/nil/crypto3/detail/basic_functions.hpp:37
constexpr static const std::size_t word_bits
Definition: block/include/nil/crypto3/detail/basic_functions.hpp:41
state_type const & operator()() const
Definition: blake2b_policy.hpp:58
Definition: blake2b_policy.hpp:38
constexpr static const std::size_t state_words
Definition: blake2b_policy.hpp:41
std::array< word_type, state_words > state_type
Definition: blake2b_policy.hpp:42
constexpr static const std::size_t block_bits
Definition: blake2b_policy.hpp:44
static_digest< digest_bits > digest_type
Definition: blake2b_policy.hpp:53
constexpr static const std::size_t state_bits
Definition: blake2b_policy.hpp:40
constexpr static const std::size_t length_bits
Definition: blake2b_policy.hpp:48
constexpr static const std::size_t block_words
Definition: blake2b_policy.hpp:45
boost::uint_t< salt_bits >::exact salt_type
Definition: blake2b_policy.hpp:67
std::array< word_type, block_words > block_type
Definition: blake2b_policy.hpp:46
constexpr static const std::size_t salt_bits
Definition: blake2b_policy.hpp:66
constexpr static const salt_type salt_value
Definition: blake2b_policy.hpp:68
stream_endian::little_octet_big_bit digest_endian
Definition: blake2b_policy.hpp:50
constexpr static const std::size_t rounds
Definition: blake2b_policy.hpp:55
constexpr static const std::size_t digest_bits
Definition: blake2b_policy.hpp:52
Definition: algebra/include/nil/crypto3/detail/stream_endian.hpp:45