@@ -379,35 +379,35 @@ auto test_vectors_oneshot(const test_vector_container_type& test_vectors) -> boo
379
379
}
380
380
381
381
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
383
383
{
384
384
using local_hasher_type = HasherType;
385
385
using local_result_type = typename local_hasher_type::return_type;
386
386
387
387
using local_array_type = local_result_type;
388
388
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 { };
399
391
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
+ };
403
397
404
- local_array_type MDi { };
405
- local_array_type MDj { };
398
+ std::copy (seed_init.cbegin (), seed_init.cend (), Seed.begin ());
406
399
407
400
bool result_is_ok { (!test_vectors_monte.empty ()) };
408
401
409
402
if (result_is_ok)
410
403
{
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
+
411
411
// See pseudocode on page 9 of "The Secure Hash Algorithm Validation System (SHAVS)".
412
412
413
413
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
419
419
using local_wide_array_type = boost::crypt::array<std::uint8_t , dummy_array.size () * 3U >;
420
420
421
421
const local_wide_array_type Mi =
422
- [&MD]()
422
+ [&MD, &dummy_array ]()
423
423
{
424
424
std::vector<std::uint8_t > result_vector { };
425
425
0 commit comments