-
Bug
-
Resolution: Fixed
-
P2
-
11
-
b21
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8206203 | 12 | Valerie Peng | P2 | Resolved | Fixed | b01 |
JDK-8206679 | 11.0.1 | Valerie Peng | P2 | Resolved | Fixed | b01 |
JDK-8239038 | openjdk8u252 | Bradford Wetmore | P2 | Resolved | Fixed | b03 |
JDK-8238790 | 8u251 | Bradford Wetmore | P2 | Closed | Fixed | b04 |
JDK-8246927 | emb-8u261 | Bradford Wetmore | P2 | Resolved | Fixed | team |
JDK-8239733 | emb-8u251 | Bradford Wetmore | P2 | Resolved | Fixed | team |
Specification states that
InvalidKeySpecException if the requested key specification is
inappropriate for the given key, or the given key cannot be processed
(e.g., the given key has an unrecognized algorithm or format).
My understanding is that if I provide an invalid key to this method, I expect InvalidKeyException
but for “RSASSA-PSS” algorithm, the KeyFactory throws “NullPointerException”
Code:
class InvalidKey implements Key{
@Override
public String getAlgorithm() {
return null;
}
@Override
public String getFormat() {
return null;
}
@Override
public byte[] getEncoded() {
return null;
}
}
KeyFactory keyFactory = KeyFactory.getInstance(“RSASSA-PSS”);
keyFactory.getKeySpec(new InvalidKey(),X509EncodedKeySpec.class); //throws NPE instead of InvalidKeyException
=========
Output:
Exception java.lang.NullPointerException
at RSAKeyFactory.checkKeyAlgo (RSAKeyFactory.java:103)
at RSAKeyFactory.engineTranslateKey (RSAKeyFactory.java:212)
at RSAKeyFactory.engineGetKeySpec (RSAKeyFactory.java:399)
• KeyFactory#translateKey(Key):
Specification states that InvalidKeyException if the given key cannot be processed by this key factory.
My understanding is that if I provide an invalid key to this method, I expect InvalidKeyException but for
“RSASSA-PSS” algorithm, the KeyFactory throws “NullPointerException”
Code:
class InvalidKey implements Key{
@Override
public String getAlgorithm() {
return null;
}
@Override
public String getFormat() {
return null;
}
@Override
public byte[] getEncoded() {
return null;
}
}
KeyFactory keyFactory = KeyFactory.getInstance(“RSASSA-PSS”);
keyFactory.translateKey(new InvalidKey()); // Throw NPE instead of InvalidKeyException.
=======
Output:
Exception java.lang.NullPointerException
at RSAKeyFactory.checkKeyAlgo (RSAKeyFactory.java:103)
at RSAKeyFactory.engineTranslateKey (RSAKeyFactory.java:212)
at KeyFactory.translateKey (KeyFactory.java:470)
===================================================
I have checked with other algorithm, it throws "InvalidKeyException"
For e.g.
jshell> KeyFactory keyFactory = KeyFactory.getInstance("XDH");
keyFactory ==> java.security.KeyFactory@77167fb7
jshell> keyFactory.getKeySpec(new InvalidKey(),X509EncodedKeySpec.class)
| Exception java.security.spec.InvalidKeySpecException: Unsupported key type
| at XDHKeyFactory.engineGetKeySpec (XDHKeyFactory.java:226)
| at KeyFactory.getKeySpec (KeyFactory.java:439)
| at (#46:1)
jshell> keyFactory.translateKey(new InvalidKey())
| Exception java.security.InvalidKeyException: Unsupported key type or format
| at XDHKeyFactory.engineTranslateKey (XDHKeyFactory.java:94)
| at KeyFactory.translateKey (KeyFactory.java:470)
| at (#47:1)
- backported by
-
JDK-8206203 KeyFactory#getKeySpec and translateKey throws NullPointerException with Invalid key
- Resolved
-
JDK-8206679 KeyFactory#getKeySpec and translateKey throws NullPointerException with Invalid key
- Resolved
-
JDK-8239038 KeyFactory#getKeySpec and translateKey throws NullPointerException with Invalid key
- Resolved
-
JDK-8239733 KeyFactory#getKeySpec and translateKey throws NullPointerException with Invalid key
- Resolved
-
JDK-8246927 KeyFactory#getKeySpec and translateKey throws NullPointerException with Invalid key
- Resolved
-
JDK-8238790 KeyFactory#getKeySpec and translateKey throws NullPointerException with Invalid key
- Closed
- relates to
-
JDK-8146293 Add support for RSASSA-PSS Signature algorithm
- Resolved