MCPcopy Create free account
hub / github.com/ElementsProject/elements / TestHKDF_SHA256_32

Function TestHKDF_SHA256_32

src/test/crypto_tests.cpp:176–190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

174}
175
176static void TestHKDF_SHA256_32(const std::string &ikm_hex, const std::string &salt_hex, const std::string &info_hex, const std::string &okm_check_hex) {
177 std::vector<unsigned char> initial_key_material = ParseHex(ikm_hex);
178 std::vector<unsigned char> salt = ParseHex(salt_hex);
179 std::vector<unsigned char> info = ParseHex(info_hex);
180
181
182 // our implementation only supports strings for the "info" and "salt", stringify them
183 std::string salt_stringified(reinterpret_cast<char*>(salt.data()), salt.size());
184 std::string info_stringified(reinterpret_cast<char*>(info.data()), info.size());
185
186 CHKDF_HMAC_SHA256_L32 hkdf32(initial_key_material.data(), initial_key_material.size(), salt_stringified);
187 unsigned char out[32];
188 hkdf32.Expand32(info_stringified, out);
189 BOOST_CHECK(HexStr(out) == okm_check_hex);
190}
191
192static std::string LongTestString()
193{

Callers 1

BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 5

ParseHexFunction · 0.85
Expand32Method · 0.80
HexStrFunction · 0.50
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected