public abstract class AbstractEncryptionScheme extends 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.
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(InputStream in,
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(InputStream in,
OutputStream out)
Encrypts the data in the given plaintext input stream into ciphertext in the output stream.
|
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.
|
OutputStream |
wrap(boolean encryptionFlag,
OutputStream out)
Wraps an output stream with one that performs encryption or decryption on the fly.
|
public byte[] encrypt(byte[] plaintext)
EncryptionScheme
encrypt
in interface EncryptionScheme
plaintext
- Input plaintext bytes.public void encrypt(InputStream in, OutputStream out) throws IOException
EncryptionScheme
EncodingOutputStream
to produce ciphertext bytes that encoded as a string data in the output
stream.encrypt
in interface EncryptionScheme
in
- Input stream of plaintext.out
- Output stream of ciphertext.IOException
- On stream read/write errors.public byte[] decrypt(byte[] ciphertext)
EncryptionScheme
decrypt
in interface EncryptionScheme
ciphertext
- Input ciphertext bytes.public void decrypt(InputStream in, OutputStream out) throws IOException
EncryptionScheme
DecodingInputStream
to handle input ciphertext encoded as string data.decrypt
in interface EncryptionScheme
in
- Input stream of ciphertext.out
- Output stream of plaintext.IOException
- On stream read/write errors.public OutputStream wrap(boolean encryptionFlag, OutputStream out)
EncryptionScheme
wrap
in interface EncryptionScheme
encryptionFlag
- True to signal encryption, false for decryption.out
- Output stream to wrapprotected void setCipher(org.bouncycastle.crypto.BufferedBlockCipher bufferedBlockCipher)
bufferedBlockCipher
- Buffered block cipher.protected void setCipherParameters(org.bouncycastle.crypto.CipherParameters parameters)
parameters
- Cipher-specific init params.Copyright © 2003-2024 Virginia Tech. All Rights Reserved.