MCPcopy Create free account
hub / github.com/LUX-Core/lux / TestKeyDerivationFunction

Function TestKeyDerivationFunction

src/cryptopp/datatest.cpp:617–645  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

615}
616
617void TestKeyDerivationFunction(TestData &v)
618{
619 std::string name = GetRequiredDatum(v, "Name");
620 std::string test = GetRequiredDatum(v, "Test");
621
622 if(test == "Skip") return;
623 CRYPTOPP_ASSERT(test == "Verify");
624
625 std::string key = GetDecodedDatum(v, "Key");
626 std::string salt = GetDecodedDatum(v, "Salt");
627 std::string info = GetDecodedDatum(v, "Info");
628 std::string derived = GetDecodedDatum(v, "DerivedKey");
629 std::string t = GetDecodedDatum(v, "DerivedKeyLength");
630
631 TestDataNameValuePairs pairs(v);
632 unsigned int length = pairs.GetIntValueWithDefault(Name::DerivedKeyLength(), (int)derived.size());
633
634 member_ptr<KeyDerivationFunction> kdf;
635 kdf.reset(ObjectFactoryRegistry<KeyDerivationFunction>::Registry().CreateObject(name.c_str()));
636
637 std::string calc; calc.resize(length);
638 unsigned int ret = kdf->DeriveKey(reinterpret_cast<byte*>(&calc[0]), calc.size(),
639 reinterpret_cast<const byte*>(key.data()), key.size(),
640 reinterpret_cast<const byte*>(salt.data()), salt.size(),
641 reinterpret_cast<const byte*>(info.data()), info.size());
642
643 if(calc != derived || ret != length)
644 SignalTestFailure();
645}
646
647bool GetField(std::istream &is, std::string &name, std::string &value)
648{

Callers 1

TestDataFileFunction · 0.85

Calls 8

GetDecodedDatumFunction · 0.85
SignalTestFailureFunction · 0.85
sizeMethod · 0.45
resetMethod · 0.45
CreateObjectMethod · 0.45
resizeMethod · 0.45
DeriveKeyMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected