edu.vt.middleware.crypt
Interface EncryptionAlgorithm

All Superinterfaces:
Algorithm
All Known Implementing Classes:
AbstractEncryptionAlgorithm, AES, AsymmetricAlgorithm, Blowfish, CAST5, CAST6, DES, DESede, RC2, RC4, RC5, RC6, Rijndael, RSA, Serpent, Skipjack, SymmetricAlgorithm, Twofish

public interface EncryptionAlgorithm
extends Algorithm

Describes operations common to both symmetric and asymmetric encryption algorithms.

Version:
$Revision: 2745 $
Author:
Middleware Services

Method Summary
 byte[] decrypt(byte[] ciphertext)
          Decrypts the given ciphertext bytes into a byte array of plaintext using the decryption key.
 void decrypt(InputStream in, OutputStream out)
          Decrypts the data in the given ciphertext input stream into plaintext in the output stream.
 byte[] decrypt(String ciphertext, Converter converter)
          Decrypts a string representation of ciphertext bytes into a byte array of plaintext using the decryption key.
 byte[] encrypt(byte[] plaintext)
          Encrypts the given plaintext bytes into a byte array of ciphertext using the encryption key.
 String encrypt(byte[] plaintext, Converter converter)
          Encrypts the given plaintext bytes into a ciphertext string using the conversion strategy provided by the given converter.
 void encrypt(InputStream in, OutputStream out)
          Encrypts the data in the given plaintext input stream into ciphertext in the output stream.
 int getBlockSize()
          Gets the block size of the encryption algorithm cipher in bytes.
 int getCipherMode()
          Gets the cipher mode indicating whether this instance is currently initialized for encryption or decryption.
 String getMode()
          Gets the encryption mode.
 String getPadding()
          Gets the encryption padding method.
 void initDecrypt()
          Initializes this instance for decryption operations.
 void initEncrypt()
          Initializes this instance for encryption operations.
 void setKey(Key k)
          Sets the key used for encryption/decryption.
 
Methods inherited from interface edu.vt.middleware.crypt.Algorithm
getAlgorithm, getRandomData, setRandomProvider
 

Method Detail

getMode

String getMode()
Gets the encryption mode.

Returns:
Name of an encryption mode, e.g. CBC.

getPadding

String getPadding()
Gets the encryption padding method.

Returns:
Name of a padding method, e.g. PKCS5Padding.

setKey

void setKey(Key k)
Sets the key used for encryption/decryption.

Parameters:
k - Public, private, or secret key used for encryption or decryption.

getCipherMode

int getCipherMode()
Gets the cipher mode indicating whether this instance is currently initialized for encryption or decryption.

Returns:
Cipher.ENCRYPT_MODE, Cipher.DECRYPT_MODE, or 0 if the cipher mode has not been initialized by calling either initEncrypt() or initDecrypt().

getBlockSize

int getBlockSize()
Gets the block size of the encryption algorithm cipher in bytes.

Returns:
Block size of cipher in bytes, or 0 if the cipher is not a block cipher.

initEncrypt

void initEncrypt()
                 throws CryptException
Initializes this instance for encryption operations.

Throws:
CryptException - On cryptographic configuration errors.

initDecrypt

void initDecrypt()
                 throws CryptException
Initializes this instance for decryption operations.

Throws:
CryptException - On cryptographic configuration errors.

encrypt

byte[] encrypt(byte[] plaintext)
               throws CryptException
Encrypts the given plaintext bytes into a byte array of ciphertext using the encryption key.

Parameters:
plaintext - Input plaintext bytes.
Returns:
Ciphertext resulting from plaintext encryption.
Throws:
CryptException - On encryption errors.

encrypt

String encrypt(byte[] plaintext,
               Converter converter)
               throws CryptException
Encrypts the given plaintext bytes into a ciphertext string using the conversion strategy provided by the given converter.

Parameters:
plaintext - Input plaintext bytes.
converter - Converter that converts ciphertext output bytes to a string representation.
Returns:
Ciphertext string resulting from plaintext encryption.
Throws:
CryptException - On encryption errors.

encrypt

void encrypt(InputStream in,
             OutputStream out)
             throws CryptException,
                    IOException
Encrypts the data in the given plaintext input stream into ciphertext in the output stream. Use Base64FilterOutputStream or HexFilterOutputStream to produce ciphertext in the output stream in an encoded string repreprestation.

Parameters:
in - Input stream of plaintext.
out - Output stream of ciphertext.
Throws:
CryptException - On encryption errors.
IOException - On stream read/write errors.

decrypt

byte[] decrypt(byte[] ciphertext)
               throws CryptException
Decrypts the given ciphertext bytes into a byte array of plaintext using the decryption key.

Parameters:
ciphertext - Input ciphertext bytes.
Returns:
Plaintext resulting from ciphertext decryption.
Throws:
CryptException - On decryption errors.

decrypt

byte[] decrypt(String ciphertext,
               Converter converter)
               throws CryptException
Decrypts a string representation of ciphertext bytes into a byte array of plaintext using the decryption key.

Parameters:
ciphertext - Input ciphertext bytes.
converter - Converter that converts the ciphertext input string into raw bytes required by the cipher algorithm.
Returns:
Plaintext resulting from ciphertext decryption.
Throws:
CryptException - On decryption errors.

decrypt

void decrypt(InputStream in,
             OutputStream out)
             throws CryptException,
                    IOException
Decrypts the data in the given ciphertext input stream into plaintext in the output stream. Use Base64FilterInputStream or HexFilterInputStream to consume ciphertext in an encoded string representation.

Parameters:
in - Input stream of ciphertext.
out - Output stream of plaintext.
Throws:
CryptException - On decryption errors.
IOException - On stream read/write errors.


Copyright © 2003-2013 Virginia Tech. All Rights Reserved.