--- old/src/java.base/share/classes/com/sun/crypto/provider/OAEPParameters.java 2018-05-11 15:03:27.560538200 -0700 +++ new/src/java.base/share/classes/com/sun/crypto/provider/OAEPParameters.java 2018-05-11 15:03:27.027619900 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2018, 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 @@ -137,6 +137,10 @@ mgfSpec = MGF1ParameterSpec.SHA384; } else if (mgfDigestName.equals("SHA-512")) { mgfSpec = MGF1ParameterSpec.SHA512; + } else if (mgfDigestName.equals("SHA-512/224")) { + mgfSpec = MGF1ParameterSpec.SHA512_224; + } else if (mgfDigestName.equals("SHA-512/256")) { + mgfSpec = MGF1ParameterSpec.SHA512_256; } else { throw new IOException( "Unrecognized message digest algorithm"); --- old/src/java.base/share/classes/com/sun/crypto/provider/RSACipher.java 2018-05-11 15:03:29.671165000 -0700 +++ new/src/java.base/share/classes/com/sun/crypto/provider/RSACipher.java 2018-05-11 15:03:29.097624300 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2018, 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 @@ -44,13 +44,15 @@ /** * RSA cipher implementation. Supports RSA en/decryption and signing/verifying - * using PKCS#1 v1.5 padding and without padding (raw RSA). Note that raw RSA - * is supported mostly for completeness and should only be used in rare cases. + * using both PKCS#1 v1.5 and OAEP (v2.2) paddings and without padding (raw RSA). + * Note that raw RSA is supported mostly for completeness and should only be + * used in rare cases. * * Objects should be instantiated by calling Cipher.getInstance() using the * following algorithm names: - * . "RSA/ECB/PKCS1Padding" (or "RSA") for PKCS#1 padding. The mode (blocktype) - * is selected based on the en/decryption mode and public/private key used + * . "RSA/ECB/PKCS1Padding" (or "RSA") for PKCS#1 v1.5 padding. + * . "RSA/ECB/OAEPwithandMGF1Padding" (or "RSA/ECB/OAEPPadding") for + * PKCS#1 v2.2 padding. * . "RSA/ECB/NoPadding" for rsa RSA. * * We only do one RSA operation per doFinal() call. If the application passes @@ -81,7 +83,7 @@ private static final String PAD_NONE = "NoPadding"; // constant for PKCS#1 v1.5 RSA private static final String PAD_PKCS1 = "PKCS1Padding"; - // constant for PKCS#2 v2.0 OAEP with MGF1 + // constant for PKCS#2 v2.2 OAEP with MGF1 private static final String PAD_OAEP_MGF1 = "OAEP"; // current mode, one of MODE_* above. Set when init() is called --- old/src/java.base/share/classes/com/sun/crypto/provider/SunJCE.java 2018-05-11 15:03:31.844424700 -0700 +++ new/src/java.base/share/classes/com/sun/crypto/provider/SunJCE.java 2018-05-11 15:03:31.257872400 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2018, 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 @@ -132,7 +132,9 @@ + "|OAEPWITHSHA-224ANDMGF1PADDING" + "|OAEPWITHSHA-256ANDMGF1PADDING" + "|OAEPWITHSHA-384ANDMGF1PADDING" - + "|OAEPWITHSHA-512ANDMGF1PADDING"); + + "|OAEPWITHSHA-512ANDMGF1PADDING" + + "|OAEPWITHSHA-512/224ANDMGF1PADDING" + + "|OAEPWITHSHA-512/256ANDMGF1PADDING"); put("Cipher.RSA SupportedKeyClasses", "java.security.interfaces.RSAPublicKey" + "|java.security.interfaces.RSAPrivateKey"); --- old/src/java.base/share/classes/java/security/Signature.java 2018-05-11 15:03:34.014694000 -0700 +++ new/src/java.base/share/classes/java/security/Signature.java 2018-05-11 15:03:33.382513800 -0700 @@ -284,6 +284,7 @@ signatureInfo.put("sun.security.rsa.RSASignature$SHA256withRSA", TRUE); signatureInfo.put("sun.security.rsa.RSASignature$SHA384withRSA", TRUE); signatureInfo.put("sun.security.rsa.RSASignature$SHA512withRSA", TRUE); + signatureInfo.put("sun.security.rsa.RSAPSSSignature", TRUE); signatureInfo.put("com.sun.net.ssl.internal.ssl.RSASignature", TRUE); signatureInfo.put("sun.security.pkcs11.P11Signature", TRUE); } --- old/src/java.base/share/classes/java/security/SignedObject.java 2018-05-11 15:03:36.169008100 -0700 +++ new/src/java.base/share/classes/java/security/SignedObject.java 2018-05-11 15:03:35.632966900 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2018, 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 @@ -26,6 +26,7 @@ package java.security; import java.io.*; +import java.security.spec.AlgorithmParameterSpec; /** *

SignedObject is a class for the purpose of creating authentic @@ -47,7 +48,7 @@ * Signature signingEngine = Signature.getInstance(algorithm, * provider); * SignedObject so = new SignedObject(myobject, signingKey, - * signingEngine); + * signingParams, signingEngine); * } * *

A typical usage for verification is the following (having @@ -56,7 +57,7 @@ *

{@code
  * Signature verificationEngine =
  *     Signature.getInstance(algorithm, provider);
- * if (so.verify(publickey, verificationEngine))
+ * if (so.verify(verificationKey, verificationParams, verificationEngine))
  *     try {
  *         Object myobj = so.getObject();
  *     } catch (java.lang.ClassNotFoundException e) {};
@@ -67,7 +68,9 @@
  * re-initialized inside the constructor and the {@code verify}
  * method. Secondly, for verification to succeed, the specified
  * public key must be the public key corresponding to the private key
- * used to generate the SignedObject.
+ * used to generate the SignedObject. If signing parameters are used,
+ * the same parameters must be specified when calling {@code verify}
+ * method for verification to succeed.
  *
  * 

More importantly, for flexibility reasons, the * constructor and {@code verify} method allow for @@ -132,8 +135,8 @@ /** * Constructs a SignedObject from any Serializable object. - * The given object is signed with the given signing key, using the - * designated signature engine. + * The given object is signed with the given signing key with + * no signature parameters, using the designated signature engine. * * @param object the object to be signed. * @param signingKey the private key for signing. @@ -146,19 +149,64 @@ public SignedObject(Serializable object, PrivateKey signingKey, Signature signingEngine) throws IOException, InvalidKeyException, SignatureException { - // creating a stream pipe-line, from a to b - ByteArrayOutputStream b = new ByteArrayOutputStream(); - ObjectOutput a = new ObjectOutputStream(b); - - // write and flush the object content to byte array - a.writeObject(object); - a.flush(); - a.close(); - this.content = b.toByteArray(); - b.close(); + // creating a stream pipe-line, from a to b + ByteArrayOutputStream b = new ByteArrayOutputStream(); + ObjectOutput a = new ObjectOutputStream(b); + + // write and flush the object content to byte array + a.writeObject(object); + a.flush(); + a.close(); + this.content = b.toByteArray(); + b.close(); - // now sign the encapsulated object - this.sign(signingKey, signingEngine); + // now sign the encapsulated object + try { + this.sign(signingKey, null, signingEngine); + } catch (InvalidAlgorithmParameterException e) { + // should not happen, re-throw just in case + throw new SignatureException(e); + } + } + + /** + * Constructs a SignedObject from any Serializable object. + * The given object is signed with the given signing key and + * signature parameters, using the designated signature engine. + * If the signature algorithm does not use any signature parameters, + * {@code signingParams} should be null. + * + * @param object the object to be signed. + * @param signingKey the private key for signing. + * @param signingParams the signature parameters used for signing, + * may be null. + * @param signingEngine the signature signing engine. + * + * @exception IOException if an error occurs during serialization + * @exception InvalidKeyException if the key is invalid. + * @exception InvalidAlgorithmParameterException if the given signature + * parameters is invalid. + * @exception SignatureException if signing fails. + * @since 11 + */ + public SignedObject(Serializable object, PrivateKey signingKey, + AlgorithmParameterSpec signingParams, + Signature signingEngine) + throws IOException, InvalidKeyException, + InvalidAlgorithmParameterException, SignatureException { + // creating a stream pipe-line, from a to b + ByteArrayOutputStream b = new ByteArrayOutputStream(); + ObjectOutput a = new ObjectOutputStream(b); + + // write and flush the object content to byte array + a.writeObject(object); + a.flush(); + a.close(); + this.content = b.toByteArray(); + b.close(); + + // now sign the encapsulated object + this.sign(signingKey, signingParams, signingEngine); } /** @@ -172,8 +220,7 @@ * de-serialization */ public Object getObject() - throws IOException, ClassNotFoundException - { + throws IOException, ClassNotFoundException { // creating a stream pipe-line, from b to a ByteArrayInputStream b = new ByteArrayInputStream(this.content); ObjectInput a = new ObjectInputStream(b); @@ -206,7 +253,8 @@ /** * Verifies that the signature in this SignedObject is the valid * signature for the object stored inside, with the given - * verification key, using the designated verification engine. + * verification key with no signature parameters, using the designated + * verification engine. * * @param verificationKey the public key for verification. * @param verificationEngine the signature verification engine. @@ -222,9 +270,54 @@ public boolean verify(PublicKey verificationKey, Signature verificationEngine) throws InvalidKeyException, SignatureException { - verificationEngine.initVerify(verificationKey); - verificationEngine.update(this.content.clone()); - return verificationEngine.verify(this.signature.clone()); + try { + return verify(verificationKey, null, verificationEngine); + } catch (InvalidAlgorithmParameterException e) { + // should not happen, re-throw just in case + throw new SignatureException(e); + } + } + + /** + * Verifies that the signature in this SignedObject is the valid + * signature for the object stored inside, with the given + * verification key and signature parameters, using the designated + * verification engine. If the signature algorithm does not use any + * signature parameters, {@code verificationParams} should be null. + * When signature parameters are used in signing, the same parameters + * must be specified when calling {@code verify} method for the + * verification to succeed. + * + * @param verificationKey the public key for verification. + * @param verificationParams the signature parameters for verification. + * @param verificationEngine the signature verification engine. + * + * @exception SignatureException if signature verification failed (an + * exception prevented the signature verification engine from completing + * normally). + * @exception InvalidKeyException if the verification key is invalid. + * @exception InvalidAlgorithmParameterException if the given signature + * parameters is invalid + * @return {@code true} if the signature is valid, {@code false} otherwise + * @since 11 + */ + public boolean verify(PublicKey verificationKey, + AlgorithmParameterSpec verificationParams, + Signature verificationEngine) + throws InvalidKeyException, InvalidAlgorithmParameterException, + SignatureException { + // set parameteres before Signature.initSign/initVerify call, + // so key can be checked when it's set + try { + verificationEngine.setParameter(verificationParams); + } catch (UnsupportedOperationException e) { + // for backward compatibility, only re-throw when + // parameters is not null + if (verificationParams != null) throw e; + } + verificationEngine.initVerify(verificationKey); + verificationEngine.update(this.content.clone()); + return verificationEngine.verify(this.signature.clone()); } /* @@ -232,18 +325,32 @@ * designated signature engine. * * @param signingKey the private key for signing. + * @param signingParams the signature parameters for signing. * @param signingEngine the signature signing engine. * * @exception InvalidKeyException if the key is invalid. + * @exception InvalidAlgorithmParameterException if the given signature + * parameters is invalid * @exception SignatureException if signing fails. */ - private void sign(PrivateKey signingKey, Signature signingEngine) - throws InvalidKeyException, SignatureException { - // initialize the signing engine - signingEngine.initSign(signingKey); - signingEngine.update(this.content.clone()); - this.signature = signingEngine.sign().clone(); - this.thealgorithm = signingEngine.getAlgorithm(); + private void sign(PrivateKey signingKey, + AlgorithmParameterSpec signingParams, + Signature signingEngine) + throws InvalidKeyException, InvalidAlgorithmParameterException, + SignatureException { + // set parameteres before Signature.initSign/initVerify call, + // so key can be checked when it's set + try { + signingEngine.setParameter(signingParams); + } catch (UnsupportedOperationException e) { + // for backward compatibility, only re-throw when + // parameters is not null + if (signingParams != null) throw e; + } + signingEngine.initSign(signingKey); + signingEngine.update(this.content.clone()); + this.signature = signingEngine.sign().clone(); + this.thealgorithm = signingEngine.getAlgorithm(); } /** @@ -252,9 +359,9 @@ */ private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { - java.io.ObjectInputStream.GetField fields = s.readFields(); - content = ((byte[])fields.get("content", null)).clone(); - signature = ((byte[])fields.get("signature", null)).clone(); - thealgorithm = (String)fields.get("thealgorithm", null); + java.io.ObjectInputStream.GetField fields = s.readFields(); + content = ((byte[])fields.get("content", null)).clone(); + signature = ((byte[])fields.get("signature", null)).clone(); + thealgorithm = (String)fields.get("thealgorithm", null); } } --- old/src/java.base/share/classes/java/security/cert/X509CRL.java 2018-05-11 15:03:38.015918600 -0700 +++ new/src/java.base/share/classes/java/security/cert/X509CRL.java 2018-05-11 15:03:37.492655200 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2018, 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,14 +25,9 @@ package java.security.cert; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.security.InvalidKeyException; -import java.security.SignatureException; -import java.security.Principal; -import java.security.Provider; -import java.security.PublicKey; -import java.security.Signature; +import java.security.*; +import java.security.spec.*; + import javax.security.auth.x500.X500Principal; import java.math.BigInteger; @@ -41,6 +36,7 @@ import java.util.Arrays; import sun.security.x509.X509CRLImpl; +import sun.security.util.SignatureUtil; /** *

@@ -246,8 +242,19 @@ Signature sig = (sigProvider == null) ? Signature.getInstance(getSigAlgName()) : Signature.getInstance(getSigAlgName(), sigProvider); + sig.initVerify(key); + // set parameters after Signature.initSign/initVerify call, + // so the deferred provider selections occur when key is set + try { + SignatureUtil.specialSetParameter(sig, getSigAlgParams()); + } catch (ProviderException e) { + throw new CRLException(e.getMessage(), e.getCause()); + } catch (InvalidAlgorithmParameterException e) { + throw new CRLException(e); + } + byte[] tbsCRL = getTBSCertList(); sig.update(tbsCRL, 0, tbsCRL.length); --- old/src/java.base/share/classes/java/security/cert/X509Certificate.java 2018-05-11 15:03:39.920892300 -0700 +++ new/src/java.base/share/classes/java/security/cert/X509Certificate.java 2018-05-11 15:03:39.303451800 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2018, 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,12 +27,14 @@ import java.math.BigInteger; import java.security.*; +import java.security.spec.*; import java.util.Collection; import java.util.Date; import java.util.List; import javax.security.auth.x500.X500Principal; import sun.security.x509.X509CertImpl; +import sun.security.util.SignatureUtil; /** *

@@ -677,8 +679,19 @@ Signature sig = (sigProvider == null) ? Signature.getInstance(getSigAlgName()) : Signature.getInstance(getSigAlgName(), sigProvider); + sig.initVerify(key); + // set parameters after Signature.initSign/initVerify call, + // so the deferred provider selections occur when key is set + try { + SignatureUtil.specialSetParameter(sig, getSigAlgParams()); + } catch (ProviderException e) { + throw new CertificateException(e.getMessage(), e.getCause()); + } catch (InvalidAlgorithmParameterException e) { + throw new CertificateException(e); + } + byte[] tbsCert = getTBSCertificate(); sig.update(tbsCert, 0, tbsCert.length); --- old/src/java.base/share/classes/java/security/interfaces/RSAKey.java 2018-05-11 15:03:42.023669200 -0700 +++ new/src/java.base/share/classes/java/security/interfaces/RSAKey.java 2018-05-11 15:03:41.491392500 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2018, 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 @@ -26,9 +26,12 @@ package java.security.interfaces; import java.math.BigInteger; +import java.security.spec.AlgorithmParameterSpec; /** - * The interface to an RSA public or private key. + * The interface to a public or private key in + * PKCS#1 v2.2 standard, + * such as those for RSA, or RSASSA-PSS algorithms. * * @author Jan Luehe * @@ -46,4 +49,20 @@ * @return the modulus */ public BigInteger getModulus(); + + /** + * Returns the parameters associated with this key. + * The parameters are optional and may be either + * explicitly specified or implicitly created during + * key pair generation. + * + * @implSpec + * The default implementation returns {@code null}. + * + * @return the associated parameters, may be null + * @since 11 + */ + default AlgorithmParameterSpec getParams() { + return null; + } } --- old/src/java.base/share/classes/java/security/interfaces/RSAMultiPrimePrivateCrtKey.java 2018-05-11 15:03:44.080548300 -0700 +++ new/src/java.base/share/classes/java/security/interfaces/RSAMultiPrimePrivateCrtKey.java 2018-05-11 15:03:43.538667100 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2018, 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,8 +30,8 @@ /** * The interface to an RSA multi-prime private key, as defined in the - * PKCS#1 v2.1, using the Chinese Remainder Theorem - * (CRT) information values. + * PKCS#1 v2.2 standard, + * using the Chinese Remainder Theorem (CRT) information values. * * @author Valerie Peng * --- old/src/java.base/share/classes/java/security/interfaces/RSAPrivateCrtKey.java 2018-05-11 15:03:46.123872500 -0700 +++ new/src/java.base/share/classes/java/security/interfaces/RSAPrivateCrtKey.java 2018-05-11 15:03:45.562476700 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2018, 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,7 +28,8 @@ import java.math.BigInteger; /** - * The interface to an RSA private key, as defined in the PKCS#1 standard, + * The interface to an RSA private key, as defined in the + * PKCS#1 v2.2 standard, * using the Chinese Remainder Theorem (CRT) information values. * * @author Jan Luehe --- old/src/java.base/share/classes/java/security/interfaces/package-info.java 2018-05-11 15:03:48.459013900 -0700 +++ new/src/java.base/share/classes/java/security/interfaces/package-info.java 2018-05-11 15:03:47.851310000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2018, 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 @@ -51,7 +51,7 @@ *

Package Specification

* * --- old/src/java.base/share/classes/java/security/spec/MGF1ParameterSpec.java 2018-05-11 15:03:50.635974000 -0700 +++ new/src/java.base/share/classes/java/security/spec/MGF1ParameterSpec.java 2018-05-11 15:03:50.086996300 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2018, 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,23 +29,31 @@ /** * This class specifies the set of parameters used with mask generation - * function MGF1 in OAEP Padding and RSA-PSS signature scheme, as + * function MGF1 in OAEP Padding and RSASSA-PSS signature scheme, as * defined in the - * PKCS #1 v2.1 - * standard. + * PKCS#1 v2.2 standard. * *

Its ASN.1 definition in PKCS#1 standard is described below: *

- * MGF1Parameters ::= OAEP-PSSDigestAlgorthms
+ * PKCS1MGFAlgorithms    ALGORITHM-IDENTIFIER ::= {
+ *   { OID id-mgf1 PARAMETERS HashAlgorithm },
+ *   ...  -- Allows for future expansion --
+ * }
  * 
* where *
+ * HashAlgorithm ::= AlgorithmIdentifier {
+ *   {OAEP-PSSDigestAlgorithms}
+ * }
+ *
  * OAEP-PSSDigestAlgorithms    ALGORITHM-IDENTIFIER ::= {
- *   { OID id-sha1 PARAMETERS NULL   }|
- *   { OID id-sha224 PARAMETERS NULL   }|
- *   { OID id-sha256 PARAMETERS NULL }|
- *   { OID id-sha384 PARAMETERS NULL }|
- *   { OID id-sha512 PARAMETERS NULL },
+ *   { OID id-sha1       PARAMETERS NULL }|
+ *   { OID id-sha224     PARAMETERS NULL }|
+ *   { OID id-sha256     PARAMETERS NULL }|
+ *   { OID id-sha384     PARAMETERS NULL }|
+ *   { OID id-sha512     PARAMETERS NULL }|
+ *   { OID id-sha512-224 PARAMETERS NULL }|
+ *   { OID id-sha512-256 PARAMETERS NULL },
  *   ...  -- Allows for future expansion --
  * }
  * 
@@ -59,31 +67,47 @@ public class MGF1ParameterSpec implements AlgorithmParameterSpec { /** - * The MGF1ParameterSpec which uses "SHA-1" message digest. + * The MGF1ParameterSpec which uses "SHA-1" message digest */ public static final MGF1ParameterSpec SHA1 = new MGF1ParameterSpec("SHA-1"); + /** - * The MGF1ParameterSpec which uses "SHA-224" message digest. + * The MGF1ParameterSpec which uses "SHA-224" message digest */ public static final MGF1ParameterSpec SHA224 = new MGF1ParameterSpec("SHA-224"); + /** - * The MGF1ParameterSpec which uses "SHA-256" message digest. + * The MGF1ParameterSpec which uses "SHA-256" message digest */ public static final MGF1ParameterSpec SHA256 = new MGF1ParameterSpec("SHA-256"); + /** - * The MGF1ParameterSpec which uses "SHA-384" message digest. + * The MGF1ParameterSpec which uses "SHA-384" message digest */ public static final MGF1ParameterSpec SHA384 = new MGF1ParameterSpec("SHA-384"); + /** - * The MGF1ParameterSpec which uses SHA-512 message digest. + * The MGF1ParameterSpec which uses SHA-512 message digest */ public static final MGF1ParameterSpec SHA512 = new MGF1ParameterSpec("SHA-512"); + /** + * The MGF1ParameterSpec which uses SHA-512/224 message digest + */ + public static final MGF1ParameterSpec SHA512_224 = + new MGF1ParameterSpec("SHA-512/224"); + + /** + * The MGF1ParameterSpec which uses SHA-512/256 message digest + */ + public static final MGF1ParameterSpec SHA512_256 = + new MGF1ParameterSpec("SHA-512/256"); + private String mdName; /** --- old/src/java.base/share/classes/java/security/spec/PSSParameterSpec.java 2018-05-11 15:03:52.661378700 -0700 +++ new/src/java.base/share/classes/java/security/spec/PSSParameterSpec.java 2018-05-11 15:03:52.096538400 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2018, 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,37 +25,43 @@ package java.security.spec; -import java.math.BigInteger; +import java.util.Objects; import java.security.spec.MGF1ParameterSpec; /** - * This class specifies a parameter spec for RSA-PSS signature scheme, + * This class specifies a parameter spec for RSASSA-PSS signature scheme, * as defined in the - * PKCS#1 v2.1 - * standard. + * PKCS#1 v2.2 standard. * *

Its ASN.1 definition in PKCS#1 standard is described below: *

  * RSASSA-PSS-params ::= SEQUENCE {
- *   hashAlgorithm      [0] OAEP-PSSDigestAlgorithms  DEFAULT sha1,
- *   maskGenAlgorithm   [1] PKCS1MGFAlgorithms  DEFAULT mgf1SHA1,
- *   saltLength         [2] INTEGER  DEFAULT 20,
- *   trailerField       [3] INTEGER  DEFAULT 1
+ *   hashAlgorithm      [0] HashAlgorithm      DEFAULT sha1,
+ *   maskGenAlgorithm   [1] MaskGenAlgorithm   DEFAULT mgf1SHA1,
+ *   saltLength         [2] INTEGER            DEFAULT 20,
+ *   trailerField       [3] TrailerField       DEFAULT trailerFieldBC(1)
  * }
  * 
* where *
+ * HashAlgorithm ::= AlgorithmIdentifier {
+ *   {OAEP-PSSDigestAlgorithms}
+ * }
+ * MaskGenAlgorithm ::= AlgorithmIdentifier { {PKCS1MGFAlgorithms} }
+ * TrailerField ::= INTEGER { trailerFieldBC(1) }
+ *
  * OAEP-PSSDigestAlgorithms    ALGORITHM-IDENTIFIER ::= {
- *   { OID id-sha1 PARAMETERS NULL   }|
- *   { OID id-sha224 PARAMETERS NULL   }|
- *   { OID id-sha256 PARAMETERS NULL }|
- *   { OID id-sha384 PARAMETERS NULL }|
- *   { OID id-sha512 PARAMETERS NULL },
+ *   { OID id-sha1       PARAMETERS NULL }|
+ *   { OID id-sha224     PARAMETERS NULL }|
+ *   { OID id-sha256     PARAMETERS NULL }|
+ *   { OID id-sha384     PARAMETERS NULL }|
+ *   { OID id-sha512     PARAMETERS NULL }|
+ *   { OID id-sha512-224 PARAMETERS NULL }|
+ *   { OID id-sha512-256 PARAMETERS NULL },
  *   ...  -- Allows for future expansion --
  * }
- *
  * PKCS1MGFAlgorithms    ALGORITHM-IDENTIFIER ::= {
- *   { OID id-mgf1 PARAMETERS OAEP-PSSDigestAlgorithms },
+ *   { OID id-mgf1 PARAMETERS HashAlgorithm },
  *   ...  -- Allows for future expansion --
  * }
  * 
@@ -78,55 +84,60 @@ public class PSSParameterSpec implements AlgorithmParameterSpec { - private String mdName = "SHA-1"; - private String mgfName = "MGF1"; - private AlgorithmParameterSpec mgfSpec = MGF1ParameterSpec.SHA1; - private int saltLen = 20; - private int trailerField = 1; + private final String mdName; + + private final String mgfName; + + private final AlgorithmParameterSpec mgfSpec; + + private final int saltLen; + + private final int trailerField; /** - * The PSS parameter set with all default values. - * @since 1.5 + * The {@code TrailerFieldBC} constant as defined in PKCS#1 + * @since 11 */ - public static final PSSParameterSpec DEFAULT = new PSSParameterSpec(); + public static final int TRAILER_FIELD_BC = 1; /** - * Constructs a new {@code PSSParameterSpec} as defined in - * the PKCS #1 standard using the default values. + * The PSS parameter set with all default values + * @since 1.5 */ + public static final PSSParameterSpec DEFAULT = new PSSParameterSpec + ("SHA-1", "MGF1", MGF1ParameterSpec.SHA1, 20, TRAILER_FIELD_BC); + + + // disallowed private PSSParameterSpec() { + throw new RuntimeException("default constructor not allowed"); } + /** * Creates a new {@code PSSParameterSpec} as defined in * the PKCS #1 standard using the specified message digest, * mask generation function, parameters for mask generation * function, salt length, and trailer field values. * - * @param mdName the algorithm name of the hash function. - * @param mgfName the algorithm name of the mask generation - * function. - * @param mgfSpec the parameters for the mask generation - * function. If null is specified, null will be returned by - * getMGFParameters(). - * @param saltLen the length of salt. - * @param trailerField the value of the trailer field. - * @exception NullPointerException if {@code mdName}, - * or {@code mgfName} is null. - * @exception IllegalArgumentException if {@code saltLen} - * or {@code trailerField} is less than 0. + * @param mdName the algorithm name of the hash function + * @param mgfName the algorithm name of the mask generation function + * @param mgfSpec the parameters for the mask generation function + * If null is specified, null will be returned by + * getMGFParameters() + * @param saltLen the length of salt + * @param trailerField the value of the trailer field + * @exception NullPointerException if {@code mdName}, or {@code mgfName} + * is null + * @exception IllegalArgumentException if {@code saltLen} or + * {@code trailerField} is less than 0 * @since 1.5 */ public PSSParameterSpec(String mdName, String mgfName, - AlgorithmParameterSpec mgfSpec, - int saltLen, int trailerField) { - if (mdName == null) { - throw new NullPointerException("digest algorithm is null"); - } - if (mgfName == null) { - throw new NullPointerException("mask generation function " + - "algorithm is null"); - } + AlgorithmParameterSpec mgfSpec, int saltLen, int trailerField) { + Objects.requireNonNull(mdName, "digest algorithm is null"); + Objects.requireNonNull(mgfName, + "mask generation function algorithm is null"); if (saltLen < 0) { throw new IllegalArgumentException("negative saltLen value: " + saltLen); @@ -147,23 +158,19 @@ * using the specified salt length and other default values as * defined in PKCS#1. * - * @param saltLen the length of salt in bits to be used in PKCS#1 - * PSS encoding. + * @param saltLen the length of salt in bytes to be used in PKCS#1 + * PSS encoding * @exception IllegalArgumentException if {@code saltLen} is - * less than 0. + * less than 0 */ public PSSParameterSpec(int saltLen) { - if (saltLen < 0) { - throw new IllegalArgumentException("negative saltLen value: " + - saltLen); - } - this.saltLen = saltLen; + this("SHA-1", "MGF1", MGF1ParameterSpec.SHA1, saltLen, TRAILER_FIELD_BC); } /** * Returns the message digest algorithm name. * - * @return the message digest algorithm name. + * @return the message digest algorithm name * @since 1.5 */ public String getDigestAlgorithm() { @@ -173,7 +180,7 @@ /** * Returns the mask generation function algorithm name. * - * @return the mask generation function algorithm name. + * @return the mask generation function algorithm name * * @since 1.5 */ @@ -184,7 +191,7 @@ /** * Returns the parameters for the mask generation function. * - * @return the parameters for the mask generation function. + * @return the parameters for the mask generation function * @since 1.5 */ public AlgorithmParameterSpec getMGFParameters() { @@ -192,18 +199,18 @@ } /** - * Returns the salt length in bits. + * Returns the salt length in bytes. * - * @return the salt length. + * @return the salt length */ public int getSaltLength() { return saltLen; } /** - * Returns the value for the trailer field, i.e. bc in PKCS#1 v2.1. + * Returns the value for the trailer field. * - * @return the value for the trailer field, i.e. bc in PKCS#1 v2.1. + * @return the value for the trailer field * @since 1.5 */ public int getTrailerField() { --- old/src/java.base/share/classes/java/security/spec/RSAKeyGenParameterSpec.java 2018-05-11 15:03:54.721316300 -0700 +++ new/src/java.base/share/classes/java/security/spec/RSAKeyGenParameterSpec.java 2018-05-11 15:03:54.179867900 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2018, 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 @@ -43,6 +43,7 @@ private int keysize; private BigInteger publicExponent; + private AlgorithmParameterSpec keyParams; /** * The public-exponent value F0 = 3. @@ -55,15 +56,30 @@ public static final BigInteger F4 = BigInteger.valueOf(65537); /** - * Constructs a new {@code RSAParameterSpec} object from the - * given keysize and public-exponent value. + * Constructs a new {@code RSAKeyGenParameterSpec} object from the + * given keysize, public-exponent value, and no key parameters. * * @param keysize the modulus size (specified in number of bits) * @param publicExponent the public exponent */ public RSAKeyGenParameterSpec(int keysize, BigInteger publicExponent) { + this(keysize, publicExponent, null); + } + + /** + * Constructs a new {@code RSAKeyGenParameterSpec} object from the + * given keysize, public-exponent value, and key parameters. + * + * @param keysize the modulus size (specified in number of bits) + * @param publicExponent the public exponent + * @param keyParams the key parameters + * @since 11 + */ + public RSAKeyGenParameterSpec(int keysize, BigInteger publicExponent, + AlgorithmParameterSpec keyParams) { this.keysize = keysize; this.publicExponent = publicExponent; + this.keyParams = keyParams; } /** @@ -83,4 +99,15 @@ public BigInteger getPublicExponent() { return publicExponent; } + + /** + * Returns the parameters to be associated with key. + * + * @return the associated parameters, may be null if + * not present + * @since 11 + */ + public AlgorithmParameterSpec getKeyParams() { + return keyParams; + } } --- old/src/java.base/share/classes/java/security/spec/RSAMultiPrimePrivateCrtKeySpec.java 2018-05-11 15:03:56.755919300 -0700 +++ new/src/java.base/share/classes/java/security/spec/RSAMultiPrimePrivateCrtKeySpec.java 2018-05-11 15:03:56.223543800 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2018, 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 @@ -26,11 +26,13 @@ package java.security.spec; import java.math.BigInteger; +import java.util.Objects; /** * This class specifies an RSA multi-prime private key, as defined in the - * PKCS#1 v2.1, using the Chinese Remainder Theorem (CRT) information - * values for efficiency. + * PKCS#1 v2.2 standard + * using the Chinese Remainder Theorem (CRT) information values + * for efficiency. * * @author Valerie Peng * @@ -57,34 +59,28 @@ private final RSAOtherPrimeInfo[] otherPrimeInfo; /** - * Creates a new {@code RSAMultiPrimePrivateCrtKeySpec} - * given the modulus, publicExponent, privateExponent, - * primeP, primeQ, primeExponentP, primeExponentQ, - * crtCoefficient, and otherPrimeInfo as defined in PKCS#1 v2.1. + * Creates a new {@code RSAMultiPrimePrivateCrtKeySpec}. * *

Note that the contents of {@code otherPrimeInfo} * are copied to protect against subsequent modification when * constructing this object. * - * @param modulus the modulus n. - * @param publicExponent the public exponent e. - * @param privateExponent the private exponent d. - * @param primeP the prime factor p of n. - * @param primeQ the prime factor q of n. - * @param primeExponentP this is d mod (p-1). - * @param primeExponentQ this is d mod (q-1). - * @param crtCoefficient the Chinese Remainder Theorem - * coefficient q-1 mod p. - * @param otherPrimeInfo triplets of the rest of primes, null can be - * specified if there are only two prime factors (p and q). - * @exception NullPointerException if any of the parameters, i.e. - * {@code modulus}, - * {@code publicExponent}, {@code privateExponent}, - * {@code primeP}, {@code primeQ}, - * {@code primeExponentP}, {@code primeExponentQ}, - * {@code crtCoefficient}, is null. + * @param modulus the modulus n + * @param publicExponent the public exponent e + * @param privateExponent the private exponent d + * @param primeP the prime factor p of n + * @param primeQ the prime factor q of q + * @param primeExponentP this is d mod (p-1) + * @param primeExponentQ this is d mod (q-1) + * @param crtCoefficient the Chinese Remainder Theorem + * coefficient q-1 mod p + * @param otherPrimeInfo triplets of the rest of primes, null can be + * specified if there are only two prime factors + * (p and q) + * @exception NullPointerException if any of the specified parameters + * with the exception of {@code otherPrimeInfo} is null * @exception IllegalArgumentException if an empty, i.e. 0-length, - * {@code otherPrimeInfo} is specified. + * {@code otherPrimeInfo} is specified */ public RSAMultiPrimePrivateCrtKeySpec(BigInteger modulus, BigInteger publicExponent, @@ -95,39 +91,65 @@ BigInteger primeExponentQ, BigInteger crtCoefficient, RSAOtherPrimeInfo[] otherPrimeInfo) { - super(modulus, privateExponent); - if (modulus == null) { - throw new NullPointerException("the modulus parameter must be " + - "non-null"); - } - if (publicExponent == null) { - throw new NullPointerException("the publicExponent parameter " + - "must be non-null"); - } - if (privateExponent == null) { - throw new NullPointerException("the privateExponent parameter " + - "must be non-null"); - } - if (primeP == null) { - throw new NullPointerException("the primeP parameter " + - "must be non-null"); - } - if (primeQ == null) { - throw new NullPointerException("the primeQ parameter " + - "must be non-null"); - } - if (primeExponentP == null) { - throw new NullPointerException("the primeExponentP parameter " + - "must be non-null"); - } - if (primeExponentQ == null) { - throw new NullPointerException("the primeExponentQ parameter " + - "must be non-null"); - } - if (crtCoefficient == null) { - throw new NullPointerException("the crtCoefficient parameter " + - "must be non-null"); - } + this(modulus, publicExponent, privateExponent, primeP, primeQ, + primeExponentP, primeExponentQ, crtCoefficient, otherPrimeInfo, + null); + } + + /** + * Creates a new {@code RSAMultiPrimePrivateCrtKeySpec} with additional + * key parameters. + * + *

Note that the contents of {@code otherPrimeInfo} + * are copied to protect against subsequent modification when + * constructing this object. + * + * @param modulus the modulus n + * @param publicExponent the public exponent e + * @param privateExponent the private exponent d + * @param primeP the prime factor p of n + * @param primeQ the prime factor q of n + * @param primeExponentP this is d mod (p-1) + * @param primeExponentQ this is d mod (q-1) + * @param crtCoefficient the Chinese Remainder Theorem coefficient + * q-1 mod p + * @param otherPrimeInfo triplets of the rest of primes, null can be + * specified if there are only two prime factors + * (p and q) + * @param keyParams the parameters associated with key + * @exception NullPointerException if any of the specified parameters + * with the exception of {@code otherPrimeInfo} and {@code keyParams} + * is null + * @exception IllegalArgumentException if an empty, i.e. 0-length, + * {@code otherPrimeInfo} is specified + * @since 11 + */ + public RSAMultiPrimePrivateCrtKeySpec(BigInteger modulus, + BigInteger publicExponent, + BigInteger privateExponent, + BigInteger primeP, + BigInteger primeQ, + BigInteger primeExponentP, + BigInteger primeExponentQ, + BigInteger crtCoefficient, + RSAOtherPrimeInfo[] otherPrimeInfo, + AlgorithmParameterSpec keyParams) { + super(modulus, privateExponent, keyParams); + Objects.requireNonNull(modulus, + "the modulus parameter must be non-null"); + Objects.requireNonNull(publicExponent, + "the publicExponent parameter must be non-null"); + Objects.requireNonNull(privateExponent, + "the privateExponent parameter must be non-null"); + Objects.requireNonNull(primeP, "the primeP parameter must be non-null"); + Objects.requireNonNull(primeQ, "the primeQ parameter must be non-null"); + Objects.requireNonNull(primeExponentP, + "the primeExponentP parameter must be non-null"); + Objects.requireNonNull(primeExponentQ, + "the primeExponentQ parameter must be non-null"); + Objects.requireNonNull(crtCoefficient, + "the crtCoefficient parameter must be non-null"); + this.publicExponent = publicExponent; this.primeP = primeP; this.primeQ = primeQ; @@ -202,8 +224,8 @@ * Returns a copy of the otherPrimeInfo or null if there are * only two prime factors (p and q). * - * @return the otherPrimeInfo. Returns a new array each - * time this method is called. + * @return the otherPrimeInfo. Returns a new array each time this method + * is called. */ public RSAOtherPrimeInfo[] getOtherPrimeInfo() { if (otherPrimeInfo == null) return null; --- old/src/java.base/share/classes/java/security/spec/RSAOtherPrimeInfo.java 2018-05-11 15:03:58.805174200 -0700 +++ new/src/java.base/share/classes/java/security/spec/RSAOtherPrimeInfo.java 2018-05-11 15:03:58.291442000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2018, 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,15 +29,16 @@ /** * This class represents the triplet (prime, exponent, and coefficient) - * inside RSA's OtherPrimeInfo structure, as defined in the PKCS#1 v2.1. + * inside RSA's OtherPrimeInfo structure, as defined in the + * PKCS#1 v2.2 standard. * The ASN.1 syntax of RSA's OtherPrimeInfo is as follows: * *

  * OtherPrimeInfo ::= SEQUENCE {
- *   prime INTEGER,
- *   exponent INTEGER,
- *   coefficient INTEGER
- *   }
+ *   prime        INTEGER,
+ *   exponent     INTEGER,
+ *   coefficient  INTEGER
+ * }
  *
  * 
* --- old/src/java.base/share/classes/java/security/spec/RSAPrivateCrtKeySpec.java 2018-05-11 15:04:01.034854400 -0700 +++ new/src/java.base/share/classes/java/security/spec/RSAPrivateCrtKeySpec.java 2018-05-11 15:04:00.408517900 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2018, 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,9 @@ import java.math.BigInteger; /** - * This class specifies an RSA private key, as defined in the PKCS#1 - * standard, using the Chinese Remainder Theorem (CRT) information values for - * efficiency. + * This class specifies an RSA private key, as defined in the + * PKCS#1 v2.2 standard, + * using the Chinese Remainder Theorem (CRT) information values for efficiency. * * @author Jan Luehe * @since 1.2 @@ -53,13 +53,8 @@ private final BigInteger primeExponentQ; private final BigInteger crtCoefficient; - - /** - * Creates a new {@code RSAPrivateCrtKeySpec} - * given the modulus, publicExponent, privateExponent, - * primeP, primeQ, primeExponentP, primeExponentQ, and - * crtCoefficient as defined in PKCS#1. + * Creates a new {@code RSAPrivateCrtKeySpec}. * * @param modulus the modulus n * @param publicExponent the public exponent e @@ -79,7 +74,36 @@ BigInteger primeExponentP, BigInteger primeExponentQ, BigInteger crtCoefficient) { - super(modulus, privateExponent); + this(modulus, publicExponent, privateExponent, primeP, primeQ, + primeExponentP, primeExponentQ, crtCoefficient, null); + } + + /** + * Creates a new {@code RSAPrivateCrtKeySpec} with additional + * key parameters. + * + * @param modulus the modulus n + * @param publicExponent the public exponent e + * @param privateExponent the private exponent d + * @param primeP the prime factor p of n + * @param primeQ the prime factor q of n + * @param primeExponentP this is d mod (p-1) + * @param primeExponentQ this is d mod (q-1) + * @param crtCoefficient the Chinese Remainder Theorem + * coefficient q-1 mod p + * @param keyParams the parameters associated with key + * @since 11 + */ + public RSAPrivateCrtKeySpec(BigInteger modulus, + BigInteger publicExponent, + BigInteger privateExponent, + BigInteger primeP, + BigInteger primeQ, + BigInteger primeExponentP, + BigInteger primeExponentQ, + BigInteger crtCoefficient, + AlgorithmParameterSpec keyParams) { + super(modulus, privateExponent, keyParams); this.publicExponent = publicExponent; this.primeP = primeP; this.primeQ = primeQ; --- old/src/java.base/share/classes/java/security/spec/RSAPrivateKeySpec.java 2018-05-11 15:04:02.987471000 -0700 +++ new/src/java.base/share/classes/java/security/spec/RSAPrivateKeySpec.java 2018-05-11 15:04:02.416275000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2018, 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 @@ -44,8 +44,9 @@ public class RSAPrivateKeySpec implements KeySpec { - private BigInteger modulus; - private BigInteger privateExponent; + private final BigInteger modulus; + private final BigInteger privateExponent; + private final AlgorithmParameterSpec params; /** * Creates a new RSAPrivateKeySpec. @@ -54,8 +55,22 @@ * @param privateExponent the private exponent */ public RSAPrivateKeySpec(BigInteger modulus, BigInteger privateExponent) { + this(modulus, privateExponent, null); + } + + /** + * Creates a new RSAPrivateKeySpec with additional key parameters. + * + * @param modulus the modulus + * @param privateExponent the private exponent + * @param params the parameters associated with this key, may be null + * @since 11 + */ + public RSAPrivateKeySpec(BigInteger modulus, BigInteger privateExponent, + AlgorithmParameterSpec params) { this.modulus = modulus; this.privateExponent = privateExponent; + this.params = params; } /** @@ -75,4 +90,15 @@ public BigInteger getPrivateExponent() { return this.privateExponent; } + + /** + * Returns the parameters associated with this key, may be null if not + * present. + * + * @return the parameters associated with this key + * @since 11 + */ + public AlgorithmParameterSpec getParams() { + return this.params; + } } --- old/src/java.base/share/classes/java/security/spec/RSAPublicKeySpec.java 2018-05-11 15:04:05.087645300 -0700 +++ new/src/java.base/share/classes/java/security/spec/RSAPublicKeySpec.java 2018-05-11 15:04:04.547247600 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2018, 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 @@ -44,8 +44,9 @@ public class RSAPublicKeySpec implements KeySpec { - private BigInteger modulus; - private BigInteger publicExponent; + private final BigInteger modulus; + private final BigInteger publicExponent; + private final AlgorithmParameterSpec params; /** * Creates a new RSAPublicKeySpec. @@ -54,10 +55,25 @@ * @param publicExponent the public exponent */ public RSAPublicKeySpec(BigInteger modulus, BigInteger publicExponent) { + this(modulus, publicExponent, null); + } + + /** + * Creates a new RSAPublicKeySpec with additional key parameters. + * + * @param modulus the modulus + * @param publicExponent the public exponent + * @param params the parameters associated with this key, may be null + * @since 11 + */ + public RSAPublicKeySpec(BigInteger modulus, BigInteger publicExponent, + AlgorithmParameterSpec params) { this.modulus = modulus; this.publicExponent = publicExponent; + this.params = params; } + /** * Returns the modulus. * @@ -75,4 +91,16 @@ public BigInteger getPublicExponent() { return this.publicExponent; } + + /** + * Returns the parameters associated with this key, may be null if not + * present. + * + * @return the parameters associated with this key + * @since 11 + */ + public AlgorithmParameterSpec getParams() { + return this.params; + } + } --- old/src/java.base/share/classes/java/security/spec/package-info.java 2018-05-11 15:04:07.182521900 -0700 +++ new/src/java.base/share/classes/java/security/spec/package-info.java 2018-05-11 15:04:06.656621400 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2018, 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 @@ -42,7 +42,7 @@ *

Package Specification

* *