Add extraneous calls for code coverage
parent
3b8bc690bb
commit
f26a07ad98
46
datatest.cpp
46
datatest.cpp
|
|
@ -237,7 +237,6 @@ private:
|
||||||
|
|
||||||
void TestKeyPairValidAndConsistent(CryptoMaterial &pub, const CryptoMaterial &priv)
|
void TestKeyPairValidAndConsistent(CryptoMaterial &pub, const CryptoMaterial &priv)
|
||||||
{
|
{
|
||||||
// "!!" converts between bool <-> integral.
|
|
||||||
if (!pub.Validate(Test::GlobalRNG(), 2U+!!s_thorough))
|
if (!pub.Validate(Test::GlobalRNG(), 2U+!!s_thorough))
|
||||||
SignalTestFailure();
|
SignalTestFailure();
|
||||||
if (!priv.Validate(Test::GlobalRNG(), 2U+!!s_thorough))
|
if (!priv.Validate(Test::GlobalRNG(), 2U+!!s_thorough))
|
||||||
|
|
@ -261,6 +260,10 @@ void TestSignatureScheme(TestData &v)
|
||||||
|
|
||||||
TestDataNameValuePairs pairs(v);
|
TestDataNameValuePairs pairs(v);
|
||||||
|
|
||||||
|
// Code coverage
|
||||||
|
(void)signer->AlgorithmName();
|
||||||
|
(void)verifier->AlgorithmName();
|
||||||
|
|
||||||
if (test == "GenerateKey")
|
if (test == "GenerateKey")
|
||||||
{
|
{
|
||||||
signer->AccessPrivateKey().GenerateRandom(Test::GlobalRNG(), pairs);
|
signer->AccessPrivateKey().GenerateRandom(Test::GlobalRNG(), pairs);
|
||||||
|
|
@ -360,6 +363,10 @@ void TestAsymmetricCipher(TestData &v)
|
||||||
encryptor->AccessMaterial().AssignFrom(pairs);
|
encryptor->AccessMaterial().AssignFrom(pairs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Code coverage
|
||||||
|
(void)encryptor->AlgorithmName();
|
||||||
|
(void)decryptor->AlgorithmName();
|
||||||
|
|
||||||
if (test == "DecryptMatch")
|
if (test == "DecryptMatch")
|
||||||
{
|
{
|
||||||
std::string decrypted, expected = GetDecodedDatum(v, "Plaintext");
|
std::string decrypted, expected = GetDecodedDatum(v, "Plaintext");
|
||||||
|
|
@ -422,6 +429,16 @@ void TestSymmetricCipher(TestData &v, const NameValuePairs &overrideParameters)
|
||||||
decryptor->SetKey((const byte *)key.data(), key.size(), pairs);
|
decryptor->SetKey((const byte *)key.data(), key.size(), pairs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Code coverage
|
||||||
|
(void)encryptor->AlgorithmName();
|
||||||
|
(void)decryptor->AlgorithmName();
|
||||||
|
(void)encryptor->MinKeyLength();
|
||||||
|
(void)decryptor->MinKeyLength();
|
||||||
|
(void)encryptor->MaxKeyLength();
|
||||||
|
(void)decryptor->MaxKeyLength();
|
||||||
|
(void)encryptor->DefaultKeyLength();
|
||||||
|
(void)decryptor->DefaultKeyLength();
|
||||||
|
|
||||||
int seek = pairs.GetIntValueWithDefault("Seek", 0);
|
int seek = pairs.GetIntValueWithDefault("Seek", 0);
|
||||||
if (seek)
|
if (seek)
|
||||||
{
|
{
|
||||||
|
|
@ -539,21 +556,24 @@ void TestAuthenticatedSymmetricCipher(TestData &v, const NameValuePairs &overrid
|
||||||
|
|
||||||
if (test == "Encrypt" || test == "EncryptXorDigest" || test == "NotVerify")
|
if (test == "Encrypt" || test == "EncryptXorDigest" || test == "NotVerify")
|
||||||
{
|
{
|
||||||
member_ptr<AuthenticatedSymmetricCipher> asc1, asc2;
|
member_ptr<AuthenticatedSymmetricCipher> encryptor, decryptor;
|
||||||
asc1.reset(ObjectFactoryRegistry<AuthenticatedSymmetricCipher, ENCRYPTION>::Registry().CreateObject(name.c_str()));
|
encryptor.reset(ObjectFactoryRegistry<AuthenticatedSymmetricCipher, ENCRYPTION>::Registry().CreateObject(name.c_str()));
|
||||||
asc2.reset(ObjectFactoryRegistry<AuthenticatedSymmetricCipher, DECRYPTION>::Registry().CreateObject(name.c_str()));
|
decryptor.reset(ObjectFactoryRegistry<AuthenticatedSymmetricCipher, DECRYPTION>::Registry().CreateObject(name.c_str()));
|
||||||
asc1->SetKey((const byte *)key.data(), key.size(), pairs);
|
encryptor->SetKey((const byte *)key.data(), key.size(), pairs);
|
||||||
asc2->SetKey((const byte *)key.data(), key.size(), pairs);
|
decryptor->SetKey((const byte *)key.data(), key.size(), pairs);
|
||||||
|
|
||||||
|
(void)encryptor->AlgorithmName();
|
||||||
|
(void)decryptor->AlgorithmName();
|
||||||
|
|
||||||
std::string encrypted, decrypted;
|
std::string encrypted, decrypted;
|
||||||
AuthenticatedEncryptionFilter ef(*asc1, new StringSink(encrypted));
|
AuthenticatedEncryptionFilter ef(*encryptor, new StringSink(encrypted));
|
||||||
bool macAtBegin = !mac.empty() && !Test::GlobalRNG().GenerateBit(); // test both ways randomly
|
bool macAtBegin = !mac.empty() && !Test::GlobalRNG().GenerateBit(); // test both ways randomly
|
||||||
AuthenticatedDecryptionFilter df(*asc2, new StringSink(decrypted), macAtBegin ? AuthenticatedDecryptionFilter::MAC_AT_BEGIN : 0);
|
AuthenticatedDecryptionFilter df(*decryptor, new StringSink(decrypted), macAtBegin ? AuthenticatedDecryptionFilter::MAC_AT_BEGIN : 0);
|
||||||
|
|
||||||
if (asc1->NeedsPrespecifiedDataLengths())
|
if (encryptor->NeedsPrespecifiedDataLengths())
|
||||||
{
|
{
|
||||||
asc1->SpecifyDataLengths(header.size(), plaintext.size(), footer.size());
|
encryptor->SpecifyDataLengths(header.size(), plaintext.size(), footer.size());
|
||||||
asc2->SpecifyDataLengths(header.size(), plaintext.size(), footer.size());
|
decryptor->SpecifyDataLengths(header.size(), plaintext.size(), footer.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
StringStore sh(header), sp(plaintext), sc(ciphertext), sf(footer), sm(mac);
|
StringStore sh(header), sp(plaintext), sc(ciphertext), sf(footer), sm(mac);
|
||||||
|
|
@ -589,7 +609,7 @@ void TestAuthenticatedSymmetricCipher(TestData &v, const NameValuePairs &overrid
|
||||||
SignalTestFailure();
|
SignalTestFailure();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ciphertext.size()+mac.size()-plaintext.size() != asc1->DigestSize())
|
if (ciphertext.size()+mac.size()-plaintext.size() != encryptor->DigestSize())
|
||||||
{
|
{
|
||||||
std::cout << "\nbad MAC size\n";
|
std::cout << "\nbad MAC size\n";
|
||||||
SignalTestFailure();
|
SignalTestFailure();
|
||||||
|
|
@ -623,6 +643,7 @@ void TestDigestOrMAC(TestData &v, bool testDigest)
|
||||||
{
|
{
|
||||||
hash.reset(ObjectFactoryRegistry<HashTransformation>::Registry().CreateObject(name.c_str()));
|
hash.reset(ObjectFactoryRegistry<HashTransformation>::Registry().CreateObject(name.c_str()));
|
||||||
pHash = hash.get();
|
pHash = hash.get();
|
||||||
|
(void)hash->AlgorithmName();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -630,6 +651,7 @@ void TestDigestOrMAC(TestData &v, bool testDigest)
|
||||||
pHash = mac.get();
|
pHash = mac.get();
|
||||||
std::string key = GetDecodedDatum(v, "Key");
|
std::string key = GetDecodedDatum(v, "Key");
|
||||||
mac->SetKey((const byte *)key.c_str(), key.size(), pairs);
|
mac->SetKey((const byte *)key.c_str(), key.size(), pairs);
|
||||||
|
(void)mac->AlgorithmName();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test == "Verify" || test == "VerifyTruncated" || test == "NotVerify")
|
if (test == "Verify" || test == "VerifyTruncated" || test == "NotVerify")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue