Class AbstractEncryptionScheme

java.lang.Object
org.cryptacular.pbe.AbstractEncryptionScheme
All Implemented Interfaces:
EncryptionScheme
Direct Known Subclasses:
OpenSSLEncryptionScheme, PBES1EncryptionScheme, PBES2EncryptionScheme

public abstract class AbstractEncryptionScheme extends Object implements EncryptionScheme
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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    decrypt(byte[] ciphertext)
    Decrypts the given ciphertext into plaintext using the derived key.
    void
    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
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 interface EncryptionScheme
      Parameters:
      plaintext - Input plaintext bytes.
      Returns:
      Ciphertext resulting from plaintext encryption.
    • encrypt

      public void encrypt(InputStream in, OutputStream out) throws IOException
      Description copied from interface: EncryptionScheme
      Encrypts the data in the given plaintext input stream into ciphertext in the output stream. Use EncodingOutputStream to produce ciphertext bytes that encoded as a string data in the output stream.
      Specified by:
      encrypt in interface EncryptionScheme
      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 interface EncryptionScheme
      Parameters:
      ciphertext - Input ciphertext bytes.
      Returns:
      Plaintext resulting from ciphertext decryption.
    • decrypt

      public void decrypt(InputStream in, OutputStream out) throws IOException
      Description copied from interface: EncryptionScheme
      Decrypts ciphertext from an input stream into plaintext in the output stream. Use DecodingInputStream to handle input ciphertext encoded as string data.
      Specified by:
      decrypt in interface EncryptionScheme
      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.