Cut-in determinsitic signature verification during signing

pull/157/head
Jeffrey Walton 2016-04-10 03:02:02 -04:00
parent 79c231edcb
commit 9cc0c47f7b
1 changed files with 29 additions and 11 deletions

View File

@ -290,9 +290,12 @@ void TestSignatureScheme(TestData &v)
// for DSA and ECDSA, and access to the seed or secret is not needed. If
// additional determinsitic signatures are added, then the test harness will
// likely need to be extended.
SignerFilter f(GlobalRNG(), *signer, new HexEncoder(new FileSink(cout)));
string signature;
SignerFilter f(GlobalRNG(), *signer, new HexEncoder(new StringSink(signature)));
StringSource ss(GetDecodedDatum(v, "Message"), true, new Redirector(f));
SignalTestFailure();
if (GetDecodedDatum(v, "Signature") != signature)
SignalTestFailure();
return;
}
else if (test == "RandomSign")
{
@ -644,11 +647,6 @@ bool GetField(std::istream &is, std::string &name, std::string &value)
name.resize(0); // GCC workaround: 2.95.3 doesn't have clear()
is >> name;
#if defined(__COVERITY__)
// The datafile being read is in /usr/share, and it protected by filesystem ACLs
// __coverity_tainted_data_sanitize__(reinterpret_cast<void*>(&name));
#endif
if (name.empty())
return false;
@ -668,7 +666,7 @@ bool GetField(std::istream &is, std::string &name, std::string &value)
// VC60 workaround: getline bug
char buffer[128];
value.resize(0); // GCC workaround: 2.95.3 doesn't have clear()
bool continueLine;
bool continueLine, space = false;
do
{
@ -676,6 +674,8 @@ bool GetField(std::istream &is, std::string &name, std::string &value)
{
is.get(buffer, sizeof(buffer));
value += buffer;
if (buffer[0] == ' ')
space = true;
}
while (buffer[0] != 0);
is.clear();
@ -698,6 +698,23 @@ bool GetField(std::istream &is, std::string &name, std::string &value)
}
while (continueLine);
// Strip intermediate spaces for some values.
if (space && (name == "Modulus" || name == "SubgroupOrder" || name == "SubgroupGenerator" ||
name == "PublicElement" || name == "PrivateExponent" || name == "Signature"))
{
string temp;
temp.reserve(value.size());
std::string::const_iterator it;
for(it = value.begin(); it != value.end(); it++)
{
if(*it != ' ')
temp.push_back(*it);
}
std::swap(temp, value);
}
return true;
}
@ -829,3 +846,4 @@ bool RunTestDataFile(const char *filename, const NameValuePairs &overrideParamet
cout << "SOME TESTS FAILED!\n";
return failedTests == 0;
}