edu.vt.middleware.crypt
Class AbstractAlgorithm

java.lang.Object
  extended by edu.vt.middleware.crypt.AbstractAlgorithm
All Implemented Interfaces:
Algorithm
Direct Known Subclasses:
AbstractEncryptionAlgorithm, AbstractRandomizableAlgorithm, SignatureAlgorithm

public abstract class AbstractAlgorithm
extends Object
implements Algorithm

Abstract cryptographic algorithm that is the basis of digest, encryption, and signature algorithms.

Version:
$Revision: 3 $
Author:
Middleware Services

Field Summary
protected  String algorithm
          Algorithm name.
protected  org.apache.commons.logging.Log logger
          Logger instance.
protected  int randomByteSize
          Number of bytes used for random data needs.
protected  SecureRandom randomProvider
          Provider of secure random data.
 
Constructor Summary
AbstractAlgorithm()
           
 
Method Summary
 String getAlgorithm()
          Gets the algorithm name.
 byte[] getRandomData(int nBytes)
          Gets random bytes from the random provider of this instance in the amount specified.
 void setRandomProvider(SecureRandom random)
          Sets the source of random data for cryptographic operations needing a random data source, such as generating a random salt value.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

protected final org.apache.commons.logging.Log logger
Logger instance.


algorithm

protected String algorithm
Algorithm name.


randomProvider

protected SecureRandom randomProvider
Provider of secure random data.


randomByteSize

protected int randomByteSize
Number of bytes used for random data needs.

Constructor Detail

AbstractAlgorithm

public AbstractAlgorithm()
Method Detail

getAlgorithm

public String getAlgorithm()
Gets the algorithm name.

Specified by:
getAlgorithm in interface Algorithm
Returns:
Algorithm name.

setRandomProvider

public void setRandomProvider(SecureRandom random)
Sets the source of random data for cryptographic operations needing a random data source, such as generating a random salt value.

Specified by:
setRandomProvider in interface Algorithm
Parameters:
random - Provider of cryptographically strong random data.

toString

public String toString()

Overrides:
toString in class Object

getRandomData

public byte[] getRandomData(int nBytes)
Gets random bytes from the random provider of this instance in the amount specified.

Specified by:
getRandomData in interface Algorithm
Parameters:
nBytes - Number of bytes of random data to retrieve.
Returns:
Byte array of random data.


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