/** * Generate a new key from its encoding. Returns a CRT key if possible and a non-CRT key * otherwise. Used by RSAKeyFactory. */ public static RSAPrivateKey newKey(byte[] encoded) throws InvalidKeyException { RSAPrivateCrtKeyImpl key = new RSAPrivateCrtKeyImpl(encoded); if (key.getPublicExponent().signum() == 0) { // public exponent is missing, return a non-CRT key return new RSAPrivateKeyImpl(key.getModulus(), key.getPrivateExponent()); } else { return key; } }