public interface StreamingEncryptionScheme extends EncryptionScheme
Example use (decrypts a file that is being read):
scheme.decrypt(new BufferedInputStream(new FileInputStream(...)), decryptionKey)returns an
InputStream where reading supplies exactly the plaintext corresponding
to the ciphertext stored in the file.
The idea is that encryption/decryption can be used as part of a chain of streams.
In the example above: FileInputStream -> BufferedInputStream -> DecryptionInputStream.
Similarly, you can chain OutputStreams such that any bytes written to it are encrypted/decrypted
and then passed to another OutputStream.
Note that the plaintext size and ciphertext size are often NOT the same, hence you cannot
expect the chained streams obtained from a StreamingEncryptionScheme to read/write
exactly the number of bytes from the chained stream that you read from/write to it.
Implementations of this interface should normally be able to do encryption and decryption without loading the whole plaintext/ciphertext into memory.
| Modifier and Type | Method and Description |
|---|---|
java.io.OutputStream |
createDecryptor(java.io.OutputStream out,
DecryptionKey privateKey)
Returns an OutputStream that decrypts any bytes written to it
and writes the resulting plaintext to out.
|
java.io.OutputStream |
createEncryptor(java.io.OutputStream out,
EncryptionKey publicKey)
Returns an OutputStream that encrypts any bytes written to it
and writes the resulting ciphertext to out.
|
java.io.InputStream |
decrypt(java.io.InputStream in,
DecryptionKey privateKey)
Returns an InputStream containing the plaintext obtained
by decrypting the content of in.
|
default void |
decrypt(java.io.InputStream cipherTextIn,
java.io.OutputStream plainTextOut,
DecryptionKey privateKey)
Reads and decrypts a ciphertext from cipherTextIn and writes
the resulting plaintext bytes to plainTextOut.
|
java.io.InputStream |
encrypt(java.io.InputStream in,
EncryptionKey publicKey)
Returns an InputStream containing the ciphertext obtained
by encrypting the content of in.
|
default void |
encrypt(java.io.InputStream plainTextIn,
java.io.OutputStream cipherTextOut,
EncryptionKey publicKey)
Reads and encrypts the bytes from plainTextIn and writes
the ciphertext to cipherTextOut.
|
decrypt, decrypt, encrypt, encrypt, restoreCipherText, restoreDecryptionKey, restoreEncryptionKey, restoreFromRepresentation, restorePlainTextdefault void encrypt(java.io.InputStream plainTextIn,
java.io.OutputStream cipherTextOut,
EncryptionKey publicKey)
throws java.io.IOException
java.io.IOException - if any of the streams throw an exception while reading/writing bytes.default void decrypt(java.io.InputStream cipherTextIn,
java.io.OutputStream plainTextOut,
DecryptionKey privateKey)
throws java.io.IOException
java.io.IOException - if any of the streams throw an exception while reading/writing bytes.java.io.InputStream encrypt(java.io.InputStream in,
EncryptionKey publicKey)
throws java.io.IOException
Note that calling this may already cause some bytes to be read from in.
in - stream containing the bytes to encryptpublicKey - the key to encrypt withjava.io.IOExceptionjava.io.OutputStream createEncryptor(java.io.OutputStream out,
EncryptionKey publicKey)
throws java.io.IOException
Note that calling this may already cause some bytes to be written to out.
out - the stream to write the ciphertext to.publicKey - the key to encrypt with.java.io.IOExceptionjava.io.InputStream decrypt(java.io.InputStream in,
DecryptionKey privateKey)
throws java.io.IOException
Note that calling this may already cause some bytes to be read from in.
in - in stream containing the bytes to decryptprivateKey - the key to decrypt with.java.io.IOExceptionjava.io.OutputStream createDecryptor(java.io.OutputStream out,
DecryptionKey privateKey)
throws java.io.IOException
Note that calling this may already cause some bytes to be written to out.
out - the stream to write the plaintext to.privateKey - the key to decrypt with.java.io.IOException