diff --git a/make/ZipSecurity.gmk b/make/ZipSecurity.gmk index f7435f05efe..4f960cd2fcd 100644 --- a/make/ZipSecurity.gmk +++ b/make/ZipSecurity.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2014, 2023, 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 @@ -41,7 +41,6 @@ $(eval $(call SetupZipArchive,BUILD_SEC_BIN_ZIP, \ modules/java.base/sun/security/internal/interfaces \ modules/java.base/sun/security/internal/spec \ modules/java.base/com/sun/crypto/provider \ - modules/jdk.crypto.ec/sun/security/ec \ modules/jdk.crypto.mscapi/sun/security/mscapi \ modules/jdk.crypto.cryptoki/sun/security/pkcs11 \ modules/jdk.crypto.cryptoki/sun/security/pkcs11/wrapper \ diff --git a/make/conf/docs-modules.conf b/make/conf/docs-modules.conf index 09b26eae9a1..b88f6ff6d90 100644 --- a/make/conf/docs-modules.conf +++ b/make/conf/docs-modules.conf @@ -1,5 +1,5 @@ # -# Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2014, 2023, 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 @@ -36,7 +36,6 @@ DOCS_MODULES= \ jdk.charsets \ jdk.compiler \ jdk.crypto.cryptoki \ - jdk.crypto.ec \ jdk.dynalink \ jdk.editpad \ jdk.hotspot.agent \ diff --git a/make/conf/module-loader-map.conf b/make/conf/module-loader-map.conf index 2c95b8570fd..cc7e7d5a652 100644 --- a/make/conf/module-loader-map.conf +++ b/make/conf/module-loader-map.conf @@ -1,5 +1,5 @@ # -# Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2014, 2023, 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 @@ -77,7 +77,6 @@ PLATFORM_MODULES= \ jdk.accessibility \ jdk.charsets \ jdk.crypto.cryptoki \ - jdk.crypto.ec \ jdk.dynalink \ jdk.httpserver \ jdk.jsobject \ diff --git a/src/java.base/share/classes/module-info.java b/src/java.base/share/classes/module-info.java index ac0ed7bee41..bf3d34abd7a 100644 --- a/src/java.base/share/classes/module-info.java +++ b/src/java.base/share/classes/module-info.java @@ -322,25 +322,21 @@ module java.base { java.sql.rowset; exports sun.security.action to java.desktop, - java.security.jgss, - jdk.crypto.ec; + java.security.jgss; exports sun.security.internal.interfaces to jdk.crypto.cryptoki; exports sun.security.internal.spec to jdk.crypto.cryptoki; exports sun.security.jca to java.smartcardio, - jdk.crypto.ec, jdk.crypto.cryptoki, jdk.naming.dns; exports sun.security.pkcs to - jdk.crypto.ec, jdk.jartool; exports sun.security.provider to java.rmi, java.security.jgss, jdk.crypto.cryptoki, - jdk.crypto.ec, jdk.security.auth; exports sun.security.provider.certpath to java.naming, @@ -359,17 +355,11 @@ module java.base { java.security.sasl, java.smartcardio, java.xml.crypto, - jdk.crypto.ec, jdk.crypto.cryptoki, jdk.jartool, jdk.security.auth, jdk.security.jgss; - exports sun.security.util.math to - jdk.crypto.ec; - exports sun.security.util.math.intpoly to - jdk.crypto.ec; exports sun.security.x509 to - jdk.crypto.ec, jdk.crypto.cryptoki, jdk.jartool; exports sun.security.validator to diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/ECDHKeyAgreement.java b/src/java.base/share/classes/sun/security/ec/ECDHKeyAgreement.java similarity index 100% rename from src/jdk.crypto.ec/share/classes/sun/security/ec/ECDHKeyAgreement.java rename to src/java.base/share/classes/sun/security/ec/ECDHKeyAgreement.java diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/ECDSAOperations.java b/src/java.base/share/classes/sun/security/ec/ECDSAOperations.java similarity index 100% rename from src/jdk.crypto.ec/share/classes/sun/security/ec/ECDSAOperations.java rename to src/java.base/share/classes/sun/security/ec/ECDSAOperations.java diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/ECDSASignature.java b/src/java.base/share/classes/sun/security/ec/ECDSASignature.java similarity index 100% rename from src/jdk.crypto.ec/share/classes/sun/security/ec/ECDSASignature.java rename to src/java.base/share/classes/sun/security/ec/ECDSASignature.java diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/ECKeyFactory.java b/src/java.base/share/classes/sun/security/ec/ECKeyFactory.java similarity index 100% rename from src/jdk.crypto.ec/share/classes/sun/security/ec/ECKeyFactory.java rename to src/java.base/share/classes/sun/security/ec/ECKeyFactory.java diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/ECKeyPairGenerator.java b/src/java.base/share/classes/sun/security/ec/ECKeyPairGenerator.java similarity index 100% rename from src/jdk.crypto.ec/share/classes/sun/security/ec/ECKeyPairGenerator.java rename to src/java.base/share/classes/sun/security/ec/ECKeyPairGenerator.java diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/ECOperations.java b/src/java.base/share/classes/sun/security/ec/ECOperations.java similarity index 100% rename from src/jdk.crypto.ec/share/classes/sun/security/ec/ECOperations.java rename to src/java.base/share/classes/sun/security/ec/ECOperations.java diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/ECPrivateKeyImpl.java b/src/java.base/share/classes/sun/security/ec/ECPrivateKeyImpl.java similarity index 100% rename from src/jdk.crypto.ec/share/classes/sun/security/ec/ECPrivateKeyImpl.java rename to src/java.base/share/classes/sun/security/ec/ECPrivateKeyImpl.java diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/ECPublicKeyImpl.java b/src/java.base/share/classes/sun/security/ec/ECPublicKeyImpl.java similarity index 100% rename from src/jdk.crypto.ec/share/classes/sun/security/ec/ECPublicKeyImpl.java rename to src/java.base/share/classes/sun/security/ec/ECPublicKeyImpl.java diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/ParametersMap.java b/src/java.base/share/classes/sun/security/ec/ParametersMap.java similarity index 100% rename from src/jdk.crypto.ec/share/classes/sun/security/ec/ParametersMap.java rename to src/java.base/share/classes/sun/security/ec/ParametersMap.java diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/SunEC.java b/src/java.base/share/classes/sun/security/ec/SunEC.java similarity index 100% rename from src/jdk.crypto.ec/share/classes/sun/security/ec/SunEC.java rename to src/java.base/share/classes/sun/security/ec/SunEC.java diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/XDHKeyAgreement.java b/src/java.base/share/classes/sun/security/ec/XDHKeyAgreement.java similarity index 100% rename from src/jdk.crypto.ec/share/classes/sun/security/ec/XDHKeyAgreement.java rename to src/java.base/share/classes/sun/security/ec/XDHKeyAgreement.java diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/XDHKeyFactory.java b/src/java.base/share/classes/sun/security/ec/XDHKeyFactory.java similarity index 100% rename from src/jdk.crypto.ec/share/classes/sun/security/ec/XDHKeyFactory.java rename to src/java.base/share/classes/sun/security/ec/XDHKeyFactory.java diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/XDHKeyPairGenerator.java b/src/java.base/share/classes/sun/security/ec/XDHKeyPairGenerator.java similarity index 100% rename from src/jdk.crypto.ec/share/classes/sun/security/ec/XDHKeyPairGenerator.java rename to src/java.base/share/classes/sun/security/ec/XDHKeyPairGenerator.java diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/XDHPrivateKeyImpl.java b/src/java.base/share/classes/sun/security/ec/XDHPrivateKeyImpl.java similarity index 100% rename from src/jdk.crypto.ec/share/classes/sun/security/ec/XDHPrivateKeyImpl.java rename to src/java.base/share/classes/sun/security/ec/XDHPrivateKeyImpl.java diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/XDHPublicKeyImpl.java b/src/java.base/share/classes/sun/security/ec/XDHPublicKeyImpl.java similarity index 100% rename from src/jdk.crypto.ec/share/classes/sun/security/ec/XDHPublicKeyImpl.java rename to src/java.base/share/classes/sun/security/ec/XDHPublicKeyImpl.java diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/XECOperations.java b/src/java.base/share/classes/sun/security/ec/XECOperations.java similarity index 100% rename from src/jdk.crypto.ec/share/classes/sun/security/ec/XECOperations.java rename to src/java.base/share/classes/sun/security/ec/XECOperations.java diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/XECParameters.java b/src/java.base/share/classes/sun/security/ec/XECParameters.java similarity index 100% rename from src/jdk.crypto.ec/share/classes/sun/security/ec/XECParameters.java rename to src/java.base/share/classes/sun/security/ec/XECParameters.java diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/ed/Ed25519Operations.java b/src/java.base/share/classes/sun/security/ec/ed/Ed25519Operations.java similarity index 100% rename from src/jdk.crypto.ec/share/classes/sun/security/ec/ed/Ed25519Operations.java rename to src/java.base/share/classes/sun/security/ec/ed/Ed25519Operations.java diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/ed/Ed448Operations.java b/src/java.base/share/classes/sun/security/ec/ed/Ed448Operations.java similarity index 100% rename from src/jdk.crypto.ec/share/classes/sun/security/ec/ed/Ed448Operations.java rename to src/java.base/share/classes/sun/security/ec/ed/Ed448Operations.java diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/ed/EdDSAAlgorithmParameters.java b/src/java.base/share/classes/sun/security/ec/ed/EdDSAAlgorithmParameters.java similarity index 100% rename from src/jdk.crypto.ec/share/classes/sun/security/ec/ed/EdDSAAlgorithmParameters.java rename to src/java.base/share/classes/sun/security/ec/ed/EdDSAAlgorithmParameters.java diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/ed/EdDSAKeyFactory.java b/src/java.base/share/classes/sun/security/ec/ed/EdDSAKeyFactory.java similarity index 100% rename from src/jdk.crypto.ec/share/classes/sun/security/ec/ed/EdDSAKeyFactory.java rename to src/java.base/share/classes/sun/security/ec/ed/EdDSAKeyFactory.java diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/ed/EdDSAKeyPairGenerator.java b/src/java.base/share/classes/sun/security/ec/ed/EdDSAKeyPairGenerator.java similarity index 100% rename from src/jdk.crypto.ec/share/classes/sun/security/ec/ed/EdDSAKeyPairGenerator.java rename to src/java.base/share/classes/sun/security/ec/ed/EdDSAKeyPairGenerator.java diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/ed/EdDSAOperations.java b/src/java.base/share/classes/sun/security/ec/ed/EdDSAOperations.java similarity index 100% rename from src/jdk.crypto.ec/share/classes/sun/security/ec/ed/EdDSAOperations.java rename to src/java.base/share/classes/sun/security/ec/ed/EdDSAOperations.java diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/ed/EdDSAParameters.java b/src/java.base/share/classes/sun/security/ec/ed/EdDSAParameters.java similarity index 100% rename from src/jdk.crypto.ec/share/classes/sun/security/ec/ed/EdDSAParameters.java rename to src/java.base/share/classes/sun/security/ec/ed/EdDSAParameters.java diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/ed/EdDSAPrivateKeyImpl.java b/src/java.base/share/classes/sun/security/ec/ed/EdDSAPrivateKeyImpl.java similarity index 100% rename from src/jdk.crypto.ec/share/classes/sun/security/ec/ed/EdDSAPrivateKeyImpl.java rename to src/java.base/share/classes/sun/security/ec/ed/EdDSAPrivateKeyImpl.java diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/ed/EdDSAPublicKeyImpl.java b/src/java.base/share/classes/sun/security/ec/ed/EdDSAPublicKeyImpl.java similarity index 100% rename from src/jdk.crypto.ec/share/classes/sun/security/ec/ed/EdDSAPublicKeyImpl.java rename to src/java.base/share/classes/sun/security/ec/ed/EdDSAPublicKeyImpl.java diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/ed/EdDSASignature.java b/src/java.base/share/classes/sun/security/ec/ed/EdDSASignature.java similarity index 100% rename from src/jdk.crypto.ec/share/classes/sun/security/ec/ed/EdDSASignature.java rename to src/java.base/share/classes/sun/security/ec/ed/EdDSASignature.java diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/ed/EdECOperations.java b/src/java.base/share/classes/sun/security/ec/ed/EdECOperations.java similarity index 100% rename from src/jdk.crypto.ec/share/classes/sun/security/ec/ed/EdECOperations.java rename to src/java.base/share/classes/sun/security/ec/ed/EdECOperations.java diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/point/AffinePoint.java b/src/java.base/share/classes/sun/security/ec/point/AffinePoint.java similarity index 100% rename from src/jdk.crypto.ec/share/classes/sun/security/ec/point/AffinePoint.java rename to src/java.base/share/classes/sun/security/ec/point/AffinePoint.java diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/point/ExtendedHomogeneousPoint.java b/src/java.base/share/classes/sun/security/ec/point/ExtendedHomogeneousPoint.java similarity index 100% rename from src/jdk.crypto.ec/share/classes/sun/security/ec/point/ExtendedHomogeneousPoint.java rename to src/java.base/share/classes/sun/security/ec/point/ExtendedHomogeneousPoint.java diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/point/ImmutablePoint.java b/src/java.base/share/classes/sun/security/ec/point/ImmutablePoint.java similarity index 100% rename from src/jdk.crypto.ec/share/classes/sun/security/ec/point/ImmutablePoint.java rename to src/java.base/share/classes/sun/security/ec/point/ImmutablePoint.java diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/point/MutablePoint.java b/src/java.base/share/classes/sun/security/ec/point/MutablePoint.java similarity index 100% rename from src/jdk.crypto.ec/share/classes/sun/security/ec/point/MutablePoint.java rename to src/java.base/share/classes/sun/security/ec/point/MutablePoint.java diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/point/Point.java b/src/java.base/share/classes/sun/security/ec/point/Point.java similarity index 100% rename from src/jdk.crypto.ec/share/classes/sun/security/ec/point/Point.java rename to src/java.base/share/classes/sun/security/ec/point/Point.java diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/point/ProjectivePoint.java b/src/java.base/share/classes/sun/security/ec/point/ProjectivePoint.java similarity index 100% rename from src/jdk.crypto.ec/share/classes/sun/security/ec/point/ProjectivePoint.java rename to src/java.base/share/classes/sun/security/ec/point/ProjectivePoint.java diff --git a/src/java.base/share/classes/sun/security/jca/ProviderConfig.java b/src/java.base/share/classes/sun/security/jca/ProviderConfig.java index 06f5144e9b2..90106674b9d 100644 --- a/src/java.base/share/classes/sun/security/jca/ProviderConfig.java +++ b/src/java.base/share/classes/sun/security/jca/ProviderConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2023, 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 @@ -176,57 +176,60 @@ final class ProviderConfig { return null; } - // Create providers which are in java.base directly - if (provName.equals("SUN") || provName.equals("sun.security.provider.Sun")) { - p = new sun.security.provider.Sun(); - } else if (provName.equals("SunRsaSign") || provName.equals("sun.security.rsa.SunRsaSign")) { - p = new sun.security.rsa.SunRsaSign(); - } else if (provName.equals("SunJCE") || provName.equals("com.sun.crypto.provider.SunJCE")) { - p = new com.sun.crypto.provider.SunJCE(); - } else if (provName.equals("SunJSSE")) { - p = new sun.security.ssl.SunJSSE(); - } else if (provName.equals("Apple") || provName.equals("apple.security.AppleProvider")) { - // need to use reflection since this class only exists on MacOsx - @SuppressWarnings("removal") - var tmp = AccessController.doPrivileged(new PrivilegedAction() { - public Provider run() { - try { - Class c = Class.forName("apple.security.AppleProvider"); - if (Provider.class.isAssignableFrom(c)) { - @SuppressWarnings("deprecation") - Object tmp = c.newInstance(); - return (Provider) tmp; - } else { + p = switch (provName) { + case "SUN", "sun.security.provider.Sun" -> + new sun.security.provider.Sun(); + case "SunRsaSign", "sun.security.rsa.SunRsaSign" -> + new sun.security.rsa.SunRsaSign(); + case "SunJCE", "com.sun.crypto.provider.SunJCE" -> + new com.sun.crypto.provider.SunJCE(); + case "SunJSSE" -> new sun.security.ssl.SunJSSE(); + case "SunEC" -> new sun.security.ec.SunEC(); + case "Apple", "apple.security.AppleProvider" -> { + // Reflection is needed for compile time as the class + // is not available for non-macosx systems + @SuppressWarnings("removal") + var tmp = AccessController.doPrivileged( + new PrivilegedAction() { + public Provider run() { + try { + Class c = Class.forName( + "apple.security.AppleProvider"); + if (Provider.class.isAssignableFrom(c)) { + @SuppressWarnings("deprecation") + Object tmp = c.newInstance(); + return (Provider) tmp; + } + } catch (Exception ex) { + if (debug != null) { + debug.println("Error loading provider Apple"); + ex.printStackTrace(); + } + } return null; } - } catch (Exception ex) { - if (debug != null) { - debug.println("Error loading provider Apple"); - ex.printStackTrace(); - } - return null; + }); + yield tmp; + } + default -> { + if (isLoading) { + // because this method is synchronized, this can only + // happen if there is recursion. + if (debug != null) { + debug.println("Recursion loading provider: " + this); + new Exception("Call trace").printStackTrace(); } + yield null; } - }); - p = tmp; - } else { - if (isLoading) { - // because this method is synchronized, this can only - // happen if there is recursion. - if (debug != null) { - debug.println("Recursion loading provider: " + this); - new Exception("Call trace").printStackTrace(); + try { + isLoading = true; + tries++; + yield doLoadProvider(); + } finally { + isLoading = false; } - return null; } - try { - isLoading = true; - tries++; - p = doLoadProvider(); - } finally { - isLoading = false; - } - } + }; provider = p; } return p; diff --git a/src/java.base/share/classes/sun/security/x509/AlgorithmId.java b/src/java.base/share/classes/sun/security/x509/AlgorithmId.java index a78b50665d5..1f8dbe368bd 100644 --- a/src/java.base/share/classes/sun/security/x509/AlgorithmId.java +++ b/src/java.base/share/classes/sun/security/x509/AlgorithmId.java @@ -544,8 +544,8 @@ public class AlgorithmId implements Serializable, DerEncoder { if (pn != null && mn != null) { return ((mn.equals("java.base") && (pn.equals("SUN") || pn.equals("SunRsaSign") || - pn.equals("SunJCE") || pn.equals("SunJSSE"))) || - (mn.equals("jdk.crypto.ec") && pn.equals("SunEC")) || + pn.equals("SunJCE") || pn.equals("SunJSSE") || + pn.equals("SunEC"))) || (mn.equals("jdk.crypto.mscapi") && pn.equals("SunMSCAPI")) || (mn.equals("jdk.crypto.cryptoki") && pn.startsWith("SunPKCS11"))); diff --git a/src/java.base/share/lib/security/default.policy b/src/java.base/share/lib/security/default.policy index 86d45147709..33774adce08 100644 --- a/src/java.base/share/lib/security/default.policy +++ b/src/java.base/share/lib/security/default.policy @@ -127,15 +127,6 @@ grant codeBase "jrt:/jdk.charsets" { permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.cs"; }; -grant codeBase "jrt:/jdk.crypto.ec" { - permission java.lang.RuntimePermission - "accessClassInPackage.sun.security.*"; - permission java.lang.RuntimePermission "loadLibrary.sunec"; - permission java.security.SecurityPermission "putProviderProperty.SunEC"; - permission java.security.SecurityPermission "clearProviderProperties.SunEC"; - permission java.security.SecurityPermission "removeProviderProperty.SunEC"; -}; - grant codeBase "jrt:/jdk.crypto.cryptoki" { permission java.lang.RuntimePermission "accessClassInPackage.com.sun.crypto.provider"; diff --git a/src/jdk.crypto.cryptoki/share/classes/module-info.java b/src/jdk.crypto.cryptoki/share/classes/module-info.java index 3c90b6dfe6c..57388fb8851 100644 --- a/src/jdk.crypto.cryptoki/share/classes/module-info.java +++ b/src/jdk.crypto.cryptoki/share/classes/module-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, 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 @@ -32,8 +32,5 @@ * @since 9 */ module jdk.crypto.cryptoki { - // Depends on SunEC provider for EC related functionality - requires jdk.crypto.ec; - provides java.security.Provider with sun.security.pkcs11.SunPKCS11; } diff --git a/src/jdk.crypto.ec/share/classes/module-info.java b/src/jdk.crypto.ec/share/classes/module-info.java index 9ba6e6195e3..2e1569c928a 100644 --- a/src/jdk.crypto.ec/share/classes/module-info.java +++ b/src/jdk.crypto.ec/share/classes/module-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, 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 @@ -31,6 +31,6 @@ * @moduleGraph * @since 9 */ +@Deprecated(since="22", forRemoval = true) module jdk.crypto.ec { - provides java.security.Provider with sun.security.ec.SunEC; } diff --git a/test/jdk/java/lang/SecurityManager/CheckSecurityProvider.java b/test/jdk/java/lang/SecurityManager/CheckSecurityProvider.java index 5e0092f8011..468cd4c57d5 100644 --- a/test/jdk/java/lang/SecurityManager/CheckSecurityProvider.java +++ b/test/jdk/java/lang/SecurityManager/CheckSecurityProvider.java @@ -60,8 +60,7 @@ public class CheckSecurityProvider { // NOTE: the ordering must match what's defined inside java.security expected.add("sun.security.provider.Sun"); expected.add("sun.security.rsa.SunRsaSign"); - layer.findModule("jdk.crypto.ec") - .ifPresent(m -> expected.add("sun.security.ec.SunEC")); + expected.add("sun.security.ec.SunEC"); expected.add("sun.security.ssl.SunJSSE"); expected.add("com.sun.crypto.provider.SunJCE"); layer.findModule("jdk.security.jgss") diff --git a/test/jdk/javax/net/ssl/TLS/TEST.properties b/test/jdk/javax/net/ssl/TLS/TEST.properties index 7ff68d5f4b2..5cd72951d1d 100644 --- a/test/jdk/javax/net/ssl/TLS/TEST.properties +++ b/test/jdk/javax/net/ssl/TLS/TEST.properties @@ -6,4 +6,4 @@ modules = \ java.security.jgss/sun.security.krb5.internal.ccache \ java.security.jgss/sun.security.krb5.internal:+open \ java.base/sun.security.util \ - jdk.crypto.ec/sun.security.ec + java.base/sun.security.ec diff --git a/test/jdk/javax/net/ssl/TLS/TestJSSEClientDefaultProtocol.java b/test/jdk/javax/net/ssl/TLS/TestJSSEClientDefaultProtocol.java index ed952234756..9429c9dc02b 100644 --- a/test/jdk/javax/net/ssl/TLS/TestJSSEClientDefaultProtocol.java +++ b/test/jdk/javax/net/ssl/TLS/TestJSSEClientDefaultProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, 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 @@ -25,7 +25,7 @@ * @test * @bug 8049429 8234723 * @modules java.management - * jdk.crypto.ec/sun.security.ec + * java.base/sun.security.ec * @summary Test that all cipher suites work in all versions and all client * authentication types. The way this is setup the server is stateless * and all checking is done on the client side. diff --git a/test/jdk/javax/net/ssl/TLS/TestJSSEClientProtocol.java b/test/jdk/javax/net/ssl/TLS/TestJSSEClientProtocol.java index f2444c4b30f..e9eb0aef103 100644 --- a/test/jdk/javax/net/ssl/TLS/TestJSSEClientProtocol.java +++ b/test/jdk/javax/net/ssl/TLS/TestJSSEClientProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, 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 @@ -25,7 +25,7 @@ * @test * @bug 8049429 8172273 8234723 * @modules java.management - * jdk.crypto.ec/sun.security.ec + * java.base/sun.security.ec * @summary Test that all cipher suites work in all versions and all client * authentication types. The way this is setup the server is stateless * and all checking is done on the client side. @@ -75,4 +75,9 @@ * -DCLIENT_PROTOCOL=TLSv1.3 * -DCIPHER=TLS_AES_256_GCM_SHA384 * TestJSSE + * @run main/othervm --limit-modules java.base + * -DSERVER_PROTOCOL=SSLv3,TLSv1,TLSv1.1,TLSv1.2,TLSv1.3 + * -DCLIENT_PROTOCOL=TLSv1.3 + * -DCIPHER=TLS_AES_256_GCM_SHA384 + * TestJSSE */ diff --git a/test/jdk/javax/net/ssl/TLS/TestJSSENoCommonProtocols.java b/test/jdk/javax/net/ssl/TLS/TestJSSENoCommonProtocols.java index 8473c8ee4f3..eb1a4e9ef8c 100644 --- a/test/jdk/javax/net/ssl/TLS/TestJSSENoCommonProtocols.java +++ b/test/jdk/javax/net/ssl/TLS/TestJSSENoCommonProtocols.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, 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 @@ -25,7 +25,7 @@ * @test * @bug 8049429 * @modules java.management - * jdk.crypto.ec/sun.security.ec + * java.base/sun.security.ec * @summary Test that all cipher suites work in all versions and all client * authentication types. The way this is setup the server is stateless * and all checking is done on the client side. diff --git a/test/jdk/javax/net/ssl/TLS/TestJSSEServerProtocol.java b/test/jdk/javax/net/ssl/TLS/TestJSSEServerProtocol.java index 7cd45756aad..8faed61f49b 100644 --- a/test/jdk/javax/net/ssl/TLS/TestJSSEServerProtocol.java +++ b/test/jdk/javax/net/ssl/TLS/TestJSSEServerProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, 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 @@ -25,7 +25,7 @@ * @test * @bug 8049429 8234723 * @modules java.management - * jdk.crypto.ec/sun.security.ec + * java.base/sun.security.ec * @summary Test that all cipher suites work in all versions and all client * authentication types. The way this is setup the server is stateless * and all checking is done on the client side. @@ -60,4 +60,9 @@ * -DCLIENT_PROTOCOL=TLSv1.3 * -DCIPHER=TLS_AES_256_GCM_SHA384 * TestJSSE javax.net.ssl.SSLHandshakeException + * @run main/othervm --limit-modules java.base + * -DSERVER_PROTOCOL=TLSv1.2 + * -DCLIENT_PROTOCOL=TLSv1.3 + * -DCIPHER=TLS_AES_256_GCM_SHA384 + * TestJSSE javax.net.ssl.SSLHandshakeException */ diff --git a/test/jdk/sun/security/ec/ecModuleCheck.java b/test/jdk/sun/security/ec/ecModuleCheck.java new file mode 100644 index 00000000000..4c8ce628970 --- /dev/null +++ b/test/jdk/sun/security/ec/ecModuleCheck.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2023, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.lang.module.ModuleFinder; +import static jdk.test.lib.Asserts.*; + +/* + * @test + * @bug 8308398 + * @library /test/lib + * @summary Verify jdk.crypto.ec empty module + * @run main ecModuleCheck + */ + +/* This test verifies jdk.crypto.ec is in the image, but not resolvable. + */ +public class ecModuleCheck { + public static void main(String[] args) throws Exception { + // True if module is found in the image. + assertTrue(ModuleFinder.ofSystem().find("jdk.crypto.ec").isPresent(), + "jdk.crypto.ec was not found in image."); + // Since the module empty, isPresent() should be false. + assertFalse(ModuleLayer.boot().findModule("jdk.crypto.ec"). + isPresent(), "jdk.crypto.ec shouldn't be resolvable."); + } +} diff --git a/test/jdk/sun/security/ec/ed/TestEdOps.java b/test/jdk/sun/security/ec/ed/TestEdOps.java index 79502be45e0..6ef1446db46 100644 --- a/test/jdk/sun/security/ec/ed/TestEdOps.java +++ b/test/jdk/sun/security/ec/ed/TestEdOps.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, 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 @@ -30,7 +30,7 @@ * java.base/sun.security.util * java.base/sun.security.util.math * java.base/sun.security.util.math.intpoly - * jdk.crypto.ec/sun.security.ec.ed + * java.base/sun.security.ec.ed * @run main TestEdOps */ diff --git a/test/jdk/sun/security/ec/xec/TestXECOps.java b/test/jdk/sun/security/ec/xec/TestXECOps.java index 15f5a813bb2..cdbcf95fc0b 100644 --- a/test/jdk/sun/security/ec/xec/TestXECOps.java +++ b/test/jdk/sun/security/ec/xec/TestXECOps.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2023, 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 @@ -25,7 +25,7 @@ * @test * @bug 8171277 * @summary Test XEC curve operations - * @modules jdk.crypto.ec/sun.security.ec + * @modules java.base/sun.security.ec * @library /test/lib * @build jdk.test.lib.Convert * @run main TestXECOps diff --git a/test/jdk/sun/security/ec/xec/XECIterative.java b/test/jdk/sun/security/ec/xec/XECIterative.java index 0d5d2931145..2550bd1a290 100644 --- a/test/jdk/sun/security/ec/xec/XECIterative.java +++ b/test/jdk/sun/security/ec/xec/XECIterative.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2023, 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,7 +27,7 @@ * @summary XEC curve operations iterative test vectors * @library /test/lib * @build jdk.test.lib.Convert - * @modules jdk.crypto.ec/sun.security.ec + * @modules java.base/sun.security.ec * @run main XECIterative 0 10000 * @run main XECIterative 10000 20000 * @run main XECIterative 20000 30000 diff --git a/test/jdk/sun/security/pkcs11/ec/ReadPKCS12.java b/test/jdk/sun/security/pkcs11/ec/ReadPKCS12.java index 6005d88aec4..d35310488d4 100644 --- a/test/jdk/sun/security/pkcs11/ec/ReadPKCS12.java +++ b/test/jdk/sun/security/pkcs11/ec/ReadPKCS12.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2023, 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 @@ -29,7 +29,7 @@ * @library /test/lib .. * @library ../../../../java/security/testlibrary * @key randomness - * @modules jdk.crypto.cryptoki jdk.crypto.ec/sun.security.ec + * @modules jdk.crypto.cryptoki java.base/sun.security.ec * @run main/othervm ReadPKCS12 * @run main/othervm -Djava.security.manager=allow ReadPKCS12 sm policy */ diff --git a/test/jdk/sun/security/provider/PolicyFile/DefaultPolicy.java b/test/jdk/sun/security/provider/PolicyFile/DefaultPolicy.java index 697db6c86e2..e16cef02657 100644 --- a/test/jdk/sun/security/provider/PolicyFile/DefaultPolicy.java +++ b/test/jdk/sun/security/provider/PolicyFile/DefaultPolicy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, 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 @@ -64,14 +64,14 @@ public class DefaultPolicy { } private static void checkPolicy(Policy p) throws Exception { - // check if jdk.crypto.ec module has been de-privileged + // check if jdk.crypto.cryptoki module has been de-privileged CodeSource cs = - new CodeSource(new URL("jrt:/jdk.crypto.ec"), (CodeSigner[])null); + new CodeSource(new URL("jrt:/jdk.crypto.cryptoki"), (CodeSigner[])null); ProtectionDomain pd = new ProtectionDomain(cs, null, null, null); if (p.implies(pd, new AllPermission())) { throw new Exception("module should not be granted AllPermission"); } - if (!p.implies(pd, new RuntimePermission("loadLibrary.sunec"))) { + if (!p.implies(pd, new RuntimePermission("loadLibrary.j2pkcs11"))) { throw new Exception("module should be granted RuntimePermission"); } } diff --git a/test/jdk/sun/security/tools/keytool/fakegen/DefaultSignatureAlgorithm.java b/test/jdk/sun/security/tools/keytool/fakegen/DefaultSignatureAlgorithm.java index 5f0822440fc..cc6a2df2081 100644 --- a/test/jdk/sun/security/tools/keytool/fakegen/DefaultSignatureAlgorithm.java +++ b/test/jdk/sun/security/tools/keytool/fakegen/DefaultSignatureAlgorithm.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2023, 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 @@ -28,9 +28,11 @@ * @library /test/lib * @build java.base/sun.security.rsa.RSAKeyPairGenerator * java.base/sun.security.provider.DSAKeyPairGenerator - * jdk.crypto.ec/sun.security.ec.ECKeyPairGenerator + * java.base/sun.security.ec.ECKeyPairGenerator * @run main DefaultSignatureAlgorithm - * @modules jdk.crypto.ec + * + * This test uses RSA, DSA, and EC inside this test directory, not the providers + * from the jdk */ import jdk.test.lib.Asserts; @@ -82,10 +84,7 @@ public class DefaultSignatureAlgorithm { throws Exception { String patchArg = "-J--patch-module=java.base=" + System.getProperty("test.classes") - + File.separator + "patches" + File.separator + "java.base" - + " -J--patch-module=jdk.crypto.ec=" - + System.getProperty("test.classes") - + File.separator + "patches" + File.separator + "jdk.crypto.ec"; + + File.separator + "patches" + File.separator + "java.base"; return kt(patchArg + " -genkeypair -alias " + alias + " -dname CN=" + alias + " " + options); } diff --git a/test/jdk/sun/security/tools/keytool/fakegen/jdk.crypto.ec/sun/security/ec/ECKeyPairGenerator.java b/test/jdk/sun/security/tools/keytool/fakegen/java.base/sun/security/ec/ECKeyPairGenerator.java similarity index 100% rename from test/jdk/sun/security/tools/keytool/fakegen/jdk.crypto.ec/sun/security/ec/ECKeyPairGenerator.java rename to test/jdk/sun/security/tools/keytool/fakegen/java.base/sun/security/ec/ECKeyPairGenerator.java diff --git a/test/jdk/tools/jpackage/share/jdk/jpackage/tests/JLinkOptionsTest.java b/test/jdk/tools/jpackage/share/jdk/jpackage/tests/JLinkOptionsTest.java index 5f97df482bf..40e143763fd 100644 --- a/test/jdk/tools/jpackage/share/jdk/jpackage/tests/JLinkOptionsTest.java +++ b/test/jdk/tools/jpackage/share/jdk/jpackage/tests/JLinkOptionsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, 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 @@ -63,7 +63,7 @@ public final class JLinkOptionsTest { "--bind-services", }, // with bind-services should have some services - new String[]{"java.smartcardio", "jdk.crypto.ec"}, + new String[]{"java.smartcardio", "jdk.crypto.cryptoki"}, null, }, // bind-services @@ -80,7 +80,7 @@ public final class JLinkOptionsTest { "--jlink-options", "--bind-services", }, // with bind-services should have some services - new String[]{"java.smartcardio", "jdk.crypto.ec"}, + new String[]{"java.smartcardio", "jdk.crypto.cryptoki"}, null, }, @@ -105,7 +105,7 @@ public final class JLinkOptionsTest { // with bind-services should have some services new String[]{"java.smartcardio"}, // but not limited - new String[]{"jdk.crypto.ec"}, + new String[]{"jdk.crypto.cryptoki"}, }, });