Skip to content

Commit

Permalink
Add NIST CAVS testing of SHA224
Browse files Browse the repository at this point in the history
  • Loading branch information
mborland committed Oct 24, 2024
1 parent 23b3999 commit b9a0d1c
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
3 changes: 3 additions & 0 deletions test/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,8 @@ run test_sha256.cpp ;
run test_nist_cavs_sha1_monte.cpp ;
run test_nist_cavs_sha1_short_long.cpp ;

run test_nist_cavs_sha224_monte.cpp ;
run test_nist_cavs_sha224_short_long.cpp ;

run test_nist_cavs_sha256_monte.cpp ;
run test_nist_cavs_sha256_short_long.cpp ;
33 changes: 33 additions & 0 deletions test/test_nist_cavs_sha224_monte.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright 2024 Matt Borland
// Copyright 2024 Christopher Kormanyos
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt

#include <boost/crypt/hash/sha224.hpp>

#include "test_nist_cavs_detail.hpp"

auto main() -> int
{
bool result_is_ok { true };

{
nist::cavs::test_vector_container_type my_test_vectors_monte { };

std::vector<std::uint8_t>
seed_init
(
{
0x99, 0xf9, 0x57, 0xf2, 0x72, 0xb0, 0xac, 0xc5, 0xbf, 0xaf, 0x38, 0xc0, 0x30, 0x78, 0xc8, 0x8c, 0x97, 0x22, 0x67, 0x1a, 0xf0, 0x4f, 0x7e, 0x39, 0x9f, 0x5e, 0x40, 0x68
}
);

static_cast<void>(nist::cavs::parse_file_monte("SHA224Monte.rsp", my_test_vectors_monte));

result_is_ok = (nist::cavs::test_vectors_monte<boost::crypt::sha224_hasher>(my_test_vectors_monte, seed_init) && result_is_ok);

BOOST_TEST(result_is_ok);
}

return boost::report_errors();
}
36 changes: 36 additions & 0 deletions test/test_nist_cavs_sha224_short_long.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright 2024 Matt Borland
// Copyright 2024 Christopher Kormanyos
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt

#include <boost/crypt/hash/sha224.hpp>

#include "test_nist_cavs_detail.hpp"

auto main() -> int
{
bool result_is_ok { true };

{
nist::cavs::test_vector_container_type test_vectors_short { };

static_cast<void>(nist::cavs::detail::parse_file_vectors("SHA224ShortMsg.rsp", test_vectors_short));

result_is_ok = (nist::cavs::test_vectors_oneshot<boost::crypt::sha224_hasher>(test_vectors_short) && result_is_ok);

BOOST_TEST(result_is_ok);
}


{
nist::cavs::test_vector_container_type test_vectors_long { };

static_cast<void>(nist::cavs::detail::parse_file_vectors("SHA224LongMsg.rsp", test_vectors_long));

result_is_ok = (nist::cavs::test_vectors_oneshot<boost::crypt::sha224_hasher>(test_vectors_long) && result_is_ok);

BOOST_TEST(result_is_ok);
}

return boost::report_errors();
}

0 comments on commit b9a0d1c

Please sign in to comment.