Bug 1061273 - Part 2: Use per-version DEFAULT_PROTOCOLS and DEFAULT_CIPHER_SUITES. r=nalexander, a=lizzard
authorRichard Newman <rnewman@mozilla.com>
Thu, 04 Jun 2015 11:07:32 -0700
changeset 266222 676ae5e1e869
parent 266221 d9943a662657
child 266223 c2f209debd59
push id4792
push userryanvm@gmail.com
push date2015-06-10 20:30 +0000
treeherdermozilla-beta@f137fedd1455 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander, lizzard
bugs1061273
milestone39.0
Bug 1061273 - Part 2: Use per-version DEFAULT_PROTOCOLS and DEFAULT_CIPHER_SUITES. r=nalexander, a=lizzard
mobile/android/base/background/common/GlobalConstants.java
--- a/mobile/android/base/background/common/GlobalConstants.java
+++ b/mobile/android/base/background/common/GlobalConstants.java
@@ -33,28 +33,81 @@ public class GlobalConstants {
   public static String GECKO_BROADCAST_HEALTHREPORT_PRUNE_METHOD = "broadcastHealthReportPrune";
 
   // Common time values.
   public static final long MILLISECONDS_PER_DAY = 24 * 60 * 60 * 1000;
   public static final long MILLISECONDS_PER_SIX_MONTHS = 180 * MILLISECONDS_PER_DAY;
 
   // Acceptable cipher suites.
   /**
+   * We support only a very limited range of strong cipher suites and protocols:
+   * no SSLv3 or TLSv1.0 (if we can), no DHE ciphers that might be vulnerable to Logjam
+   * (https://weakdh.org/), no RC4.
+   *
+   * Backstory: Bug 717691 (we no longer support Android 2.2, so the name
+   * workaround is unnecessary), Bug 1081953, Bug 1061273, Bug 1166839.
+   *
    * See <http://developer.android.com/reference/javax/net/ssl/SSLSocket.html> for
    * supported Android versions for each set of protocols and cipher suites.
+   *
+   * Note that currently we need to support connections to Sync 1.1 on Mozilla-hosted infra,
+   * as well as connections to FxA and Sync 1.5 on AWS.
+   *
+   * ELB cipher suites:
+   * <http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/elb-security-policy-table.html>
    */
   public static final String[] DEFAULT_CIPHER_SUITES;
   public static final String[] DEFAULT_PROTOCOLS;
 
   static {
-    DEFAULT_CIPHER_SUITES = new String[]
-        {
-          "TLS_DHE_RSA_WITH_AES_256_CBC_SHA",
-          "TLS_DHE_RSA_WITH_AES_128_CBC_SHA",
-          "SSL_RSA_WITH_RC4_128_SHA", // "RC4_SHA"
-        };
-    DEFAULT_PROTOCOLS = new String[]
-        {
-          "SSLv3",
-          "TLSv1",
-        };
+    // Prioritize 128 over 256 as a tradeoff between device CPU/battery and the minor
+    // increase in strength.
+    if (Versions.feature20Plus) {
+      DEFAULT_CIPHER_SUITES = new String[]
+          {
+           "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",   // 20+
+           "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",     // 20+
+           "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256",     // 20+
+           "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",        // 11+
+           "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",     // 20+
+           "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384",     // 20+
+           "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA",        // 11+
+          };
+    } else if (Versions.feature11Plus) {
+      DEFAULT_CIPHER_SUITES = new String[]
+          {
+           "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",        // 11+
+           "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA",      // 11+
+           "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA",        // 11+
+           "TLS_RSA_WITH_AES_256_CBC_SHA",              // 9+
+          };
+    } else {       // 9+
+      // Fall back to the only half-decent cipher suites supported on Gingerbread.
+      // N.B., there appears to be *no overlap* between the ELB 2015-05 default
+      // suites and Gingerbread. A custom configuration is needed if moving beyond
+      // the 2015-03 defaults.
+      DEFAULT_CIPHER_SUITES = new String[]
+          {
+           // This is for Sync 1.5 on ELB 2015-03.
+           "TLS_DHE_RSA_WITH_AES_128_CBC_SHA",
+           "TLS_DHE_DSS_WITH_AES_128_CBC_SHA",
+
+           // This is for Sync 1.1.
+           "TLS_DHE_RSA_WITH_AES_256_CBC_SHA",          // 9+
+           "TLS_RSA_WITH_AES_256_CBC_SHA",              // 9+
+          };
+    }
+
+    if (Versions.feature16Plus) {
+      DEFAULT_PROTOCOLS = new String[]
+          {
+           "TLSv1.2",
+           "TLSv1.1",
+          };
+    } else {
+      // Fall back to TLSv1 if there's nothing better.
+      DEFAULT_PROTOCOLS = new String[]
+          {
+           "TLSv1",
+          };
+    }
   }
 }