public abstract class AbstractEncryptionScheme extends java.lang.Object implements EncryptionScheme
NOTE: Classes derived from this class are not thread safe. In particular, care should be take to prevent multiple threads from performing encryption and/or decryption concurrently.
| Modifier and Type | Field and Description |
|---|---|
private org.bouncycastle.crypto.BufferedBlockCipher |
cipher
Cipher used for encryption and decryption.
|
private org.bouncycastle.crypto.CipherParameters |
parameters
Cipher initialization parameters.
|
| Constructor and Description |
|---|
AbstractEncryptionScheme() |
| Modifier and Type | Method and Description |
|---|---|
byte[] |
decrypt(byte[] ciphertext)
Decrypts the given ciphertext into plaintext using the derived key.
|
void |
decrypt(java.io.InputStream in,
java.io.OutputStream out)
Decrypts ciphertext from an input stream into plaintext in the output stream.
|
byte[] |
encrypt(byte[] plaintext)
Encrypts the given plaintext bytes into a byte array of ciphertext using the derived key.
|
void |
encrypt(java.io.InputStream in,
java.io.OutputStream out)
Encrypts the data in the given plaintext input stream into ciphertext in the output stream.
|
private byte[] |
process(byte[] input)
Run the given data through the initialized underlying cipher and return the result.
|
protected void |
setCipher(org.bouncycastle.crypto.BufferedBlockCipher bufferedBlockCipher)
Sets the block cipher used for encryption/decryption.
|
protected void |
setCipherParameters(org.bouncycastle.crypto.CipherParameters parameters)
Sets block cipher initialization parameters.
|
private org.bouncycastle.crypto.BufferedBlockCipher cipher
private org.bouncycastle.crypto.CipherParameters parameters
public byte[] encrypt(byte[] plaintext)
EncryptionSchemeencrypt in interface EncryptionSchemeplaintext - Input plaintext bytes.public void encrypt(java.io.InputStream in,
java.io.OutputStream out)
throws java.io.IOException
EncryptionSchemeEncodingOutputStream to produce ciphertext bytes that encoded as a string data in the output
stream.encrypt in interface EncryptionSchemein - Input stream of plaintext.out - Output stream of ciphertext.java.io.IOException - On stream read/write errors.public byte[] decrypt(byte[] ciphertext)
EncryptionSchemedecrypt in interface EncryptionSchemeciphertext - Input ciphertext bytes.public void decrypt(java.io.InputStream in,
java.io.OutputStream out)
throws java.io.IOException
EncryptionSchemeDecodingInputStream to handle input ciphertext encoded as string data.decrypt in interface EncryptionSchemein - Input stream of ciphertext.out - Output stream of plaintext.java.io.IOException - On stream read/write errors.protected void setCipher(org.bouncycastle.crypto.BufferedBlockCipher bufferedBlockCipher)
bufferedBlockCipher - Buffered block cipher.protected void setCipherParameters(org.bouncycastle.crypto.CipherParameters parameters)
parameters - Cipher-specific init params.private byte[] process(byte[] input)
input - Input data.