Package org.cryptacular.pbe
Class AbstractEncryptionScheme
java.lang.Object
org.cryptacular.pbe.AbstractEncryptionScheme
- All Implemented Interfaces:
EncryptionScheme
- Direct Known Subclasses:
OpenSSLEncryptionScheme
,PBES1EncryptionScheme
,PBES2EncryptionScheme
Abstract base class for password-based encryption schemes based on salt data and iterated hashing as the basis of the
key derivation function.
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.
- Version:
- $Revision: 2744 $
- Author:
- Middleware Services
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
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.
-
Constructor Details
-
AbstractEncryptionScheme
public AbstractEncryptionScheme()
-
-
Method Details
-
encrypt
public byte[] encrypt(byte[] plaintext) Description copied from interface:EncryptionScheme
Encrypts the given plaintext bytes into a byte array of ciphertext using the derived key.- Specified by:
encrypt
in interfaceEncryptionScheme
- Parameters:
plaintext
- Input plaintext bytes.- Returns:
- Ciphertext resulting from plaintext encryption.
-
encrypt
Description copied from interface:EncryptionScheme
Encrypts the data in the given plaintext input stream into ciphertext in the output stream. UseEncodingOutputStream
to produce ciphertext bytes that encoded as a string data in the output stream.- Specified by:
encrypt
in interfaceEncryptionScheme
- Parameters:
in
- Input stream of plaintext.out
- Output stream of ciphertext.- Throws:
IOException
- On stream read/write errors.
-
decrypt
public byte[] decrypt(byte[] ciphertext) Description copied from interface:EncryptionScheme
Decrypts the given ciphertext into plaintext using the derived key.- Specified by:
decrypt
in interfaceEncryptionScheme
- Parameters:
ciphertext
- Input ciphertext bytes.- Returns:
- Plaintext resulting from ciphertext decryption.
-
decrypt
Description copied from interface:EncryptionScheme
Decrypts ciphertext from an input stream into plaintext in the output stream. UseDecodingInputStream
to handle input ciphertext encoded as string data.- Specified by:
decrypt
in interfaceEncryptionScheme
- Parameters:
in
- Input stream of ciphertext.out
- Output stream of plaintext.- Throws:
IOException
- On stream read/write errors.
-
setCipher
protected void setCipher(org.bouncycastle.crypto.BufferedBlockCipher bufferedBlockCipher) Sets the block cipher used for encryption/decryption.- Parameters:
bufferedBlockCipher
- Buffered block cipher.
-
setCipherParameters
protected void setCipherParameters(org.bouncycastle.crypto.CipherParameters parameters) Sets block cipher initialization parameters.- Parameters:
parameters
- Cipher-specific init params.
-