8204152: SignedObject throws NullPointerException for null keys with an initialized Signature object
authorvaleriep
Tue, 19 Jun 2018 23:33:31 +0000
changeset 50668 11c7290b85ff
parent 50667 cc58f1fa0438
child 50669 4935323c3e61
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
src/java.base/share/classes/sun/security/rsa/RSAKeyFactory.java
--- 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)) {