Details
-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
None
-
None
Description
The following program
//CASE#4 Fails
int dgLen = MessageDigest.getInstance(DIGEST).getDigestLength();
int saltLength = K_SIZE / 8 - dgLen - 2;
PSSParameterSpec params = new PSSParameterSpec(DIGEST, "MGF1", new MGF1ParameterSpec(DIGEST),
saltLength, PSSParameterSpec.TRAILER_FIELD_BC);
try {
kpg.initialize(new RSAKeyGenParameterSpec(K_SIZE, RSAKeyGenParameterSpec.F4, params));
KeyPair kp3 = kpg.generateKeyPair();
testSerialize(kp3);
} catch (Exception e) {
pass = false;
System.out.println("####### CASE#4 FAILED #########");
e.printStackTrace(System.out);
}
fails with an InvalidKeySpecException that is
java.io.NotSerializableException: java.security.Key: [PRIVATE] [RSASSA-PSS] [PKCS#8]
at java.base/java.security.KeyRep.readResolve(KeyRep.java:185)
at java.base/jdk.internal.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at java.base/java.io.ObjectStreamClass.invokeReadResolve(ObjectStreamClass.java:1291)
at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2200)
at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1685)
at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:499)
at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:457)
at KeySerialization.deserialize(KeySerialization.java:225)
at KeySerialization.deserializedCopy(KeySerialization.java:213)
at KeySerialization.testSerialize(KeySerialization.java:189)
at KeySerialization.test(KeySerialization.java:115)
at KeySerialization.main(KeySerialization.java:95)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127)
at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: java.security.spec.InvalidKeySpecException: java.security.InvalidKeyException: java.security.ProviderException: Unsupported algorithm 1.2.840.113549.1.1.10
at java.base/sun.security.rsa.RSAKeyFactory.engineGeneratePrivate(RSAKeyFactory.java:251)
at java.base/java.security.KeyFactory.generatePrivate(KeyFactory.java:390)
at java.base/java.security.KeyRep.readResolve(KeyRep.java:176)
... 19 more
Caused by: java.security.InvalidKeyException: java.security.ProviderException: Unsupported algorithm 1.2.840.113549.1.1.10
at java.base/sun.security.rsa.RSAPrivateCrtKeyImpl.<init>(RSAPrivateCrtKeyImpl.java:138)
at java.base/sun.security.rsa.RSAPrivateCrtKeyImpl.newKey(RSAPrivateCrtKeyImpl.java:82)
at java.base/sun.security.rsa.RSAKeyFactory.generatePrivate(RSAKeyFactory.java:356)
at java.base/sun.security.rsa.RSAKeyFactory.engineGeneratePrivate(RSAKeyFactory.java:247)
... 21 more
//CASE#4 Fails
int dgLen = MessageDigest.getInstance(DIGEST).getDigestLength();
int saltLength = K_SIZE / 8 - dgLen - 2;
PSSParameterSpec params = new PSSParameterSpec(DIGEST, "MGF1", new MGF1ParameterSpec(DIGEST),
saltLength, PSSParameterSpec.TRAILER_FIELD_BC);
try {
kpg.initialize(new RSAKeyGenParameterSpec(K_SIZE, RSAKeyGenParameterSpec.F4, params));
KeyPair kp3 = kpg.generateKeyPair();
testSerialize(kp3);
} catch (Exception e) {
pass = false;
System.out.println("####### CASE#4 FAILED #########");
e.printStackTrace(System.out);
}
fails with an InvalidKeySpecException that is
java.io.NotSerializableException: java.security.Key: [PRIVATE] [RSASSA-PSS] [PKCS#8]
at java.base/java.security.KeyRep.readResolve(KeyRep.java:185)
at java.base/jdk.internal.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at java.base/java.io.ObjectStreamClass.invokeReadResolve(ObjectStreamClass.java:1291)
at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2200)
at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1685)
at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:499)
at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:457)
at KeySerialization.deserialize(KeySerialization.java:225)
at KeySerialization.deserializedCopy(KeySerialization.java:213)
at KeySerialization.testSerialize(KeySerialization.java:189)
at KeySerialization.test(KeySerialization.java:115)
at KeySerialization.main(KeySerialization.java:95)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127)
at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: java.security.spec.InvalidKeySpecException: java.security.InvalidKeyException: java.security.ProviderException: Unsupported algorithm 1.2.840.113549.1.1.10
at java.base/sun.security.rsa.RSAKeyFactory.engineGeneratePrivate(RSAKeyFactory.java:251)
at java.base/java.security.KeyFactory.generatePrivate(KeyFactory.java:390)
at java.base/java.security.KeyRep.readResolve(KeyRep.java:176)
... 19 more
Caused by: java.security.InvalidKeyException: java.security.ProviderException: Unsupported algorithm 1.2.840.113549.1.1.10
at java.base/sun.security.rsa.RSAPrivateCrtKeyImpl.<init>(RSAPrivateCrtKeyImpl.java:138)
at java.base/sun.security.rsa.RSAPrivateCrtKeyImpl.newKey(RSAPrivateCrtKeyImpl.java:82)
at java.base/sun.security.rsa.RSAKeyFactory.generatePrivate(RSAKeyFactory.java:356)
at java.base/sun.security.rsa.RSAKeyFactory.engineGeneratePrivate(RSAKeyFactory.java:247)
... 21 more
Attachments
Issue Links
- blocks
-
JDK-8242335 Additional Tests for RSASSA-PSS
- Resolved
- duplicates
-
JDK-8242556 Cannot load RSASSA-PSS public key with non-null params from byte array
- Closed
- relates to
-
JDK-8146293 Add support for RSASSA-PSS Signature algorithm
- Resolved