Skip to content

Commit

Permalink
Add sha1 testing
Browse files Browse the repository at this point in the history
  • Loading branch information
mborland committed Nov 5, 2024
1 parent 8b24ac7 commit 227a02d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
1 change: 1 addition & 0 deletions test/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ run test_hmac.cpp ;
# NIST standard testing
run test_nist_cavs_sha1_monte.cpp ;
run test_nist_cavs_sha1_short_long.cpp ;
run test_nist_cavs_sha1_hmac.cpp ;

run test_nist_cavs_sha224_monte.cpp ;
run test_nist_cavs_sha224_short_long.cpp ;
Expand Down
3 changes: 1 addition & 2 deletions test/test_nist_cavs_detail.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#define BOOST_CRYPT_TEST_NIST_CAVS_DETAIL_HPP

#include <boost/core/lightweight_test.hpp>

#include <boost/crypt/hash/hmac.hpp>
#include <cstddef>
#include <cstdint>
#include <deque>
Expand Down Expand Up @@ -337,7 +337,6 @@ auto parse_file_vectors_hmac(const std::string& test_vectors_filename, test_vect
result_parse_is_ok = true;

std::string line { };
std::size_t length { };
std::string message { };
std::string result { };
std::string key { };
Expand Down
35 changes: 35 additions & 0 deletions test/test_nist_cavs_sha1_hmac.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// 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/sha1.hpp>

#include "test_nist_cavs_detail.hpp"

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

{
nist::cavs::test_vector_container_type test_vectors {};

static_cast<void>(nist::cavs::detail::parse_file_vectors_hmac("sha1.fax", test_vectors));

result_is_ok = (nist::cavs::test_vectors_hmac<boost::crypt::sha1_hasher>(test_vectors) && result_is_ok);

BOOST_TEST(result_is_ok);
}

{
nist::cavs::test_vector_container_type test_vectors {};

static_cast<void>(nist::cavs::detail::parse_file_vectors_hmac("sha1cavs11.fax", test_vectors));

result_is_ok = (nist::cavs::test_vectors_hmac<boost::crypt::sha1_hasher>(test_vectors) && result_is_ok);

BOOST_TEST(result_is_ok);
}

return boost::report_errors();
}

0 comments on commit 227a02d

Please sign in to comment.