8226307: Curve names should be case-insensitive
Reviewed-by: igerasim, jnimeh, wetmore
--- a/src/java.base/share/classes/sun/security/util/CurveDB.java Fri Jun 21 12:23:46 2019 +0200
+++ b/src/java.base/share/classes/sun/security/util/CurveDB.java Fri Jun 21 08:38:26 2019 -0400
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2019, 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
@@ -68,7 +68,7 @@
return spec;
}
- return nameMap.get(name);
+ return nameMap.get(name.toLowerCase(Locale.ENGLISH));
}
// Return EC parameters for the specified field size. If there are known
@@ -151,7 +151,8 @@
String[] commonNames = nameSplitPattern.split(name);
for (String commonName : commonNames) {
- if (nameMap.put(commonName.trim(), params) != null) {
+ if (nameMap.put(commonName.trim().toLowerCase(Locale.ENGLISH),
+ params) != null) {
throw new RuntimeException("Duplication name: " + commonName);
}
}
--- a/test/jdk/java/security/KeyAgreement/KeyAgreementTest.java Fri Jun 21 12:23:46 2019 +0200
+++ b/test/jdk/java/security/KeyAgreement/KeyAgreementTest.java Fri Jun 21 08:38:26 2019 -0400
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2019 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,7 +23,7 @@
/*
* @test
- * @bug 4936763 8184359 8205476
+ * @bug 4936763 8184359 8205476 8226307
* @summary KeyAgreement Test with all supported algorithms from JCE.
* Arguments order <KeyExchangeAlgorithm> <KeyGenAlgorithm> <Provider>
* It removes com/sun/crypto/provider/KeyAgreement/DHGenSecretKey.java
@@ -73,7 +73,7 @@
// SEC2 prime curves
"secp112r1", "secp112r2", "secp128r1", "secp128r2", "secp160k1",
"secp160r1", "secp192k1", "secp192r1", "secp224k1", "secp224r1",
- "secp256k1", "secp256r1", "secp384r1", "secp521r1",
+ "secp256k1", "secp256r1", "secp384r1", "secp521r1", "SECP521R1",
// ANSI X9.62 prime curves
"X9.62 prime192v2", "X9.62 prime192v3", "X9.62 prime239v1",
"X9.62 prime239v2", "X9.62 prime239v3",
@@ -87,7 +87,7 @@
"X9.62 c2tnb239v1", "X9.62 c2tnb239v2", "X9.62 c2tnb239v3",
"X9.62 c2tnb359v1", "X9.62 c2tnb431r1"
),
- XDH("X25519", "X448"),
+ XDH("X25519", "X448", "x25519"),
// There is no curve for DiffieHellman
DiffieHellman(new String[]{});