changeset 51302:11c7290b85ff

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
author valeriep
date Tue, 19 Jun 2018 23:33:31 +0000
parents cc58f1fa0438
children 4935323c3e61
files src/java.base/share/classes/sun/security/rsa/RSAKeyFactory.java
diffstat 1 files changed, 3 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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)) {