Changeset View
Changeset View
Standalone View
Standalone View
src/test/crypto_tests.cpp
Show First 20 Lines • Show All 621 Lines • ▼ Show 20 Lines | for (int i = 0; i <= 64; ++i) { | ||||
// Randomly test 1000 samples of each length above 10 bits. | // Randomly test 1000 samples of each length above 10 bits. | ||||
uint64_t j = uint64_t(1) << (i - 1) | ctx.randbits(i - 1); | uint64_t j = uint64_t(1) << (i - 1) | ctx.randbits(i - 1); | ||||
BOOST_CHECK_EQUAL(CountBits(j), i); | BOOST_CHECK_EQUAL(CountBits(j), i); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(sha256d64) { | |||||
for (int i = 0; i <= 32; ++i) { | |||||
uint8_t in[64 * 32]; | |||||
uint8_t out1[32 * 32], out2[32 * 32]; | |||||
for (int j = 0; j < 64 * i; ++j) { | |||||
in[j] = InsecureRandBits(8); | |||||
} | |||||
for (int j = 0; j < i; ++j) { | |||||
CHash256().Write(in + 64 * j, 64).Finalize(out1 + 32 * j); | |||||
} | |||||
SHA256D64(out2, in, i); | |||||
BOOST_CHECK(memcmp(out1, out2, 32 * i) == 0); | |||||
} | |||||
} | |||||
BOOST_AUTO_TEST_SUITE_END() | BOOST_AUTO_TEST_SUITE_END() |