Skip to content

Commit 88f44af

Browse files
committed
Try repairing syntax issue
1 parent 8deb6df commit 88f44af

File tree

2 files changed

+28
-18
lines changed

2 files changed

+28
-18
lines changed

test/test_nist_cavs_detail.hpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -379,35 +379,35 @@ auto test_vectors_oneshot(const test_vector_container_type& test_vectors) -> boo
379379
}
380380

381381
template<typename HasherType>
382-
auto test_vectors_monte(const nist::cavs::test_vector_container_type& test_vectors_monte) -> bool
382+
auto test_vectors_monte(const nist::cavs::test_vector_container_type& test_vectors_monte, const std::vector<std::uint8_t>& seed_init) -> bool
383383
{
384384
using local_hasher_type = HasherType;
385385
using local_result_type = typename local_hasher_type::return_type;
386386

387387
using local_array_type = local_result_type;
388388

389-
// TODO: ckormanyos this is for sha1 only. Use generic programming for the Seed.
390-
local_array_type
391-
Seed
392-
(
393-
{
394-
0xDDU, 0x4DU, 0xF6U, 0x44U, 0xEAU, 0xF3U, 0xD8U, 0x5BU,
395-
0xACU, 0xE2U, 0xB2U, 0x1AU, 0xCCU, 0xAAU, 0x22U, 0xB2U,
396-
0x88U, 0x21U, 0xF5U, 0xCDU
397-
}
398-
);
389+
// Obtain the test-specific initial seed.
390+
local_array_type Seed { };
399391

400-
constexpr local_array_type dummy_array { };
401-
402-
local_array_type MD[3U] { { }, { }, { } };
392+
const std::size_t
393+
max_copy
394+
{
395+
(std::min)(static_cast<std::size_t>(Seed.size()), static_cast<std::size_t>(seed_init.size()))
396+
};
403397

404-
local_array_type MDi { };
405-
local_array_type MDj { };
398+
std::copy(seed_init.cbegin(), seed_init.cend(), Seed.begin());
406399

407400
bool result_is_ok { (!test_vectors_monte.empty()) };
408401

409402
if(result_is_ok)
410403
{
404+
local_array_type MD[3U] { { }, { }, { } };
405+
406+
local_array_type MDi { };
407+
local_array_type MDj { };
408+
409+
constexpr local_array_type dummy_array { };
410+
411411
// See pseudocode on page 9 of "The Secure Hash Algorithm Validation System (SHAVS)".
412412

413413
for(std::size_t j { }; j < 100U; ++j)
@@ -419,7 +419,7 @@ auto test_vectors_monte(const nist::cavs::test_vector_container_type& test_vecto
419419
using local_wide_array_type = boost::crypt::array<std::uint8_t, dummy_array.size() * 3U>;
420420

421421
const local_wide_array_type Mi =
422-
[&MD]()
422+
[&MD, &dummy_array]()
423423
{
424424
std::vector<std::uint8_t> result_vector { };
425425

test/test_nist_cavs_sha1_monte.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,19 @@ auto main() -> int
1414
{
1515
nist::cavs::test_vector_container_type my_test_vectors_monte { };
1616

17+
std::vector<std::uint8_t>
18+
seed_init
19+
(
20+
{
21+
0xDDU, 0x4DU, 0xF6U, 0x44U, 0xEAU, 0xF3U, 0xD8U, 0x5BU,
22+
0xACU, 0xE2U, 0xB2U, 0x1AU, 0xCCU, 0xAAU, 0x22U, 0xB2U,
23+
0x88U, 0x21U, 0xF5U, 0xCDU
24+
}
25+
);
26+
1727
static_cast<void>(nist::cavs::detail::parse_file_monte("SHA1Monte.rsp", my_test_vectors_monte));
1828

19-
result_is_ok = (nist::cavs::test_vectors_monte<boost::crypt::sha1_hasher>(my_test_vectors_monte) && result_is_ok);
29+
result_is_ok = (nist::cavs::test_vectors_monte<boost::crypt::sha1_hasher>(my_test_vectors_monte, seed_init) && result_is_ok);
2030

2131
BOOST_TEST(result_is_ok);
2232
}

0 commit comments

Comments
 (0)