| 615 | } |
| 616 | |
| 617 | void 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 | |
| 647 | bool GetField(std::istream &is, std::string &name, std::string &value) |
| 648 | { |
no test coverage detected