summaryrefslogtreecommitdiffstats
path: root/support
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2014-11-04 00:53:41 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-11-04 00:53:41 +0000
commit31ac5350615c2a1f8c01d354ab07768de999a400 (patch)
tree2542b77cfbaa1e8f80f99cd25e9872b639caef5e /support
parenta4403d98e8aba592195fe2558fa945110d0ed052 (diff)
parent140f3a336ff5383b3462a720786143f3dda347bf (diff)
downloadlibcore-31ac5350615c2a1f8c01d354ab07768de999a400.zip
libcore-31ac5350615c2a1f8c01d354ab07768de999a400.tar.gz
libcore-31ac5350615c2a1f8c01d354ab07768de999a400.tar.bz2
am 140f3a33: Merge "SSLSocket: document current behavior with SSLContext"
* commit '140f3a336ff5383b3462a720786143f3dda347bf': SSLSocket: document current behavior with SSLContext
Diffstat (limited to 'support')
-rw-r--r--support/src/test/java/libcore/java/security/StandardNames.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/support/src/test/java/libcore/java/security/StandardNames.java b/support/src/test/java/libcore/java/security/StandardNames.java
index 528a651..ff6128e 100644
--- a/support/src/test/java/libcore/java/security/StandardNames.java
+++ b/support/src/test/java/libcore/java/security/StandardNames.java
@@ -101,6 +101,9 @@ public final class StandardNames extends Assert {
public static final Map<String,Set<String>> CIPHER_PADDINGS
= new HashMap<String,Set<String>>();
+ private static final Map<String, String[]> SSL_CONTEXT_PROTOCOLS_ENABLED
+ = new HashMap<String,String[]>();
+
private static void provide(String type, String algorithm) {
Set<String> algorithms = PROVIDER_ALGORITHMS.get(type);
if (algorithms == null) {
@@ -134,6 +137,18 @@ public final class StandardNames extends Assert {
}
paddings.addAll(Arrays.asList(newPaddings));
}
+ private static void provideSslContextEnabledProtocols(String algorithm, TLSVersion minimum,
+ TLSVersion maximum) {
+ if (minimum.ordinal() > maximum.ordinal()) {
+ throw new RuntimeException("TLS version: minimum > maximum");
+ }
+ int versionsLength = maximum.ordinal() - minimum.ordinal() + 1;
+ String[] versionNames = new String[versionsLength];
+ for (int i = 0; i < versionsLength; i++) {
+ versionNames[i] = TLSVersion.values()[i + minimum.ordinal()].name;
+ }
+ SSL_CONTEXT_PROTOCOLS_ENABLED.put(algorithm, versionNames);
+ }
static {
provide("AlgorithmParameterGenerator", "DSA");
provide("AlgorithmParameterGenerator", "DiffieHellman");
@@ -533,6 +548,22 @@ public final class StandardNames extends Assert {
}
}
+
+ if (IS_RI) {
+ provideSslContextEnabledProtocols("SSL", TLSVersion.SSLv3, TLSVersion.TLSv1);
+ provideSslContextEnabledProtocols("SSLv3", TLSVersion.SSLv3, TLSVersion.TLSv1);
+ provideSslContextEnabledProtocols("TLS", TLSVersion.SSLv3, TLSVersion.TLSv1);
+ provideSslContextEnabledProtocols("TLSv1", TLSVersion.SSLv3, TLSVersion.TLSv1);
+ provideSslContextEnabledProtocols("TLSv1.1", TLSVersion.SSLv3, TLSVersion.TLSv11);
+ provideSslContextEnabledProtocols("TLSv1.2", TLSVersion.SSLv3, TLSVersion.TLSv12);
+ } else {
+ provideSslContextEnabledProtocols("SSL", TLSVersion.SSLv3, TLSVersion.TLSv12);
+ provideSslContextEnabledProtocols("SSLv3", TLSVersion.SSLv3, TLSVersion.TLSv12);
+ provideSslContextEnabledProtocols("TLS", TLSVersion.SSLv3, TLSVersion.TLSv12);
+ provideSslContextEnabledProtocols("TLSv1", TLSVersion.SSLv3, TLSVersion.TLSv12);
+ provideSslContextEnabledProtocols("TLSv1.1", TLSVersion.SSLv3, TLSVersion.TLSv12);
+ provideSslContextEnabledProtocols("TLSv1.2", TLSVersion.SSLv3, TLSVersion.TLSv12);
+ }
}
public static final String SSL_CONTEXT_PROTOCOLS_DEFAULT = "Default";
@@ -593,6 +624,19 @@ public final class StandardNames extends Assert {
}
}
+ private static enum TLSVersion {
+ SSLv3("SSLv3"),
+ TLSv1("TLSv1"),
+ TLSv11("TLSv1.1"),
+ TLSv12("TLSv1.2");
+
+ private final String name;
+
+ TLSVersion(String name) {
+ this.name = name;
+ }
+ };
+
/**
* Valid values for X509TrustManager.checkClientTrusted authType,
* either the algorithm of the public key or UNKNOWN.
@@ -1084,6 +1128,12 @@ public final class StandardNames extends Assert {
}
}
+ public static void assertSSLContextEnabledProtocols(String version, String[] protocols) {
+ assertEquals("For protocol \"" + version + "\"",
+ Arrays.toString(SSL_CONTEXT_PROTOCOLS_ENABLED.get(version)),
+ Arrays.toString(protocols));
+ }
+
private static boolean isPermittedDefaultCipherSuite(String cipherSuite) {
assertNotNull(cipherSuite);
if (CIPHER_SUITE_SECURE_RENEGOTIATION.equals(cipherSuite)) {