boringssl/crypto/rand/CMakeLists.txt
Adam Langley 92f888e836 Make fork-unsafe buffering act via CTR-DRBG.
Fork-unsafe buffering was a mode that could be enabled by applications
that were sure that they didn't need to worry about state duplication.
It saved reads to urandom.

Since everything is now going through the CTR-DRBG, we can get the same
effect by simply not reading additional data from urandom in this case.

This change drops the buffering from urandom.c and, instead, implements
fork-unsafe buffering as a mode that skips reading additional data from
urandom, which only happened when RDRAND wasn't available anyway.

Since we expect the power-on self-tests to call into the PRNG, this
change also makes the flag capable of changing at any point by using a
mutex rather than a once. This is split into a separate file so that it
doesn't have to go into the FIPS module—since it uses r/w data that
would be a pain.

Change-Id: I5fd0ead0422e770e35758f080bb1cffa70d0c8da
Reviewed-on: https://boringssl-review.googlesource.com/14924
Reviewed-by: Adam Langley <agl@google.com>
2017-04-14 16:55:49 +00:00

39 lines
542 B
CMake

include_directories(../../include)
if (${ARCH} STREQUAL "x86_64")
set(
RAND_ARCH_SOURCES
rdrand-x86_64.${ASM_EXT}
)
endif()
add_library(
rand
OBJECT
ctrdrbg.c
deterministic.c
forkunsafe.c
fuchsia.c
rand.c
urandom.c
windows.c
${RAND_ARCH_SOURCES}
)
perlasm(rdrand-x86_64.${ASM_EXT} asm/rdrand-x86_64.pl)
add_executable(
ctrdrbg_vector_test
ctrdrbg_vector_test.cc
$<TARGET_OBJECTS:test_support>
)
target_link_libraries(ctrdrbg_vector_test crypto)
add_dependencies(all_tests ctrdrbg_vector_test)