iaik.security.cipher
Class SecretKey

java.lang.Object
  |
  +--iaik.security.cipher.SecretKey

public class SecretKey
extends java.lang.Object
implements SecretKey, java.io.Serializable

This class represents a secret key as used with symmetric algorithms. Applications generally shall use a proper KeyGenerator for generating the requested Secret Key.

See Also:
SecretKey, Key, KeyGenerator, Serialized Form

Fields inherited from interface java.security.Key
serialVersionUID
 
Constructor Summary
SecretKey(byte[] key, int off, int len, java.lang.String algName)
          Creates a SecretKey object from given byte sub-array and algorithm name.
SecretKey(byte[] key, java.lang.String algName)
          Creates a SecretKey object from given byte array and algorithm name.
SecretKey(SecretKeySpec keySpec)
           
 
Method Summary
 void destroyCriticalData()
          Destroys the critical data of this object.
 java.lang.String getAlgorithm()
          Returns the name of the key algorithm for this key.
 byte[] getEncoded()
          Returns a copy of the secret key as byte array.
 java.lang.String getFormat()
          Returns the format name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SecretKey

public SecretKey(byte[] key,
                 java.lang.String algName)
Creates a SecretKey object from given byte array and algorithm name.

This constructor is called from inside a KeyGenerator to create a SecretKey. Applications shall use the KeyGenerator.getInstance and generateKey methods for creating a SecretKey object.

Parameters:
key - the key as byte array
algName - the name of the key algorithm
See Also:
KeyGenerator.getInstance(java.lang.String), KeyGenerator.generateKey()

SecretKey

public SecretKey(SecretKeySpec keySpec)

SecretKey

public SecretKey(byte[] key,
                 int off,
                 int len,
                 java.lang.String algName)
Creates a SecretKey object from given byte sub-array and algorithm name. Beginning at off, only len bytes of the given key byte array are used for creating the SecretKey.

This constructor is called from inside a KeyGenerator to create a SecretKey. Applications shall use the KeyGenerator.getInstance and generateKey methods for creating a SecretKey object.

Parameters:
key - the key as byte array
algName - the name of the key algorithm
See Also:
KeyGenerator.getInstance(java.lang.String), KeyGenerator.generateKey()
Method Detail

getEncoded

public byte[] getEncoded()
Returns a copy of the secret key as byte array.
Returns:
a copy of the secret key as byte array

getAlgorithm

public java.lang.String getAlgorithm()
Returns the name of the key algorithm for this key.
Returns:
the key algorithm name

getFormat

public java.lang.String getFormat()
Returns the format name.
Returns:
"RAW"

destroyCriticalData

public void destroyCriticalData()
Destroys the critical data of this object.