diff options
author | Jack Lloyd <[email protected]> | 2018-08-13 16:25:55 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-08-13 16:25:55 -0400 |
commit | 3f313ff9ef28f00cf7a4822d95eb0af29e3a5e41 (patch) | |
tree | e37a511f6fb9824ab201eeefd1479205ade86d3f /src/lib/ffi | |
parent | b34fc175d8a5bef2ab148afef9e5aa4faf1d392f (diff) |
Expose RDRAND RNG through FFI
Diffstat (limited to 'src/lib/ffi')
-rw-r--r-- | src/lib/ffi/ffi_rng.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/lib/ffi/ffi_rng.cpp b/src/lib/ffi/ffi_rng.cpp index 7e185f75d..e193d4123 100644 --- a/src/lib/ffi/ffi_rng.cpp +++ b/src/lib/ffi/ffi_rng.cpp @@ -10,6 +10,10 @@ #include <botan/system_rng.h> #include <botan/auto_rng.h> +#if defined(BOTAN_HAS_RDRAND_RNG) + #include <botan/rdrand_rng.h> +#endif + extern "C" { using namespace Botan_FFI; @@ -36,15 +40,22 @@ int botan_rng_init(botan_rng_t* rng_out, const char* rng_type) { rng.reset(new Botan::Null_RNG); } +#if defined(BOTAN_HAS_RDRAND_RNG) + else if(rng_type_s == "rdrand" && Botan::RDRAND_RNG::available()) + { + rng.reset(new Botan::RDRAND_RNG); + } +#endif #if defined(BOTAN_TARGET_OS_HAS_THREADS) else if(rng_type_s == "user-threadsafe") { rng.reset(new Botan::Serialized_RNG(new Botan::AutoSeeded_RNG)); } #endif - else + + if(!rng) { - return BOTAN_FFI_ERROR_BAD_PARAMETER; + return BOTAN_FFI_ERROR_NOT_IMPLEMENTED; } *rng_out = new botan_rng_struct(rng.release()); |