From da95173201779658f2bea88fd4c9ef4415575d85 Mon Sep 17 00:00:00 2001 From: davidben Date: Mon, 6 Jul 2015 14:23:31 -0700 Subject: [PATCH] Use EVP_has_aes_hardware to check AES-GCM hardware support. The base::CPU logic is based on what NSS's implementation requires. BoringSSL includes both AVX and non-AVX CLMUL code. This should make us prefer AES-GCM on a few more CPU families; it seems PCLMULQDQ predated AVX by a year. (It's also more correct; what we care about is not the CPU but whether BoringSSL will enable a hardware-supported implementation.) BUG=none Review URL: https://codereview.chromium.org/1217923003 Cr-Commit-Position: refs/heads/master@{#337477} --- net/quic/quic_stream_factory.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/net/quic/quic_stream_factory.cc b/net/quic/quic_stream_factory.cc index 02b0b986be89..0a43e7044de1 100644 --- a/net/quic/quic_stream_factory.cc +++ b/net/quic/quic_stream_factory.cc @@ -7,7 +7,6 @@ #include #include -#include "base/cpu.h" #include "base/location.h" #include "base/metrics/field_trial.h" #include "base/metrics/histogram_macros.h" @@ -46,6 +45,12 @@ #include "base/win/windows_version.h" #endif +#if defined(USE_OPENSSL) +#include +#else +#include "base/cpu.h" +#endif + namespace net { namespace { @@ -609,8 +614,12 @@ QuicStreamFactory::QuicStreamFactory( crypto_config_.SetChannelIDSource( new ChannelIDSourceChromium(channel_id_service)); } +#if defined(USE_OPENSSL) + bool has_aes_hardware_support = !!EVP_has_aes_hardware(); +#else base::CPU cpu; bool has_aes_hardware_support = cpu.has_aesni() && cpu.has_avx(); +#endif UMA_HISTOGRAM_BOOLEAN("Net.QuicSession.PreferAesGcm", has_aes_hardware_support); if (has_aes_hardware_support || prefer_aes_) -- 2.11.4.GIT