aboutsummaryrefslogtreecommitdiffstats
path: root/checks/validate.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2009-10-07 18:09:33 +0000
committerlloyd <[email protected]>2009-10-07 18:09:33 +0000
commitc3ee539408849fc317b6ada78148cd5cb5ae6399 (patch)
treea9ff14b87ffaee7a0f90cdfe918fba87b2541924 /checks/validate.cpp
parent0d409578fecf39b6c2dc4926c4d95e353dcfcd78 (diff)
Use the new selftest framework for testing hashes, MACs, and ciphers.
Remove the Decrypt direction cipher mode tests - now both directions are always tested for all modes. Also add IVs for Salsa20 (were implicit all-zeros) since that does not fly anymore in validate.dat
Diffstat (limited to 'checks/validate.cpp')
-rw-r--r--checks/validate.cpp43
1 files changed, 33 insertions, 10 deletions
diff --git a/checks/validate.cpp b/checks/validate.cpp
index 8fb225137..6a8fed3d9 100644
--- a/checks/validate.cpp
+++ b/checks/validate.cpp
@@ -10,6 +10,8 @@
#include <botan/filters.h>
#include <botan/exceptn.h>
+#include <botan/selftest.h>
+#include <botan/libstate.h>
using namespace Botan;
#include "validate.h"
@@ -43,8 +45,7 @@ u32bit random_word(Botan::RandomNumberGenerator& rng,
}
-Botan::Filter* lookup(const std::string&, const std::vector<std::string>&,
- const std::string& = "All");
+Botan::Filter* lookup(const std::string&, const std::vector<std::string>&);
bool failed_test(const std::string&, std::vector<std::string>, bool, bool,
const std::string&, std::string&,
@@ -184,17 +185,39 @@ bool failed_test(const std::string& algo,
std::string& last_missing,
Botan::RandomNumberGenerator& rng)
{
-#if DEBUG
- std::cout << "Testing: " << algo;
- if(!exp_pass)
- std::cout << " (expecting failure)";
- std::cout << std::endl;
-#endif
-
#if !EXTRA_TESTS
if(!exp_pass) return true;
#endif
+ std::map<std::string, std::string> vars;
+ vars["input"] = params[0];
+ vars["output"] = params[1];
+
+ if(params.size() > 2)
+ vars["key"] = params[2];
+
+ if(params.size() > 3)
+ vars["iv"] = params[3];
+
+ std::map<std::string, bool> results =
+ algorithm_kat(algo, vars, global_state().algorithm_factory());
+
+ if(results.size())
+ {
+ for(std::map<std::string, bool>::const_iterator i = results.begin();
+ i != results.end(); ++i)
+ {
+ if(i->second == false)
+ {
+ std::cout << algo << " test with provider "
+ << i->first << " failed\n";
+ return true;
+ }
+ }
+
+ return false; // OK
+ }
+
const std::string in = params[0];
const std::string expected = params[1];
@@ -210,7 +233,7 @@ bool failed_test(const std::string& algo,
Botan::Pipe pipe;
try {
- Botan::Filter* test = lookup(algo, params, section);
+ Botan::Filter* test = lookup(algo, params);
if(test == 0 && is_extension) return !exp_pass;
if(test == 0)
{