Source:
<code>private InputStream getObject(String bucketName, String objectName, Object key, String keyDecryptionCipherMode) throws InvalidKeyException, InvalidBucketNameException, NoSuchAlgorithmException, InsufficientDataException, NoResponseException, ErrorResponseException, InternalException, IOException, XmlPullParserException, InvalidEncryptionMetadataException, InvalidArgumentException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException, InvalidAlgorithmParameterException { ObjectStat stat = statObject(bucketName, objectName); Key masterKey = null; String dataDecryptionCipherMode = "AES/CBC/PKCS5Padding"; if ((stat.contentKey() == null) && (stat.encryptionIv() == null)) { throw new InvalidEncryptionMetadataException("encryption key or iv not present in object metadata"); } InputStream stream = getObject(bucketName, objectName); if (key instanceof KeyPair) { masterKey = ((KeyPair) key).getPrivate(); } else if (key instanceof SecretKey) { masterKey = (SecretKey) key; } else { <START> throw new InvalidArgumentException("key should be an instance of KeyPair or SecretKey"); <END> } byte[] encryptedDataKey = BaseEncoding.base64().decode(stat.contentKey()); byte[] iv = BaseEncoding.base64().decode(stat.encryptionIv()); byte[] plainDataKey = Crypto.decrypt(encryptedDataKey, masterKey, keyDecryptionCipherMode); SecretKey dataEncryptionKey = new SecretKeySpec(plainDataKey, 0, plainDataKey.length, "AES"); CipherInputStream decryptedStream = Crypto.decryptInputStream(stream, dataEncryptionKey, dataDecryptionCipherMode, iv); return decryptedStream; }</code><technical_language>This InternalException(). This occur</technical_language>

Target:
private InputStream getObject(String bucketName, String objectName, Object key, String keyDecryptionCipherMode) throws InvalidKeyException, InvalidBucketNameException, NoSuchAlgorithmException, InsufficientDataException, NoResponseException, ErrorResponseException, InternalException, IOException, XmlPullParserException, InvalidEncryptionMetadataException, InvalidArgumentException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException, InvalidAlgorithmParameterException { ObjectStat stat = statObject(bucketName, objectName); Key masterKey = null; String dataDecryptionCipherMode = "AES/CBC/PKCS5Padding"; if (key instanceof KeyPair) { masterKey = ((KeyPair) key).getPrivate(); } else if (key instanceof SecretKey) { masterKey = (SecretKey) key; } else { throw new InternalException( "Unknown key object. This should not happen. Please report this issue at <LINK_0>"); } if ((stat.contentKey() == null) && (stat.encryptionIv() == null)) { throw new InvalidEncryptionMetadataException("encryption key or iv not present in object metadata"); } InputStream stream = getObject(bucketName, objectName); byte[] encryptedDataKey = BaseEncoding.base64().decode(stat.contentKey()); byte[] iv = BaseEncoding.base64().decode(stat.encryptionIv()); byte[] plainDataKey = Crypto.decrypt(encryptedDataKey, masterKey, keyDecryptionCipherMode); SecretKey dataEncryptionKey = new SecretKeySpec(plainDataKey, 0, plainDataKey.length, "AES"); CipherInputStream decryptedStream = Crypto.decrypt(stream, dataEncryptionKey, dataDecryptionCipherMode, iv); return decryptedStream; }