use of com.amazonaws.services.s3.internal.RepeatableCipherInputStream in project aws-sdk-android by aws-amplify.
the class EncryptionUtils method decryptObjectUsingInstruction.
/**
* Returns an updated object where the object content input stream contains
* the decrypted contents.
*
* @param object The object whose contents are to be decrypted.
* @param instruction The instruction that will be used to decrypt the
* object data.
* @return The updated object where the object content input stream contains
* the decrypted contents.
*/
public static S3Object decryptObjectUsingInstruction(S3Object object, EncryptionInstruction instruction) {
S3ObjectInputStream objectContent = object.getObjectContent();
InputStream decryptedInputStream = new RepeatableCipherInputStream(objectContent, instruction.getCipherFactory());
object.setObjectContent(new S3ObjectInputStream(decryptedInputStream));
return object;
}
use of com.amazonaws.services.s3.internal.RepeatableCipherInputStream in project aws-sdk-android by aws-amplify.
the class EncryptionUtils method getEncryptedInputStream.
/**
* Retrives the encrypted input stream.
* @param request the UploadPartRequest to encrypt.
* @param cipherFactory the CipherFactory used to encrypt.
* @return the encrypted input stream.
*/
public static ByteRangeCapturingInputStream getEncryptedInputStream(UploadPartRequest request, CipherFactory cipherFactory) {
try {
InputStream originalInputStream = request.getInputStream();
if (request.getFile() != null) {
originalInputStream = new InputSubstream(new RepeatableFileInputStream(request.getFile()), request.getFileOffset(), request.getPartSize(), request.isLastPart());
}
originalInputStream = new RepeatableCipherInputStream(originalInputStream, cipherFactory);
if (!request.isLastPart()) {
// We want to prevent the final padding from being sent on the
// stream...
originalInputStream = new InputSubstream(originalInputStream, 0, request.getPartSize(), false);
}
long partSize = request.getPartSize();
int cipherBlockSize = cipherFactory.createCipher().getBlockSize();
return new ByteRangeCapturingInputStream(originalInputStream, partSize - cipherBlockSize, partSize);
} catch (Exception e) {
throw new AmazonClientException("Unable to create cipher input stream: " + e.getMessage(), e);
}
}
Aggregations