aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/rng
Commit message (Collapse)AuthorAgeFilesLines
* Slight improvements to RNG testsJack Lloyd2017-09-221-2/+2
|
* Apply final annotations to the library alsoJack Lloyd2017-09-221-1/+1
| | | | | Done by a perl script which converted all classes to final, followed by selective reversion where it caused compilation failures.
* Merge GH #1219 Implement System_RNG on macOS/iOS using arc4randomJack Lloyd2017-09-211-6/+3
|\
| * Supposedly iOS has arc4random, so maybe this works...Jack Lloyd2017-09-211-6/+3
| |
* | More include header cleanupsJack Lloyd2017-09-212-1/+1
| |
* | Clean up header includesJack Lloyd2017-09-211-1/+0
|/ | | | | | | Avoid including build.h or assert.h directly, instead always take them though types.h Avoid math.h in favor of cmath
* Change header guard format to BOTAN_FOO_H_Jack Lloyd2017-09-207-14/+14
| | | | | | ISO C++ reserves names with double underscores in them Closes #512
* More annotationsJack Lloyd2017-09-191-1/+1
|
* Add API stability annotations.Jack Lloyd2017-09-196-10/+10
| | | | | Defined in build.h, all equal to BOTAN_DLL so ties into existing system for exporting symbols.
* Define macro so windows.h doesn't include winsock.hJack Lloyd2017-09-031-0/+1
| | | | Ugh Windows headers y u so nasty.
* Refactor RNGs to support Windows PhoneJack Lloyd2017-09-022-108/+150
| | | | | | | | | | | | | | | | | | | This OS has its own crypto API and does not support CryptGenRandom. Splits System_RNG_Impl into distinct declarations one per implementation type. Easier to read now that we are up to 4 distinct versions. Removes the CryptoAPI entropy source, and replaces it with an entropy source that calls the system RNG. This is nominally a bit less flexible in that the entropy source allowed polling multiple providers (though we didn't actually make use of that). Plus side is it works on all systems. Currently the dev_random entropy source is still there because we do actually use it to poll both /dev/random and /dev/urandom, and it might be useful (on certain systems) to also poll a HW RNG, which are often assigned their own device node. This could debatably also be removed in favor of just reading the system RNG.
* Fix missing virtual destructor on CSP_HandleJack Lloyd2017-08-311-1/+1
| | | | Caught by GCC cross compiling. Also fix a couple 0-as-null warnings.
* Reset the ChaCha key in clearJack Lloyd2017-08-031-0/+1
| | | | | This is not necessary for setup, but we want to zero the key out in the event someone calls clear explicitly.
* Use new reset_reseed_counter function within Stateful_RNG as wellJack Lloyd2017-08-031-3/+3
|
* Add Stateful_RNG::reset_reseed_counterJack Lloyd2017-08-033-4/+7
| | | | Instead of giving subclasses access to the variable directly.
* Refactor stateful RNG tests to cover both HMAC_DRBG and ChaCha_RNGJack Lloyd2017-08-034-17/+38
|
* Add ChaCha_RNGJack Lloyd2017-08-033-0/+238
|
* Add explicit tests for RDRAND_RNG and System_RNGJack Lloyd2017-08-031-9/+7
|
* Fix for #1078Baruch2017-06-191-1/+1
|
* Follow NIST SP 800-57 for HMAC_DRBG security levelRené Korthaus2017-04-031-3/+12
|
* Change security_strength of HMAC_DRBGRené Korthaus2017-04-032-5/+12
| | | | | | | | | | | | | | Looking into SP808-90A, it mentions that the max security strength is the security strength of the hash function for pre-image resistance. The current implementation however always only uses half of the output length, therefore only providing half of the security strength possible. However, SP800-90A supports only up to 256 bit security strength, so we fix it to this upper limit. In a second change, add_entropy() now also resets the reseed counter if enough entropy input provided.
* Remove "Dirty hack" for multiple defines in lex_me_harder()Simon Warta2017-04-025-7/+17
|
* Use arc4random(3) as system rng on OpenBSD.Alexander Bluhm2017-03-301-0/+15
| | | | | | | | | OpenBSD provides the arc4random(3) function in libc for user land programs that need good random data. Use this to implement the Botan system random number generator. It has the advantage over /dev/urandom that it works without file descriptors and in chroot(2) environment. Internally libc is currently using a ChaCha20 cipher as PRNG and getentropy(2) to reseed itself automatically.
* Avoid use of deprecated function in (deprecated) Serialized_RNG constructorJack Lloyd2017-02-192-2/+12
|
* Change meaning of get_processor_timestampJack Lloyd2017-01-272-2/+2
| | | | | | | | | | | Now let it return 0 if we have no hardware timestamp, and add OS::get_high_resolution_clock for best available clock. This is mainly because it's confusing for get_processor_timestamp to return something that is not a processor timestamp and because it simplifies adding cycles/byte output if we know that something is or is not a cycle counter. Also adds Windows SEH version of run_cpu_instruction_probe. Untested, uncompiled.
* Convert to using standard uintN_t integer typesJack Lloyd2016-12-188-46/+46
| | | | | | Renames a couple of functions for somewhat better name consistency, eg make_u32bit becomes make_uint32. The old typedefs remain for now since probably lots of application code uses them.
* IncludeOS has random device files nowJack Lloyd2016-12-181-0/+1
| | | | | | GH #726 [ci skip]
* system_rng: workaround read only urandomAlon Bar-Lev2016-12-011-1/+4
| | | | | | | | botan_rng_reseed: System_RNG write failed error 9 FFI ran 252 tests 1 FAILED Failure 1: FFI botan_rng_reseed unexpectedly failed with error code -1 Signed-off-by: Alon Bar-Lev <[email protected]>
* define NOMINMAX 1 before every include of windows.hBaruch Burstein2016-11-281-2/+1
|
* Simple tests for AutoSeeded_RNGJack Lloyd2016-11-262-1/+2
|
* Avoid having source files start with /**Jack Lloyd2016-11-252-2/+2
| | | | | | | This caused Doxygen to dump the copyright notices for those files into the Botan namespace description, which is not helpful. [ci skip]
* Don't force HMAC_DRBG to be enabledJack Lloyd2016-11-182-1/+2
| | | | | No need to strictly require it, and some applications may only want system RNG or RDRAND.
* Remove HMAC_RNG, X9.31-RNG, BeOS stats, EGD reader, Unix process runnerJack Lloyd2016-10-288-504/+18
| | | | | Change AutoSeeded_RNG to use SHA-384, SHA-256, SHA-3(256), or SHA-1, whichever is available (in that order).
* HMAC_DRBG - Fix constructor init order. Use create_or_throw to simplify.Jack Lloyd2016-10-281-6/+3
|
* make max_number_of_bytes_per_request configurableDaniel Neus2016-10-282-27/+79
|
* Fix doxygen warnings [ci skip]René Korthaus2016-10-193-2/+6
|
* Improve rng doxygen [ci skip]René Korthaus2016-10-196-11/+82
|
* Add ISA annotations to functions using SIMD, AES, etcJack Lloyd2016-10-141-0/+1
| | | | | | | | Also emit `#pragma GCC target` in the ISA specific amalgamation files. This allows compiling without any special compiler flags, at least with GCC 6.2 and Clang 3.8. The ISA annotations are ignored in MSVC, which just emits whatever instruction the intrinsic requires.
* Abstract out mutex type. Make threads optional.Jack Lloyd2016-10-122-9/+13
|
* Resolve #647Nathan Hourt2016-10-031-0/+6
| | | Implement a backoff approach to opening the system RNG: if opening read-write fails, try to open read-only. This will allow the RNG to be used, but attempts to add entropy will fail. If opening as read-only also fails, only then throw an exception.
* HMAC_RNG ignored its entropy_source argument :(Jack Lloyd2016-08-311-1/+1
|
* RNG changes (GH #593)Jack Lloyd2016-08-2420-348/+745
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change reseed interval logic to count calls to `randomize` rather than bytes, to match SP 800-90A Changes RNG reseeding API: there is no implicit reference to the global entropy sources within the RNGs anymore. The entropy sources must be supplied with the API call. Adds support for reseding directly from another RNG (such as a system or hardware RNG). Stateful_RNG keeps optional references to both an RNG and a set of entropy sources. During a reseed, both sources are used if set. These can be provided to HMAC_DRBG constructor. For HMAC_DRBG, SP800-90A requires we output no more than 2**16 bytes per DRBG request. We treat requests longer than that as if the caller had instead made several sequential maximum-length requests. This means it is possible for one or more reseeds to trigger even in the course of generating a single (long) output (generate a 256-bit key and use ChaCha or HKDF if this is a problem). Adds RNG::randomize_with_ts_input which takes timestamps and uses them as the additional_data DRBG field. Stateful_RNG overrides this to also include the process ID and the reseed counter. AutoSeeded_RNG's `randomize` uses this. Officially deprecates RNG::make_rng and the Serialized_RNG construtor which creates an AutoSeeded_RNG. With these removed, it would be possible to perform a build with no AutoSeeded_RNG/HMAC_DRBG at all (eg, for applications which only use the system RNG). Tests courtesy @cordney in GH PRs #598 and #600
* Fix header guard formatJack Lloyd2016-07-201-2/+2
| | | | | configure.py expects all header guards to match a specific form, for finding them when generating the amalgamation file.
* Add RDRAND_RNGJack Lloyd2016-07-193-0/+161
| | | | | | | | For those that are willing to trust uninspectible hardware. :) Changes RDRAND entropy source to call RDRAND_RNG Add --rdrand flag to rng cmdlet
* Address some review comments from @cordneyJack Lloyd2016-07-179-27/+29
| | | | | | | | | Use consistent naming for the max output before reseed parameter. The constant (default) value is renamed to BOTAN_RNG_DEFAULT_MAX_OUTPUT_BEFORE_RESEED, since without the DEFAULT_ it reads like a compile time maximum instead. Use uint8_t instead of byte.
* Revamp entropy pollingJack Lloyd2016-07-172-4/+11
| | | | | Remove Entropy_Accumulator, instead have entropy sources directly add entropy to the RNG.
* Move poll logic to Entropy_SourcesJack Lloyd2016-07-171-15/+1
|
* Add Stateful_RNGJack Lloyd2016-07-178-140/+135
| | | | | | | | | | | | | | Handles fork checking for HMAC_RNG and HMAC_DRBG AutoSeeded_RNG change - switch to HMAC_DRBG as default. Start removing the io buffer from entropy poller. Update default RNG poll bits to 256. Fix McEliece test, was using wrong RNG API. Update docs.
* Make the DRBG hash selectable in build.h with BOTAN_AUTO_RNG_DRBG_HASH_FUNCTIONJack Lloyd2016-07-172-3/+3
| | | | Add some missing overrides
* If EPERM when writing to the random device, return silently.Jack Lloyd2016-07-171-1/+13
| | | | | | | | | That failure seems like an explicit system policy decision, so accept it as such. Versus say EBADF or EFAULT which would instead suggest a library bug. This return is seen on OS X Travis CI, unclear if this is a problem with OS X or with how Travis does OS X containers.