external/boringssl: Sync to 2c45fa0b90f61b27973fa81893e014fc8c8e8999.

This includes the following changes:

https://boringssl.googlesource.com/boringssl/+log/faa539f877432814d0f2de19846eb99f2ea1e207..2c45fa0b90f61b27973fa81893e014fc8c8e8999

Test: BoringSSL CTS Presubmits
Change-Id: Ie6dc40e0c979168ec73fa1165cbc6e6b83793439
diff --git a/src/crypto/CMakeLists.txt b/src/crypto/CMakeLists.txt
index 3728e6f..ef8c2d4 100644
--- a/src/crypto/CMakeLists.txt
+++ b/src/crypto/CMakeLists.txt
@@ -1,30 +1,43 @@
 include_directories(../include)
 
-if(APPLE)
-  if (${ARCH} STREQUAL "x86")
-    set(PERLASM_FLAGS "-fPIC -DOPENSSL_IA32_SSE2")
-  endif()
-  set(PERLASM_STYLE macosx)
-  set(ASM_EXT S)
-  enable_language(ASM)
-elseif(UNIX)
+if(UNIX)
   if (${ARCH} STREQUAL "aarch64")
     # The "armx" Perl scripts look for "64" in the style argument
     # in order to decide whether to generate 32- or 64-bit asm.
-    set(PERLASM_STYLE linux64)
+    if (APPLE)
+      set(PERLASM_STYLE ios64)
+    else()
+      set(PERLASM_STYLE linux64)
+    endif()
   elseif (${ARCH} STREQUAL "arm")
-    set(PERLASM_STYLE linux32)
-  elseif (${ARCH} STREQUAL "x86")
-    set(PERLASM_FLAGS "-fPIC -DOPENSSL_IA32_SSE2")
-    set(PERLASM_STYLE elf)
+    if (APPLE)
+      set(PERLASM_STYLE ios32)
+    else()
+      set(PERLASM_STYLE linux32)
+    endif()
   elseif (${ARCH} STREQUAL "ppc64le")
     set(PERLASM_STYLE ppc64le)
   else()
-    set(PERLASM_STYLE elf)
+    if (${ARCH} STREQUAL "x86")
+      set(PERLASM_FLAGS "-fPIC -DOPENSSL_IA32_SSE2")
+    endif()
+    if (APPLE)
+      set(PERLASM_STYLE macosx)
+    else()
+      set(PERLASM_STYLE elf)
+    endif()
   endif()
   set(ASM_EXT S)
   enable_language(ASM)
   set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -Wa,--noexecstack")
+
+  # CMake does not add -isysroot and -arch flags to assembly.
+  if (APPLE)
+    set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -isysroot ${CMAKE_OSX_SYSROOT}")
+    foreach(arch ${CMAKE_OSX_ARCHITECTURES})
+      set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -arch ${arch}")
+    endforeach()
+  endif()
 else()
   if (CMAKE_CL_64)
     message("Using nasm")
@@ -67,11 +80,7 @@
 add_subdirectory(pool)
 
 # Level 0.2 - depends on nothing but itself
-add_subdirectory(sha)
-add_subdirectory(md4)
-add_subdirectory(md5)
 add_subdirectory(modes)
-add_subdirectory(aes)
 add_subdirectory(des)
 add_subdirectory(rc4)
 add_subdirectory(conf)
@@ -80,7 +89,7 @@
 add_subdirectory(curve25519)
 
 # Level 1, depends only on 0.*
-add_subdirectory(digest)
+add_subdirectory(digest_extra)
 add_subdirectory(cipher)
 add_subdirectory(rand)
 add_subdirectory(bio)
@@ -96,7 +105,7 @@
 add_subdirectory(ec)
 add_subdirectory(ecdh)
 add_subdirectory(ecdsa)
-add_subdirectory(hmac)
+add_subdirectory(hmac_extra)
 
 # Level 3
 add_subdirectory(cmac)
@@ -112,8 +121,12 @@
 # Test support code
 add_subdirectory(test)
 
+add_subdirectory(fipsmodule)
+
 add_library(
-  crypto
+  crypto_base
+
+  OBJECT
 
   cpu-aarch64-linux.c
   cpu-arm.c
@@ -129,20 +142,33 @@
   thread_none.c
   thread_pthread.c
   thread_win.c
+)
 
+if(FIPS)
+  SET_SOURCE_FILES_PROPERTIES(fipsmodule/bcm.o PROPERTIES EXTERNAL_OBJECT true)
+  SET_SOURCE_FILES_PROPERTIES(fipsmodule/bcm.o PROPERTIES GENERATED true)
+
+  set(
+    CRYPTO_FIPS_OBJECTS
+
+    fipsmodule/bcm.o
+  )
+endif()
+
+add_library(
+  crypto
+
+  $<TARGET_OBJECTS:crypto_base>
   $<TARGET_OBJECTS:stack>
   $<TARGET_OBJECTS:lhash>
   $<TARGET_OBJECTS:err>
   $<TARGET_OBJECTS:base64>
   $<TARGET_OBJECTS:bytestring>
   $<TARGET_OBJECTS:pool>
-  $<TARGET_OBJECTS:sha>
-  $<TARGET_OBJECTS:md4>
-  $<TARGET_OBJECTS:md5>
-  $<TARGET_OBJECTS:digest>
+  $<TARGET_OBJECTS:fipsmodule>
+  $<TARGET_OBJECTS:digest_extra>
   $<TARGET_OBJECTS:cipher>
   $<TARGET_OBJECTS:modes>
-  $<TARGET_OBJECTS:aes>
   $<TARGET_OBJECTS:des>
   $<TARGET_OBJECTS:rc4>
   $<TARGET_OBJECTS:conf>
@@ -162,7 +188,6 @@
   $<TARGET_OBJECTS:ec>
   $<TARGET_OBJECTS:ecdh>
   $<TARGET_OBJECTS:ecdsa>
-  $<TARGET_OBJECTS:hmac>
   $<TARGET_OBJECTS:cmac>
   $<TARGET_OBJECTS:evp>
   $<TARGET_OBJECTS:hkdf>
@@ -170,8 +195,16 @@
   $<TARGET_OBJECTS:x509>
   $<TARGET_OBJECTS:x509v3>
   $<TARGET_OBJECTS:pkcs8_lib>
+
+  ${CRYPTO_FIPS_OBJECTS}
 )
 
+if(FIPS)
+  add_dependencies(crypto bcm_o_target)
+endif()
+
+SET_TARGET_PROPERTIES(crypto PROPERTIES LINKER_LANGUAGE C)
+
 if(NOT MSVC AND NOT ANDROID)
   target_link_libraries(crypto pthread)
 endif()
@@ -201,7 +234,9 @@
   crypto_test
 
   asn1/asn1_test.cc
+  base64/base64_test.cc
   bio/bio_test.cc
+  bytestring/bytestring_test.cc
   chacha/chacha_test.cc
   constant_time_test.cc
   curve25519/x25519_test.cc
@@ -210,6 +245,7 @@
   ec/ec_test.cc
   err/err_test.cc
   evp/evp_extra_test.cc
+  rand/ctrdrbg_test.cc
   rsa/rsa_test.cc
 
   $<TARGET_OBJECTS:gtest_main>