edu.vt.middleware.crypt.asymmetric
Class AsymmetricAlgorithm

java.lang.Object
  extended by edu.vt.middleware.crypt.AbstractAlgorithm
      extended by edu.vt.middleware.crypt.AbstractEncryptionAlgorithm
          extended by edu.vt.middleware.crypt.asymmetric.AsymmetricAlgorithm
All Implemented Interfaces:
Algorithm, EncryptionAlgorithm
Direct Known Subclasses:
RSA

public class AsymmetricAlgorithm
extends AbstractEncryptionAlgorithm

Provides asymmetric encryption and decryption operations using a public/private key pair.

Version:
$Revision: 84 $
Author:
Middleware Services

Field Summary
static String MODE
          Mode used for encryption and decryption.
static String PADDING
          Padding used for encryption and decryption.
 
Fields inherited from class edu.vt.middleware.crypt.AbstractEncryptionAlgorithm
cipher, cipherMode, key, mode, padding
 
Fields inherited from class edu.vt.middleware.crypt.AbstractAlgorithm
algorithm, logger, randomByteSize, randomProvider
 
Constructor Summary
protected AsymmetricAlgorithm(String cipherAlgorithm)
          Creates a new instance that uses a cipher of the given algorithm and the default mode and padding.
 
Method Summary
 KeyPair generateKeys()
          Generates a public/private key pair of the default length suitable for the cipher used for encryption on this instance.
 KeyPair generateKeys(int bitLength)
          Generates a public/private key pair of the given length suitable for the cipher used for encryption on this instance.
static KeyPair generateKeys(String algorithm, int bitLength, SecureRandom random)
          Generates a public/private key pair using the given cipher algorithm.
protected  AlgorithmParameterSpec getAlgorithmParameterSpec()
          Gets the algorithm parameter specification for this algorithm.
protected  int getChunkSize()
          Gets the chunk size for buffers using in stream-based encryption and decryption operations.
 int getDefaultKeyLength()
          Gets the default key length for this algorithm.
static AsymmetricAlgorithm newInstance(String algorithm)
          Creates a new instance that uses a cipher of the given name.
 
Methods inherited from class edu.vt.middleware.crypt.AbstractEncryptionAlgorithm
crypt, crypt, decrypt, decrypt, decrypt, encrypt, encrypt, encrypt, getBlockSize, getCipherMode, getMode, getPadding, init, initCipher, initDecrypt, initEncrypt, setKey, toString
 
Methods inherited from class edu.vt.middleware.crypt.AbstractAlgorithm
getAlgorithm, getRandomData, setRandomProvider
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.vt.middleware.crypt.Algorithm
getAlgorithm, getRandomData, setRandomProvider
 

Field Detail

MODE

public static final String MODE
Mode used for encryption and decryption.

See Also:
Constant Field Values

PADDING

public static final String PADDING
Padding used for encryption and decryption.

See Also:
Constant Field Values
Constructor Detail

AsymmetricAlgorithm

protected AsymmetricAlgorithm(String cipherAlgorithm)
Creates a new instance that uses a cipher of the given algorithm and the default mode and padding.

Parameters:
cipherAlgorithm - Cipher algorithm name.
Method Detail

newInstance

public static AsymmetricAlgorithm newInstance(String algorithm)
Creates a new instance that uses a cipher of the given name.

Parameters:
algorithm - Cipher algorithm name.
Returns:
Asymmetric algorithm instance that implements the given cipher algorithm.

generateKeys

public static KeyPair generateKeys(String algorithm,
                                   int bitLength,
                                   SecureRandom random)
                            throws CryptException
Generates a public/private key pair using the given cipher algorithm.

Parameters:
algorithm - Name of a cipher algorithm for which a suitable key pair will be generated.
bitLength - Size of each key in pair in bits.
random - Source of randomness used for key generation.
Returns:
Key pair that may be used for encryption/decryption on a cipher of the given algorithm.
Throws:
CryptException - On key pair generation errors.

generateKeys

public KeyPair generateKeys()
                     throws CryptException
Generates a public/private key pair of the default length suitable for the cipher used for encryption on this instance.

Returns:
Key pair that may be used for encryption/decryption on the cipher used by this instance.
Throws:
CryptException - On key pair generation errors.

generateKeys

public KeyPair generateKeys(int bitLength)
                     throws CryptException
Generates a public/private key pair of the given length suitable for the cipher used for encryption on this instance.

Parameters:
bitLength - Size of each key in pair in bits.
Returns:
Key pair that may be used for encryption/decryption on the cipher used by this instance.
Throws:
CryptException - On key pair generation errors.

getDefaultKeyLength

public int getDefaultKeyLength()
Gets the default key length for this algorithm.

Returns:
Default key length in bits.

getAlgorithmParameterSpec

protected AlgorithmParameterSpec getAlgorithmParameterSpec()
Gets the algorithm parameter specification for this algorithm.

Specified by:
getAlgorithmParameterSpec in class AbstractEncryptionAlgorithm
Returns:
Algorithm parameter specification specific to this algorithm.

getChunkSize

protected int getChunkSize()
Gets the chunk size for buffers using in stream-based encryption and decryption operations.

Specified by:
getChunkSize in class AbstractEncryptionAlgorithm
Returns:
Stream chunk size.


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