aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/ffi/ffi_rng.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-08-10 10:53:05 -0400
committerJack Lloyd <[email protected]>2018-08-10 10:53:05 -0400
commit2eee96640f4629aa9c6c517b1703e7dcd8a4dbd5 (patch)
tree82c62e857dea098b27124dfe8d37e6d79c8ae795 /src/lib/ffi/ffi_rng.cpp
parentd664c9669a0f3d5f09e3bf89b222abb7483d426e (diff)
Add a "user-threadsafe" option to botan_rng_init
Diffstat (limited to 'src/lib/ffi/ffi_rng.cpp')
-rw-r--r--src/lib/ffi/ffi_rng.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/lib/ffi/ffi_rng.cpp b/src/lib/ffi/ffi_rng.cpp
index 8d97a39d8..b3c5cd967 100644
--- a/src/lib/ffi/ffi_rng.cpp
+++ b/src/lib/ffi/ffi_rng.cpp
@@ -25,11 +25,21 @@ int botan_rng_init(botan_rng_t* rng_out, const char* rng_type)
std::unique_ptr<Botan::RandomNumberGenerator> rng;
if(rng_type_s == "system")
+ {
rng.reset(new Botan::System_RNG);
+ }
else if(rng_type_s == "user")
+ {
rng.reset(new Botan::AutoSeeded_RNG);
+ }
+ else if(rng_type_s == "user-threadsafe")
+ {
+ rng.reset(new Botan::Serialized_RNG(new Botan::AutoSeeded_RNG));
+ }
else
+ {
return BOTAN_FFI_ERROR_BAD_PARAMETER;
+ }
*rng_out = new botan_rng_struct(rng.release());
return BOTAN_FFI_SUCCESS;