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 taken 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.voiddecrypt(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.voidencrypt(InputStream in, OutputStream out) Encrypts the data in the given plaintext input stream into ciphertext in the output stream.protected voidsetCipher(org.bouncycastle.crypto.BufferedBlockCipher bufferedBlockCipher) Sets the block cipher used for encryption/decryption.protected voidsetCipherParameters(org.bouncycastle.crypto.CipherParameters parameters) Sets block cipher initialization parameters.wrap(boolean encryptionFlag, OutputStream out) Wraps an output stream with one that performs encryption or decryption on the fly.
-
Constructor Details
-
AbstractEncryptionScheme
public AbstractEncryptionScheme()
-
-
Method Details
-
encrypt
public byte[] encrypt(byte[] plaintext) Description copied from interface:EncryptionSchemeEncrypts the given plaintext bytes into a byte array of ciphertext using the derived key.- Specified by:
encryptin interfaceEncryptionScheme- Parameters:
plaintext- Input plaintext bytes.- Returns:
- Ciphertext resulting from plaintext encryption.
-
encrypt
Description copied from interface:EncryptionSchemeEncrypts the data in the given plaintext input stream into ciphertext in the output stream. UseEncodingOutputStreamto produce ciphertext bytes that encoded as a string data in the output stream.- Specified by:
encryptin 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:EncryptionSchemeDecrypts the given ciphertext into plaintext using the derived key.- Specified by:
decryptin interfaceEncryptionScheme- Parameters:
ciphertext- Input ciphertext bytes.- Returns:
- Plaintext resulting from ciphertext decryption.
-
decrypt
Description copied from interface:EncryptionSchemeDecrypts ciphertext from an input stream into plaintext in the output stream. UseDecodingInputStreamto handle input ciphertext encoded as string data.- Specified by:
decryptin interfaceEncryptionScheme- Parameters:
in- Input stream of ciphertext.out- Output stream of plaintext.- Throws:
IOException- On stream read/write errors.
-
wrap
Description copied from interface:EncryptionSchemeWraps an output stream with one that performs encryption or decryption on the fly.- Specified by:
wrapin interfaceEncryptionScheme- Parameters:
encryptionFlag- True to signal encryption, false for decryption.out- Output stream to wrap- Returns:
- Wrapped output steam.
-
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.
-