Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: crypto/openssl_util.cc

Issue 442863003: Disable Poly1305 code only on bad chips. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Leak the LazyInstance. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/cpu.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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> 8 #include <openssl/ssl.h>
9 #include <openssl/cpu.h> 9 #include <openssl/cpu.h>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "base/memory/singleton.h" 13 #include "base/memory/singleton.h"
14 #include "base/strings/string_piece.h" 14 #include "base/strings/string_piece.h"
15 #include "base/synchronization/lock.h" 15 #include "base/synchronization/lock.h"
16 #include "build/build_config.h" 16 #include "build/build_config.h"
17 17
18 #if defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL) 18 #if defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL)
19 #include <cpu-features.h> 19 #include <cpu-features.h>
20 #include "base/cpu.h"
20 #endif 21 #endif
21 22
22 namespace crypto { 23 namespace crypto {
23 24
24 namespace { 25 namespace {
25 26
26 void CurrentThreadId(CRYPTO_THREADID* id) { 27 void CurrentThreadId(CRYPTO_THREADID* id) {
27 CRYPTO_THREADID_set_numeric( 28 CRYPTO_THREADID_set_numeric(
28 id, static_cast<unsigned long>(base::PlatformThread::CurrentId())); 29 id, static_cast<unsigned long>(base::PlatformThread::CurrentId()));
29 } 30 }
(...skipping 25 matching lines...) Expand all
55 for (int i = 0; i < num_locks; ++i) 56 for (int i = 0; i < num_locks; ++i)
56 locks_.push_back(new base::Lock()); 57 locks_.push_back(new base::Lock());
57 CRYPTO_set_locking_callback(LockingCallback); 58 CRYPTO_set_locking_callback(LockingCallback);
58 CRYPTO_THREADID_set_callback(CurrentThreadId); 59 CRYPTO_THREADID_set_callback(CurrentThreadId);
59 60
60 #if defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL) 61 #if defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL)
61 const bool has_neon = 62 const bool has_neon =
62 (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0; 63 (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0;
63 if (has_neon) 64 if (has_neon)
64 CRYPTO_set_NEON_capable(1); 65 CRYPTO_set_NEON_capable(1);
65 // In all cases, currently, mark the NEON unit as broken because some 66 // See https://code.google.com/p/chromium/issues/detail?id=341598
66 // phones can't execute the Poly1305 code correctly. See 67 base::CPU cpu;
67 // https://code.google.com/p/chromium/issues/detail?id=341598 68 CRYPTO_set_NEON_functional(!cpu.has_broken_neon());
68 CRYPTO_set_NEON_functional(0);
69 #endif 69 #endif
70 } 70 }
71 71
72 ~OpenSSLInitSingleton() { 72 ~OpenSSLInitSingleton() {
73 CRYPTO_set_locking_callback(NULL); 73 CRYPTO_set_locking_callback(NULL);
74 EVP_cleanup(); 74 EVP_cleanup();
75 ERR_free_strings(); 75 ERR_free_strings();
76 } 76 }
77 77
78 static void LockingCallback(int mode, int n, const char* file, int line) { 78 static void LockingCallback(int mode, int n, const char* file, int line) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 std::string message; 122 std::string message;
123 location.Write(true, true, &message); 123 location.Write(true, true, &message);
124 DVLOG(1) << "OpenSSL ERR_get_error stack from " << message; 124 DVLOG(1) << "OpenSSL ERR_get_error stack from " << message;
125 ERR_print_errors_cb(&OpenSSLErrorCallback, NULL); 125 ERR_print_errors_cb(&OpenSSLErrorCallback, NULL);
126 } else { 126 } else {
127 ERR_clear_error(); 127 ERR_clear_error();
128 } 128 }
129 } 129 }
130 130
131 } // namespace crypto 131 } // namespace crypto
OLDNEW
« no previous file with comments | « base/cpu.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698