File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed
Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -50,11 +50,7 @@ namespace ccf::crypto
5050
5151 std::ostream& operator <<(std::ostream& os, const ccf::crypto::Sha256Hash& h)
5252 {
53- for (unsigned i = 0 ; i < ccf::crypto::Sha256Hash::SIZE; i++)
54- {
55- os << std::hex << static_cast <int >(h.h [i]);
56- }
57-
53+ os << h.hex_str ();
5854 return os;
5955 }
6056
Original file line number Diff line number Diff line change @@ -1466,4 +1466,20 @@ TEST_CASE("Do not trust non-ca certs")
14661466 // CA:FALSE).
14671467 REQUIRE_FALSE (
14681468 non_ca_cert_verifier->verify_certificate ({&non_ca_cert}, {}, true ));
1469+ }
1470+
1471+ TEST_CASE (" Sha256 hex conversions" )
1472+ {
1473+ {
1474+ INFO (" Sha256 via operator<<" );
1475+
1476+ const std::string hex{
1477+ " f3d25d4670b742f035c1f1d9fffa2eba676ddc491c5288403fa1091e62f26dd6" };
1478+ auto hash = ccf::crypto::Sha256Hash::from_hex_string (hex);
1479+
1480+ std::stringstream ss;
1481+ ss << hash;
1482+
1483+ REQUIRE (ss.str () == hex);
1484+ }
14691485}
You can’t perform that action at this time.
0 commit comments