8205720: KeyFactory#getKeySpec and translateKey thorws NullPointerException with Invalid key

Updated SunRsaSign provider to check and throw InvalidKeyException for null key algo/format/encoding

Reviewed-by: xuelei
This commit is contained in:
Valerie Peng 2018-06-30 00:33:05 +00:00
parent 11184615a8
commit ecc5979769
4 changed files with 33 additions and 21 deletions

View file

@ -123,6 +123,10 @@ public final class RSAPrivateCrtKeyImpl
* Construct a key from its encoding. Called from newKey above.
*/
RSAPrivateCrtKeyImpl(byte[] encoded) throws InvalidKeyException {
if (encoded == null || encoded.length == 0) {
throw new InvalidKeyException("Missing key encoding");
}
decode(encoded);
RSAKeyFactory.checkRSAProviderKeyLengths(n.bitLength(), e);
try {