aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/test_rng.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2014-02-09 16:52:51 +0000
committerlloyd <[email protected]>2014-02-09 16:52:51 +0000
commit4f3b0ce8fccd879791d5a701102ee0737f3509b1 (patch)
tree37ab6f550154de465d2677fdab1cc1d96904fa5c /src/tests/test_rng.cpp
parent253aa701ffa654af3c880e1e1b4965fabf86be3b (diff)
More fixes for minified builds
Diffstat (limited to 'src/tests/test_rng.cpp')
-rw-r--r--src/tests/test_rng.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/tests/test_rng.cpp b/src/tests/test_rng.cpp
index 88e21f62c..84e291c6a 100644
--- a/src/tests/test_rng.cpp
+++ b/src/tests/test_rng.cpp
@@ -2,22 +2,25 @@
#include "test_rng.h"
#include <botan/libstate.h>
-#include <botan/x931_rng.h>
-#include <botan/aes.h>
-#include <botan/des.h>
#include <botan/hex.h>
#include <iostream>
#include <fstream>
-#include <deque>
+
+#if defined(BOTAN_HAS_X931_RNG)
+ #include <botan/x931_rng.h>
+ #include <botan/aes.h>
+ #include <botan/des.h>
+#endif
using namespace Botan;
namespace {
-RandomNumberGenerator* get_x931(const std::string& algo, const std::string& ikm_hex)
+RandomNumberGenerator* get_rng(const std::string& algo, const std::string& ikm_hex)
{
const auto ikm = hex_decode(ikm_hex);
+#if defined(BOTAN_HAS_X931_RNG)
if(algo == "X9.31-RNG(TripleDES)")
return new ANSI_X931_RNG(new TripleDES, new Fixed_Output_RNG(ikm));
else if(algo == "X9.31-RNG(AES-128)")
@@ -26,6 +29,7 @@ RandomNumberGenerator* get_x931(const std::string& algo, const std::string& ikm_
return new ANSI_X931_RNG(new AES_192, new Fixed_Output_RNG(ikm));
else if(algo == "X9.31-RNG(AES-256)")
return new ANSI_X931_RNG(new AES_256, new Fixed_Output_RNG(ikm));
+#endif
return nullptr;
}
@@ -35,10 +39,14 @@ size_t x931_test(const std::string& algo,
const std::string& out,
size_t L)
{
- std::unique_ptr<RandomNumberGenerator> x931(get_x931(algo, ikm));
- x931->reseed(0);
+ std::unique_ptr<RandomNumberGenerator> rng(get_rng(algo, ikm));
+
+ if(!rng)
+ throw std::runtime_error("Unknown RNG " + algo);
+
+ rng->reseed(0);
- const std::string got = hex_encode(x931->random_vec(L));
+ const std::string got = hex_encode(rng->random_vec(L));
if(got != out)
{