hash/include/nil/crypto3/hash/detail/md5/md5_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_HASH_DETAIL_MD5_POLICY_HPP
27 #define CRYPTO3_HASH_DETAIL_MD5_POLICY_HPP
28 
30 
31 #include <nil/crypto3/detail/static_digest.hpp>
32 
33 namespace nil {
34  namespace crypto3 {
35  namespace hashes {
36  namespace detail {
37 
38  struct md5_policy {
40 
41  constexpr static const std::size_t word_bits = block_cipher_type::word_bits;
43 
44  constexpr static const std::size_t state_bits = block_cipher_type::block_bits;
45  constexpr static const std::size_t state_words = block_cipher_type::block_words;
47 
48  constexpr static const std::size_t block_bits = block_cipher_type::key_bits;
49  constexpr static const std::size_t block_words = block_cipher_type::key_words;
51 
52  constexpr static const std::size_t length_bits = word_bits * 2;
53 
55 
56  constexpr static const std::size_t digest_bits = state_bits;
58 
59  constexpr static const std::size_t pkcs_id_size = 18;
60  constexpr static const std::size_t pkcs_id_bits = pkcs_id_size * CHAR_BIT;
61  typedef std::array<std::uint8_t, pkcs_id_size> pkcs_id_type;
62 
63  constexpr static const pkcs_id_type pkcs_id = {0x30, 0x20, 0x30, 0x0C, 0x06, 0x08,
64  0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D,
65  0x02, 0x05, 0x05, 0x00, 0x04, 0x10};
66 
67  struct iv_generator {
68  state_type const &operator()() const {
69  // Same as MD4
70  static state_type const H0 = {{0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476}};
71  return H0;
72  }
73  };
74  };
75 
76  } // namespace detail
77  } // namespace hashes
78  } // namespace crypto3
79 } // namespace nil
80 
81 #endif // CRYPTO3_HASH_DETAIL_MD5_POLICY_HPP
MD5 block cipher. Stands as a foundation for MD5 hashes.
Definition: block/include/nil/crypto3/block/md5.hpp:57
constexpr static const std::size_t block_bits
Definition: block/include/nil/crypto3/block/md5.hpp:70
policy_type::word_type word_type
Definition: block/include/nil/crypto3/block/md5.hpp:64
constexpr static const std::size_t block_words
Definition: block/include/nil/crypto3/block/md5.hpp:71
constexpr static const std::size_t key_bits
Definition: block/include/nil/crypto3/block/md5.hpp:66
constexpr static const std::size_t word_bits
Definition: block/include/nil/crypto3/block/md5.hpp:63
policy_type::key_type key_type
Definition: block/include/nil/crypto3/block/md5.hpp:68
constexpr static const std::size_t key_words
Definition: block/include/nil/crypto3/block/md5.hpp:67
policy_type::block_type block_type
Definition: block/include/nil/crypto3/block/md5.hpp:72
Definition: block/include/nil/crypto3/detail/static_digest.hpp:72
Definition: pair.hpp:31
Definition: hash/include/nil/crypto3/hash/detail/md5/md5_policy.hpp:67
state_type const & operator()() const
Definition: hash/include/nil/crypto3/hash/detail/md5/md5_policy.hpp:68
Definition: hash/include/nil/crypto3/hash/detail/md5/md5_policy.hpp:38
constexpr static const pkcs_id_type pkcs_id
Definition: hash/include/nil/crypto3/hash/detail/md5/md5_policy.hpp:63
constexpr static const std::size_t block_words
Definition: hash/include/nil/crypto3/hash/detail/md5/md5_policy.hpp:49
constexpr static const std::size_t state_bits
Definition: hash/include/nil/crypto3/hash/detail/md5/md5_policy.hpp:44
constexpr static const std::size_t pkcs_id_size
Definition: hash/include/nil/crypto3/hash/detail/md5/md5_policy.hpp:59
constexpr static const std::size_t word_bits
Definition: hash/include/nil/crypto3/hash/detail/md5/md5_policy.hpp:41
block_cipher_type::key_type block_type
Definition: hash/include/nil/crypto3/hash/detail/md5/md5_policy.hpp:50
constexpr static const std::size_t block_bits
Definition: hash/include/nil/crypto3/hash/detail/md5/md5_policy.hpp:48
constexpr static const std::size_t pkcs_id_bits
Definition: hash/include/nil/crypto3/hash/detail/md5/md5_policy.hpp:60
stream_endian::little_octet_big_bit digest_endian
Definition: hash/include/nil/crypto3/hash/detail/md5/md5_policy.hpp:54
constexpr static const std::size_t length_bits
Definition: hash/include/nil/crypto3/hash/detail/md5/md5_policy.hpp:52
constexpr static const std::size_t digest_bits
Definition: hash/include/nil/crypto3/hash/detail/md5/md5_policy.hpp:56
block_cipher_type::word_type word_type
Definition: hash/include/nil/crypto3/hash/detail/md5/md5_policy.hpp:42
block::md5 block_cipher_type
Definition: hash/include/nil/crypto3/hash/detail/md5/md5_policy.hpp:39
std::array< std::uint8_t, pkcs_id_size > pkcs_id_type
Definition: hash/include/nil/crypto3/hash/detail/md5/md5_policy.hpp:61
constexpr static const std::size_t state_words
Definition: hash/include/nil/crypto3/hash/detail/md5/md5_policy.hpp:45
static_digest< digest_bits > digest_type
Definition: hash/include/nil/crypto3/hash/detail/md5/md5_policy.hpp:57
block_cipher_type::block_type state_type
Definition: hash/include/nil/crypto3/hash/detail/md5/md5_policy.hpp:46
Definition: algebra/include/nil/crypto3/detail/stream_endian.hpp:45