Async MAC authentication for HTTP range requests. Fixes #38

This commit is contained in:
Sebastian Stenzel
2015-03-09 16:32:59 +01:00
parent 0994e7bb39
commit c1dd902a10
12 changed files with 187 additions and 20 deletions
@@ -75,6 +75,11 @@ public interface Cryptor extends SensitiveDataSwipeListener {
*/
Long decryptedContentLength(SeekableByteChannel encryptedFile) throws IOException;
/**
* @return true, if the stored MAC matches the calculated one.
*/
boolean isAuthentic(SeekableByteChannel encryptedFile) throws IOException;
/**
* @return Number of decrypted bytes. This might not be equal to the encrypted file size due to optional metadata written to it.
* @throws DecryptFailedException If decryption failed
@@ -81,6 +81,11 @@ public class SamplingDecorator implements Cryptor, CryptorIOSampling {
return cryptor.decryptedContentLength(encryptedFile);
}
@Override
public boolean isAuthentic(SeekableByteChannel encryptedFile) throws IOException {
return cryptor.isAuthentic(encryptedFile);
}
@Override
public Long decryptFile(SeekableByteChannel encryptedFile, OutputStream plaintextFile) throws IOException, DecryptFailedException {
final OutputStream countingInputStream = new CountingOutputStream(decryptedBytes, plaintextFile);