From 98656eef99633eacc779057074cb0a13e1f49e8b Mon Sep 17 00:00:00 2001 From: Nikita Iashchenko Date: Fri, 2 Oct 2020 11:55:28 +0000 Subject: [PATCH] Add TLS handshake metrics atom proto This CL adds a new Westworld pushed metric which counts the number of: 1. Successful/failed handshakes 2. Chosen protocol after handshake 3. Chosen cipher suite after handshake 4. Duration of the handshake, in milliseconds Bug: 160345816 Test: m statsd_testdrive && ./out/host/linux-x86/bin/statsd_testdrive 317 Change-Id: I142a792c34dced6b0e27b867ed3a1d95249a5f7f --- cmds/statsd/src/atoms.proto | 18 ++++++ core/proto/android/stats/tls/enums.proto | 70 ++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 core/proto/android/stats/tls/enums.proto diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto index 084959b5071ad..c53b2a7565ae6 100644 --- a/cmds/statsd/src/atoms.proto +++ b/cmds/statsd/src/atoms.proto @@ -59,6 +59,7 @@ import "frameworks/base/core/proto/android/stats/mediaprovider/mediaprovider_enu import "frameworks/base/core/proto/android/stats/storage/storage_enums.proto"; import "frameworks/base/core/proto/android/stats/style/style_enums.proto"; import "frameworks/base/core/proto/android/stats/sysui/notification_enums.proto"; +import "frameworks/base/core/proto/android/stats/tls/enums.proto"; import "frameworks/base/core/proto/android/telecomm/enums.proto"; import "frameworks/base/core/proto/android/telephony/enums.proto"; import "frameworks/base/core/proto/android/view/enums.proto"; @@ -499,6 +500,7 @@ message Atom { CarrierIdMatchingTable carrier_id_table_update = 314 [(module) = "telephony"]; DataStallRecoveryReported data_stall_recovery_reported = 315 [(module) = "telephony"]; MediametricsMediaParserReported mediametrics_mediaparser_reported = 316; + TlsHandshakeReported tls_handshake_reported = 317 [(module) = "conscrypt"]; // StatsdStats tracks platform atoms with ids upto 500. // Update StatsdStats::kMaxPushedAtomId when atom ids here approach that value. @@ -11959,3 +11961,19 @@ message HdmiCecMessageReported { // The reason for the feature abort. optional android.stats.hdmi.FeatureAbortReason feature_abort_reason = 9; } + +/** + * Pushes TLS handshake counters from Conscrypt. + * Pulled from: + * external/conscrypt/common/src/main/java/org/conscrypt/ConscryptEngineSocket.java + * external/conscrypt/common/src/main/java/org/conscrypt/ConscryptFileDescriptorSocket.java + */ +message TlsHandshakeReported { + optional bool success = 1; + + optional android.stats.tls.Protocol protocol = 2; + + optional android.stats.tls.CipherSuite cipher_suite = 3; + + optional int32 handshake_duration_millis = 4; +} diff --git a/core/proto/android/stats/tls/enums.proto b/core/proto/android/stats/tls/enums.proto new file mode 100644 index 0000000000000..0ae87ee1d89bf --- /dev/null +++ b/core/proto/android/stats/tls/enums.proto @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +syntax = "proto2"; +package android.stats.tls; + +// Keep in sync with +// external/conscrypt/{android,platform}/src/main/java/org/conscrypt/Platform.java +enum Protocol { + UNKNOWN_PROTO = 0; + SSLv3 = 1; + TLSv1 = 2; + TLSv1_1 = 3; + TLSv1_2 = 4; + TLSv1_3 = 5; +} + +// Cipher suites' ids are based on IANA's database: +// https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-4 +// +// If you add new cipher suite, make sure id is the same as in IANA's database (see link above) +// +// Keep in sync with +// external/conscrypt/{android,platform}/src/main/java/org/conscrypt/Platform.java +enum CipherSuite { + UNKNOWN_CIPHER_SUITE = 0x0000; + + TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA = 0xC00A; + TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA = 0xC014; + TLS_RSA_WITH_AES_256_CBC_SHA = 0x0035; + TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA = 0xC009; + TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA = 0xC013; + TLS_RSA_WITH_AES_128_CBC_SHA = 0x002F; + TLS_RSA_WITH_3DES_EDE_CBC_SHA = 0x000A; + + // TLSv1.2 cipher suites + TLS_RSA_WITH_AES_128_GCM_SHA256 = 0x009C; + TLS_RSA_WITH_AES_256_GCM_SHA384 = 0x009D; + TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 = 0xC02F; + TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 = 0xC030; + TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 = 0xC02B; + TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 = 0xC02C; + TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 = 0xCCA9; + TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 = 0xCCA8; + + // Pre-Shared Key (PSK) cipher suites + TLS_PSK_WITH_AES_128_CBC_SHA = 0x008C; + TLS_PSK_WITH_AES_256_CBC_SHA = 0x008D; + TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA = 0xC035; + TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA = 0xC036; + TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256 = 0xCCAC; + + // TLS 1.3 cipher suites + TLS_AES_128_GCM_SHA256 = 0x1301; + TLS_AES_256_GCM_SHA384 = 0x1302; + TLS_CHACHA20_POLY1305_SHA256 = 0x1303; +} +