Oracle Security Developer Tools Crypto Java API Reference
10g (10.1.4.0.1)

B28171-01


oracle.security.crypto.core
Class SymmetricKey

java.lang.Object
  extended byoracle.security.crypto.core.SymmetricKey

All Implemented Interfaces:
java.lang.Cloneable, Key

public class SymmetricKey
extends java.lang.Object
implements Key

An encryption/decryption key used by a symmetric cipher.


Constructor Summary
SymmetricKey()
          Creates a new symmetric key.
SymmetricKey(byte[] key)
          Creates a new symmetric key with the given key material.
SymmetricKey(byte[] key, AlgorithmIdentifier algID)
           
SymmetricKey(byte[] key, java.lang.String alg)
          Deprecated.  

 

Method Summary
 java.lang.Object clone()
          Creates a deep copy of this SymmetricKey instance.
 boolean equals(java.lang.Object o)
          A shallow equals method that simply compares the key material of two SymmetricKey instances for equality.
 void erase()
          Erases the key material making the key un-usable.
 void finalize()
          Erases this object prior to being reclaimed by the garbage collector.
 AlgorithmIdentifier getAlgID()
           
 java.lang.String getAlgorithm()
          Deprecated.  
 int getBitLength()
          Returns the number of bits required to represent the byte array wrapped by the SymmetricKey instance.
 byte[] getBytes()
          Returns the encoded key.
 byte[] getEncoded()
          Returns the encoded key.
 java.lang.String getFormat()
          Returns the format used in this key's encoding.
 int keySize()
          Returns the length of the key in bytes.
 void setAlgID(AlgorithmIdentifier algID)
           
 void setBytes(byte[] key)
          Sets the actual bytes of the key.
 java.lang.String toString()
           

 

Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait

 

Constructor Detail

SymmetricKey

public SymmetricKey(byte[] key,
                    java.lang.String alg)
Deprecated.  
Creates a new symmetric key for the specified algorithm with the given key material.

SymmetricKey

public SymmetricKey(byte[] key,
                    AlgorithmIdentifier algID)

SymmetricKey

public SymmetricKey(byte[] key)
Creates a new symmetric key with the given key material.

SymmetricKey

public SymmetricKey()
Creates a new symmetric key. Call setBytes to define the key material.

Method Detail

getAlgorithm

public java.lang.String getAlgorithm()
Deprecated.  
Returns the name of the algorithm for which this key will be used.
Specified by:
getAlgorithm in interface Key

getAlgID

public AlgorithmIdentifier getAlgID()

setAlgID

public void setAlgID(AlgorithmIdentifier algID)

keySize

public int keySize()
Returns the length of the key in bytes.

setBytes

public void setBytes(byte[] key)
Sets the actual bytes of the key.

getBytes

public byte[] getBytes()
Returns the encoded key.

getEncoded

public byte[] getEncoded()
Returns the encoded key.
Specified by:
getEncoded in interface Key

getBitLength

public int getBitLength()
Returns the number of bits required to represent the byte array wrapped by the SymmetricKey instance.

This will always be 8 * the number of bytes in the key array or 0 if the array is null.

Specified by:
getBitLength in interface Key

getFormat

public java.lang.String getFormat()
Returns the format used in this key's encoding.
Specified by:
getFormat in interface Key
Returns:
"RAW"

equals

public boolean equals(java.lang.Object o)
A shallow equals method that simply compares the key material of two SymmetricKey instances for equality.

erase

public void erase()
Erases the key material making the key un-usable.

Keys can be erased multiple times with no consequence.

Specified by:
erase in interface Key

finalize

public void finalize()
Erases this object prior to being reclaimed by the garbage collector.

Note: There is no guarantee of when, if ever, finalize will be invoked by the Java runtime.


toString

public java.lang.String toString()

clone

public java.lang.Object clone()
Creates a deep copy of this SymmetricKey instance.
Specified by:
clone in interface Key

Oracle Security Developer Tools Crypto Java API Reference
10g (10.1.4.0.1)

B28171-01


Copyright © 2005 ,2006 , Oracle. All rights reserved.