diff --git a/CMakeLists.txt b/CMakeLists.txt index 9be4cc2b..dc988509 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,6 +108,15 @@ if(CRYPTO3_HASH_BLAKE2B) ${${CURRENT_PROJECT_NAME}_BLAKE2B_HEADERS}) endif() +if(CRYPTO3_HASH_GOST_34_11) + list(APPEND ${CURRENT_PROJECT_NAME}_GOST_34_11_HEADERS + include/nil/crypto3/hash/gost_3411.hpp) + + add_definitions(-D${CMAKE_UPPER_WORKSPACE_NAME}_HAS_GOST_34_11) + list(APPEND ${CURRENT_PROJECT_NAME}_PUBLIC_HEADERS + ${${CURRENT_PROJECT_NAME}_GOST_34_11_HEADERS}) +endif() + if(CRYPTO3_HASH_KECCAK) list(APPEND ${CURRENT_PROJECT_NAME}_KECCAK_HEADERS include/nil/crypto3/hash/keccak.hpp) diff --git a/include/nil/crypto3/hash/detail/gost_3411/gost_3411_policy.hpp b/include/nil/crypto3/hash/detail/gost_3411/gost_3411_policy.hpp new file mode 100644 index 00000000..48ac171d --- /dev/null +++ b/include/nil/crypto3/hash/detail/gost_3411/gost_3411_policy.hpp @@ -0,0 +1,43 @@ +//---------------------------------------------------------------------------// +// Copyright (c) 2018-2020 Mikhail Komarov +// +// Distributed under the Boost Software License, Version 1.0 +// See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt +//---------------------------------------------------------------------------// + +#ifndef CRYPTO3_GOST_3411_POLICY_HPP +#define CRYPTO3_GOST_3411_POLICY_HPP + +#include +#include + +namespace nil { + namespace crypto3 { + namespace hash { + namespace detail { + struct gost_3411_policy : public ::nil::crypto3::detail::basic_functions<32> { + typedef ::nil::crypto3::detail::basic_functions<32> policy_type; + + constexpr static const std::size_t rounds = 32; + + constexpr static const std::size_t word_bits = policy_type::word_bits; + typedef typename policy_type::word_type word_type; + + constexpr static const std::size_t digest_bits = 256; + typedef static_digest digest_type; + + constexpr static const std::size_t block_bits = 64; + constexpr static const std::size_t block_words = block_bits / word_bits; + typedef std::array block_type; + + constexpr static const std::size_t state_bits = 256; + constexpr static const std::size_t state_words = state_bits / word_bits; + typedef std::array state_type; + }; + } // namespace detail + } // namespace hash + } // namespace crypto3 +} // namespace nil + +#endif // CRYPTO3_GOST_3411_POLICY_HPP diff --git a/include/nil/crypto3/hash/gost_3411.hpp b/include/nil/crypto3/hash/gost_3411.hpp new file mode 100644 index 00000000..b70dc2e0 --- /dev/null +++ b/include/nil/crypto3/hash/gost_3411.hpp @@ -0,0 +1,55 @@ +//---------------------------------------------------------------------------// +// Copyright (c) 2018-2020 Mikhail Komarov +// Copyright (c) 2020 Nikita Kaskov +// +// Distributed under the Boost Software License, Version 1.0 +// See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt +//---------------------------------------------------------------------------// + +#ifndef CRYPTO3_GOST_3411_HPP +#define CRYPTO3_GOST_3411_HPP + +#include + +#include + +namespace nil { + namespace crypto3 { + namespace hash { + class gost_3411_compressor { + typedef detail::gost_3411_policy policy_type; + + public: + constexpr static const std::size_t word_bits = policy_type::word_bits; + typedef typename policy_type::word_type word_type; + + constexpr static const std::size_t state_bits = policy_type::state_bits; + constexpr static const std::size_t state_words = policy_type::state_words; + typedef typename policy_type::state_type state_type; + + constexpr static const std::size_t block_bits = policy_type::block_bits; + constexpr static const std::size_t block_words = policy_type::block_words; + typedef typename policy_type::block_type block_type; + + void operator()(state_type &state, const block_type &block) { + } + }; + + /*! + * @brief + * @tparam ParamsType + * @ingroup hash + */ + template + class gost_3411 { + typedef detail::gost_3411_policy policy_type; + typedef block::gost_28147_89 block_cipher_type; + + public: + }; + } // namespace hash + } // namespace crypto3 +} // namespace nil + +#endif diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 83f1e305..cd6cad4f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -41,6 +41,7 @@ endmacro() set(TESTS_NAMES "blake2b" + "gost_3411" "keccak" "md4" "md5" diff --git a/test/gost_3411.cpp b/test/gost_3411.cpp new file mode 100644 index 00000000..a8566428 --- /dev/null +++ b/test/gost_3411.cpp @@ -0,0 +1,48 @@ +//---------------------------------------------------------------------------// +// Copyright (c) 2018-2020 Mikhail Komarov +// +// Distributed under the Boost Software License, Version 1.0 +// See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt +//---------------------------------------------------------------------------// + +#define BOOST_TEST_MODULE gost_3411_test + +#include + +#include +#include + +#include +#include +#include + +#include + +#include +#include +#include + +#include + +using namespace nil::crypto3::hash; + +namespace boost { + namespace test_tools { + namespace tt_detail { + template class P, typename K, typename V> + struct print_log_value> { + void operator()(std::ostream&, P const&) { + } + }; + } // namespace tt_detail + } // namespace test_tools +} // namespace boost + +BOOST_AUTO_TEST_SUITE(gost_3411_test_suite) + +BOOST_AUTO_TEST_CASE(gost_3411_iterator_hash) { + +} + +BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file