summaryrefslogtreecommitdiff
path: root/validat3.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'validat3.cpp')
-rw-r--r--validat3.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/validat3.cpp b/validat3.cpp
index 44b0dbef..dfd72c9e 100644
--- a/validat3.cpp
+++ b/validat3.cpp
@@ -662,15 +662,18 @@ bool TestHKDF(KeyDerivationFunction &kdf, const HKDF_TestTuple *testSet, unsigne
StringSource(tuple.hexSalt ? tuple.hexSalt : "", true, new HexDecoder(new StringSink(salt)));
StringSource(tuple.hexInfo ? tuple.hexInfo : "", true, new HexDecoder(new StringSink(info)));
StringSource(tuple.hexExpected, true, new HexDecoder(new StringSink(expected)));
-
SecByteBlock derived(expected.size());
- unsigned int ret = kdf.DeriveKey(derived, derived.size(),
- reinterpret_cast<const unsigned char*>(secret.data()), secret.size(),
- (tuple.hexSalt ? reinterpret_cast<const unsigned char*>(salt.data()) : NULLPTR), salt.size(),
- (tuple.hexInfo ? reinterpret_cast<const unsigned char*>(info.data()) : NULLPTR), info.size());
- bool fail = !VerifyBufsEqual(derived, reinterpret_cast<const unsigned char*>(expected.data()), derived.size());
- pass = pass && (ret == tuple.len) && !fail;
+ AlgorithmParameters params;
+ if (tuple.hexSalt)
+ params.operator()(Name::Salt(), ConstByteArrayParameter((const byte*)&salt[0], salt.size()));
+ if (tuple.hexSalt)
+ params.operator()("Info", ConstByteArrayParameter((const byte*)&info[0], info.size()));
+
+ kdf.DeriveKey((byte*)&derived[0], derived.size(), (const byte*)&secret[0], secret.size(), params);
+
+ bool fail = !VerifyBufsEqual(derived, (const byte*)&expected[0], derived.size());
+ pass = pass && !fail;
HexEncoder enc(new FileSink(std::cout));
std::cout << (fail ? "FAILED " : "passed ");
@@ -748,8 +751,6 @@ bool ValidateHKDF()
pass = TestHKDF(hkdf, testSet, COUNTOF(testSet)) && pass;
}
-
-
{
// Whirlpool, Crypto++ generated, based on RFC 5869, https://tools.ietf.org/html/rfc5869
static const HKDF_TestTuple testSet[] =