Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
43 changes: 43 additions & 0 deletions include/nil/crypto3/hash/detail/gost_3411/gost_3411_policy.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//---------------------------------------------------------------------------//
// Copyright (c) 2018-2020 Mikhail Komarov <nemo@nil.foundation>
//
// 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 <nil/crypto3/detail/static_digest.hpp>
#include <nil/crypto3/detail/basic_functions.hpp>

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_bits> 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<word_type, block_words> 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<word_type, state_words> state_type;
};
} // namespace detail
} // namespace hash
} // namespace crypto3
} // namespace nil

#endif // CRYPTO3_GOST_3411_POLICY_HPP
55 changes: 55 additions & 0 deletions include/nil/crypto3/hash/gost_3411.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//---------------------------------------------------------------------------//
// Copyright (c) 2018-2020 Mikhail Komarov <nemo@nil.foundation>
// Copyright (c) 2020 Nikita Kaskov <nbering@nil.foundation>
//
// 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 <nil/crypto3/hash/detail/gost_3411_policy.hpp>

#include <nil/crypto3/block/gost28147.hpp>

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<typename ParamsType = block::cbr_params>
class gost_3411 {
typedef detail::gost_3411_policy policy_type;
typedef block::gost_28147_89<ParamsType> block_cipher_type;

public:
};
} // namespace hash
} // namespace crypto3
} // namespace nil

#endif
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ endmacro()

set(TESTS_NAMES
"blake2b"
"gost_3411"
"keccak"
"md4"
"md5"
Expand Down
48 changes: 48 additions & 0 deletions test/gost_3411.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//---------------------------------------------------------------------------//
// Copyright (c) 2018-2020 Mikhail Komarov <nemo@nil.foundation>
//
// 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 <nil/crypto3/hash/algorithm/hash.hpp>

#include <nil/crypto3/hash/gost_3411.hpp>
#include <nil/crypto3/hash/hash_state.hpp>

#include <boost/test/unit_test.hpp>
#include <boost/test/data/test_case.hpp>
#include <boost/test/data/monomorphic.hpp>

#include <boost/static_assert.hpp>

#include <iostream>
#include <string>
#include <unordered_map>

#include <cstdio>

using namespace nil::crypto3::hash;

namespace boost {
namespace test_tools {
namespace tt_detail {
template<template<typename, typename> class P, typename K, typename V>
struct print_log_value<P<K, V>> {
void operator()(std::ostream&, P<K, V> 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()