8204152: SignedObject throws NullPointerException for null keys with an initialized Signature object

Check for null and throw InvalidKeyException to maintain same behavior

Reviewed-by: xuelei
This commit is contained in:
Valerie Peng 2018-06-19 23:33:31 +00:00
parent 6f462fbc70
commit 8e127e5c26

@ -114,6 +114,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)) {