8242929: The values of jdk.tls.namedGroups should not be case-sensitive

The values of jdk.tls.namedGroups should not be case-sensitive

Reviewed-by: xuelei
This commit is contained in:
Sibabrata Sahoo 2020-04-23 22:49:55 -07:00
parent 905eb57ede
commit e5c84ff282
3 changed files with 25 additions and 20 deletions
src/java.base/share/classes/sun/security/ssl
test/jdk/sun/security/ssl/CipherSuite

@ -350,7 +350,7 @@ enum NamedGroup {
static NamedGroup nameOf(String name) {
for (NamedGroup group : NamedGroup.values()) {
if (group.name.equals(name)) {
if (group.name.equalsIgnoreCase(name)) {
return group;
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -27,17 +27,17 @@ import javax.net.ssl.SSLSocket;
/*
* @test
* @bug 8224650
* @bug 8224650 8242929
* @library /javax/net/ssl/templates
* /javax/net/ssl/TLSCommon
* @summary Test TLS ciphersuite with each individual supported group
* @run main/othervm NamedGroupsWithCipherSuite x25519
* @run main/othervm NamedGroupsWithCipherSuite x448
* @run main/othervm NamedGroupsWithCipherSuite X448
* @run main/othervm NamedGroupsWithCipherSuite secp256r1
* @run main/othervm NamedGroupsWithCipherSuite secp384r1
* @run main/othervm NamedGroupsWithCipherSuite secp521r1
* @run main/othervm NamedGroupsWithCipherSuite ffdhe2048
* @run main/othervm NamedGroupsWithCipherSuite ffdhe3072
* @run main/othervm NamedGroupsWithCipherSuite secP384r1
* @run main/othervm NamedGroupsWithCipherSuite SECP521R1
* @run main/othervm NamedGroupsWithCipherSuite ffDhe2048
* @run main/othervm NamedGroupsWithCipherSuite FFDHE3072
* @run main/othervm NamedGroupsWithCipherSuite ffdhe4096
* @run main/othervm NamedGroupsWithCipherSuite ffdhe6144
* @run main/othervm NamedGroupsWithCipherSuite ffdhe8192
@ -135,19 +135,23 @@ public class NamedGroupsWithCipherSuite extends SSLSocketTemplate {
public static void main(String[] args) throws Exception {
String namedGroup = args[0];
// Named group is set as per run argument with no change in it's alphabet
System.setProperty("jdk.tls.namedGroups", namedGroup);
System.out.println("NamedGroup: " + namedGroup);
for (Protocol protocol : PROTOCOLS) {
for (CipherSuite cipherSuite : CIPHER_SUITES) {
// Named group converted to lower case just
// to satisfy Test condition
if (cipherSuite.supportedByProtocol(protocol)
&& groupSupportdByCipher(namedGroup, cipherSuite)) {
&& groupSupportdByCipher(namedGroup.toLowerCase(),
cipherSuite)) {
System.out.printf("Protocol: %s, cipher suite: %s%n",
protocol, cipherSuite);
// Named group converted to lower case just
// to satisfy Test condition
new NamedGroupsWithCipherSuite(protocol.name,
cipherSuite.name(), namedGroup).run();
cipherSuite.name(), namedGroup.toLowerCase()).run();
}
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -23,16 +23,16 @@
/*
* @test
* @bug 8226374
* @bug 8226374 8242929
* @library /javax/net/ssl/templates
* @summary Restrict signature algorithms and named groups
* @run main/othervm RestrictNamedGroup x25519
* @run main/othervm RestrictNamedGroup x448
* @run main/othervm RestrictNamedGroup secp256r1
* @run main/othervm RestrictNamedGroup secp384r1
* @run main/othervm RestrictNamedGroup secp521r1
* @run main/othervm RestrictNamedGroup ffdhe2048
* @run main/othervm RestrictNamedGroup ffdhe3072
* @run main/othervm RestrictNamedGroup X448
* @run main/othervm RestrictNamedGroup secP256r1
* @run main/othervm RestrictNamedGroup SECP384r1
* @run main/othervm RestrictNamedGroup SECP521R1
* @run main/othervm RestrictNamedGroup ffDhe2048
* @run main/othervm RestrictNamedGroup FFDHE3072
* @run main/othervm RestrictNamedGroup ffdhe4096
* @run main/othervm RestrictNamedGroup ffdhe6144
* @run main/othervm RestrictNamedGroup ffdhe8192
@ -88,6 +88,7 @@ public class RestrictNamedGroup extends SSLSocketTemplate {
* Run the test case.
*/
public static void main(String[] args) throws Exception {
// Named group is set as per run argument with no change in it's alphabet
Security.setProperty("jdk.tls.disabledAlgorithms", args[0]);
System.setProperty("jdk.tls.namedGroups", args[0]);