edu.vt.middleware.crypt.symmetric
Class SecretKeyUtils

java.lang.Object
  extended by edu.vt.middleware.crypt.symmetric.SecretKeyUtils

public final class SecretKeyUtils
extends Object

Utility class with methods for handling secret keys.

Version:
$Revision: 2744 $
Author:
Middleware Services

Constructor Summary
SecretKeyUtils()
           
 
Method Summary
static SecretKey generate(String algorithm, int bitLength)
          Generates a new secret key of the prescribed length that is suitable for the given algorithm.
static SecretKey generate(String algorithm, int bitLength, SecureRandom random)
          Generates a new secret key of the prescribed length that is suitable for the given algorithm.
 int length(SecretKey key)
          Gets the key size in bits, which is simply the size of the encoded data in bytes converted to bits.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SecretKeyUtils

public SecretKeyUtils()
Method Detail

length

public int length(SecretKey key)
Gets the key size in bits, which is simply the size of the encoded data in bytes converted to bits.

Parameters:
key - Secret key.
Returns:
Key size in bits.

generate

public static SecretKey generate(String algorithm,
                                 int bitLength)
                          throws CryptException
Generates a new secret key of the prescribed length that is suitable for the given algorithm.

Parameters:
algorithm - Name of cipher algorithm for which a suitable key will be generated.
bitLength - Bit length required in generated key. Valid key lengths are commonly a function of the cipher algorithm.
Returns:
New secret key for use with cipher of given algorithm name.
Throws:
CryptException - if the private key cannot be generated

generate

public static SecretKey generate(String algorithm,
                                 int bitLength,
                                 SecureRandom random)
                          throws CryptException
Generates a new secret key of the prescribed length that is suitable for the given algorithm.

Parameters:
algorithm - Name of cipher algorithm for which a suitable key will be generated.
bitLength - Bit length required in generated key. Valid key lengths are commonly a function of the cipher algorithm.
random - Source of random data for key generation operation.
Returns:
New secret key for use with cipher of given algorithm name.
Throws:
CryptException - if the private key cannot be generated


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