From 62bda38593ee8bcf7b62f63cd84cdf795398c182 Mon Sep 17 00:00:00 2001 From: valeriep Date: Tue, 19 Jun 2018 23:33:31 +0000 Subject: [PATCH] 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/share/classes/sun/security/rsa/RSAKeyFactory.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/share/classes/sun/security/rsa/RSAKeyFactory.java b/src/share/classes/sun/security/rsa/RSAKeyFactory.java index 54451256d..021fa9318 100644 --- a/src/share/classes/sun/security/rsa/RSAKeyFactory.java +++ b/src/share/classes/sun/security/rsa/RSAKeyFactory.java @@ -115,6 +115,9 @@ public class RSAKeyFactory extends KeyFactorySpi { * 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)) { -- GitLab