diff options
author | Gil <mcg@google.com> | 2018-01-19 12:20:46 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-19 12:20:46 -0800 |
commit | 9f7c094f9f00a6efc0107071f109ef1bc4d7357d (patch) | |
tree | 98326bf2f1190338ddc451ea5418bbc4b3348008 /Firestore/core/src/firebase/firestore/util/CMakeLists.txt | |
parent | 6a6e14822fc8c4ec16e9045b23b515b4baad14fd (diff) |
Add platform detection logic for SecureRandom (#676)
* Add CMake platform detection logic for SecureRandom
Now only builds secure_random_arc4random.cc if available.
Remove firebase/firestore/base/port.h. Nothing else was in that
directory.
* Add a SecureRandom implementation that uses OpenSSL
This is usable on Linux, Windows, and Android
* Properly check return from RAND_bytes
Diffstat (limited to 'Firestore/core/src/firebase/firestore/util/CMakeLists.txt')
-rw-r--r-- | Firestore/core/src/firebase/firestore/util/CMakeLists.txt | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/Firestore/core/src/firebase/firestore/util/CMakeLists.txt b/Firestore/core/src/firebase/firestore/util/CMakeLists.txt index 7283942..737173b 100644 --- a/Firestore/core/src/firebase/firestore/util/CMakeLists.txt +++ b/Firestore/core/src/firebase/firestore/util/CMakeLists.txt @@ -16,11 +16,12 @@ # libraries in here are an implementation detail of making this a # mutli-platform build. +include(CheckSymbolExists) +include(CheckIncludeFiles) + cc_library( firebase_firestore_util_base SOURCES - secure_random.h - secure_random_arc4random.cc string_printf.cc string_printf.h DEPENDS @@ -60,15 +61,55 @@ else() endif() +## secure_random + +check_symbol_exists(arc4random stdlib.h HAVE_ARC4RANDOM) +cc_library( + firebase_firestore_util_arc4random + SOURCES + secure_random_arc4random.cc +) + +get_target_property( + CMAKE_REQUIRED_INCLUDES + OpenSSL::Crypto INTERFACE_INCLUDE_DIRECTORIES +) +check_include_files(openssl/rand.h HAVE_OPENSSL_RAND_H) +cc_library( + firebase_firestore_util_openssl + SOURCES + secure_random_openssl.cc + DEPENDS + OpenSSL::Crypto +) + +if(HAVE_ARC4RANDOM) + list(APPEND UTIL_DEPENDS firebase_firestore_util_arc4random) + +elseif(HAVE_OPENSSL_RAND_H) + list(APPEND UTIL_DEPENDS firebase_firestore_util_openssl) + +else() + message(FATAL_ERROR "No implementation for SecureRandom available.") + +endif() + + ## main library +configure_file( + config.h.in + config.h +) cc_library( firebase_firestore_util SOURCES autoid.cc autoid.h + config.h firebase_assert.h log.h + secure_random.h DEPENDS ${UTIL_DEPENDS} firebase_firestore_util_base |