8204152: SignedObject throws NullPointerException for null keys with an initialized Signature object
Summary: Check for null and throw InvalidKeyException to maintain same behavior
Reviewed-by: xuelei
--- a/src/java.base/share/classes/sun/security/rsa/RSAKeyFactory.java Tue Jun 19 09:34:41 2018 +0200
+++ b/src/java.base/share/classes/sun/security/rsa/RSAKeyFactory.java Tue Jun 19 23:33:31 2018 +0000
@@ -114,6 +114,9 @@
* Used by RSASignature and RSACipher.
*/
public static RSAKey toRSAKey(Key key) throws InvalidKeyException {
+ if (key == null) {
+ throw new InvalidKeyException("Key must not be null");
+ }
if ((key instanceof RSAPrivateKeyImpl) ||
(key instanceof RSAPrivateCrtKeyImpl) ||
(key instanceof RSAPublicKeyImpl)) {