The unified diff between revisions [695f5995..] and [13704fef..] is displayed below. It can also be downloaded as a raw diff.
This diff has been restricted to the following files: 'checks/validate.cpp'
#
#
# patch "checks/validate.cpp"
# from [34e3699ec7308c0ddea294ca8005f0bf869ef781]
# to [0be5b3c114c588d0b1c20fe2766bf0fae03b26a8]
#
============================================================
--- checks/validate.cpp 34e3699ec7308c0ddea294ca8005f0bf869ef781
+++ checks/validate.cpp 0be5b3c114c588d0b1c20fe2766bf0fae03b26a8
@@ -1,6 +1,5 @@
/*
Validation routines
- This file is in the public domain
*/
#include <iostream>
@@ -10,7 +9,8 @@
#include <cstdlib>
#include <botan/filters.h>
-#include <botan/rng.h>
+#include <botan/exceptn.h>
+#include <botan/libstate.h>
using namespace Botan_types;
#define EXTRA_TESTS 0
@@ -31,7 +31,7 @@ u32bit random_word(u32bit max)
/* normal version */
u32bit r = 0;
for(u32bit j = 0; j != 4; j++)
- r = (r << 8) | Botan::Global_RNG::random();
+ r = (r << 8) | Botan::global_state().random();
return ((r % max) + 1); // return between 1 and max inclusive
#endif
}
@@ -52,10 +52,7 @@ u32bit do_validation_tests(const std::st
bool first_mark = true;
if(!test_data)
- {
- std::cout << "Couldn't open test file " << filename << std::endl;
- std::exit(1);
- }
+ throw Botan::Stream_IO_Error("Couldn't open test file " + filename);
u32bit errors = 0, alg_count = 0;
std::string algorithm;
@@ -67,10 +64,8 @@ u32bit do_validation_tests(const std::st
while(!test_data.eof())
{
if(test_data.bad() || test_data.fail())
- {
- std::cout << "File I/O error." << std::endl;
- std::exit(1);
- }
+ throw Botan::Stream_IO_Error("File I/O error reading from " +
+ filename);
std::string line;
std::getline(test_data, line);
@@ -268,14 +263,11 @@ bool failed_test(const std::string& algo
bool OK = true;
for(u32bit j = offset; j != offset+length; j++)
- if((byte)output[j] != peekbuf[j-offset])
+ if(static_cast<byte>(output[j]) != peekbuf[j-offset])
OK = false;
if(!OK)
- {
- std::cout << "Peek testing failed!" << std::endl;
- std::exit(1);
- }
+ throw Botan::Self_Test_Failure("Peek testing failed in validate.cpp");
}
if(output == expected && !exp_pass)