OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "crypto/openssl_util.h" | 5 #include "crypto/openssl_util.h" |
6 | 6 |
7 #include <openssl/err.h> | 7 #include <openssl/err.h> |
8 #include <openssl/ssl.h> | |
9 #include <openssl/cpu.h> | 8 #include <openssl/cpu.h> |
| 9 #include <openssl/crypto.h> |
10 #include <stddef.h> | 10 #include <stddef.h> |
11 #include <stdint.h> | 11 #include <stdint.h> |
12 | 12 |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/singleton.h" | 15 #include "base/memory/singleton.h" |
16 #include "base/strings/string_piece.h" | 16 #include "base/strings/string_piece.h" |
17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
18 | 18 |
19 #if defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL) | 19 #if defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL) |
(...skipping 22 matching lines...) Expand all Loading... |
42 OpenSSLInitSingleton, | 42 OpenSSLInitSingleton, |
43 base::LeakySingletonTraits<OpenSSLInitSingleton>>::get(); | 43 base::LeakySingletonTraits<OpenSSLInitSingleton>>::get(); |
44 } | 44 } |
45 private: | 45 private: |
46 friend struct base::DefaultSingletonTraits<OpenSSLInitSingleton>; | 46 friend struct base::DefaultSingletonTraits<OpenSSLInitSingleton>; |
47 OpenSSLInitSingleton() { | 47 OpenSSLInitSingleton() { |
48 #if defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL) | 48 #if defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL) |
49 const bool has_neon = | 49 const bool has_neon = |
50 (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0; | 50 (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0; |
51 base::CPU cpu; | 51 base::CPU cpu; |
52 // CRYPTO_set_NEON_capable is called before |SSL_library_init| because this | 52 // CRYPTO_set_NEON_capable is called before |CRYPTO_library_init| because |
53 // stops BoringSSL from probing for NEON support via SIGILL in the case that | 53 // this stops BoringSSL from probing for NEON support via SIGILL in the case |
54 // getauxval isn't present. Also workaround a CPU with broken NEON | 54 // that getauxval isn't present. Also workaround a CPU with broken NEON |
55 // support. See https://code.google.com/p/chromium/issues/detail?id=341598 | 55 // support. See https://code.google.com/p/chromium/issues/detail?id=341598 |
56 CRYPTO_set_NEON_capable(has_neon && !cpu.has_broken_neon()); | 56 CRYPTO_set_NEON_capable(has_neon && !cpu.has_broken_neon()); |
57 #endif | 57 #endif |
58 | 58 |
59 SSL_library_init(); | 59 CRYPTO_library_init(); |
60 } | 60 } |
61 | 61 |
62 ~OpenSSLInitSingleton() {} | 62 ~OpenSSLInitSingleton() {} |
63 | 63 |
64 DISALLOW_COPY_AND_ASSIGN(OpenSSLInitSingleton); | 64 DISALLOW_COPY_AND_ASSIGN(OpenSSLInitSingleton); |
65 }; | 65 }; |
66 | 66 |
67 // Callback routine for OpenSSL to print error messages. |str| is a | 67 // Callback routine for OpenSSL to print error messages. |str| is a |
68 // NULL-terminated string of length |len| containing diagnostic information | 68 // NULL-terminated string of length |len| containing diagnostic information |
69 // such as the library, function and reason for the error, the file and line | 69 // such as the library, function and reason for the error, the file and line |
(...skipping 23 matching lines...) Expand all Loading... |
93 std::string message; | 93 std::string message; |
94 location.Write(true, true, &message); | 94 location.Write(true, true, &message); |
95 DVLOG(1) << "OpenSSL ERR_get_error stack from " << message; | 95 DVLOG(1) << "OpenSSL ERR_get_error stack from " << message; |
96 ERR_print_errors_cb(&OpenSSLErrorCallback, NULL); | 96 ERR_print_errors_cb(&OpenSSLErrorCallback, NULL); |
97 } else { | 97 } else { |
98 ERR_clear_error(); | 98 ERR_clear_error(); |
99 } | 99 } |
100 } | 100 } |
101 | 101 |
102 } // namespace crypto | 102 } // namespace crypto |
OLD | NEW |