|
Oracle Fusion Middleware Crypto FIPS Java API Reference for Oracle Security Developer Tools 11g Release 1 (11.1.1) E10696-04 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
oracle.security.crypto.core.SymmetricKey
public class SymmetricKey
An encryption/decryption key used by a symmetric cipher.
Field Summary |
---|
Fields inherited from interface javax.crypto.SecretKey |
---|
serialVersionUID |
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) Creates a new symmetric key with the given key material and algorithm identifier. |
Method Summary | |
---|---|
protected void |
assertAllowExport() If either this key's export flag or the global export flag is set to false , this method throws a KeyExportException . |
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 sensitive key material of a private or symmetric key, making the key un-usable. |
void |
finalize() Erases this object prior to being reclaimed by the garbage collector. |
AlgorithmIdentifier |
getAlgID() Returns the algorithm identifier of this symmetric key. |
java.lang.String |
getAlgorithm() Returns a description of this symmetric key. |
boolean |
getAllowExport() Returns false if plaintext export of this SymmetricKey 's key material is not allowed; returns true if plaintext export is allowed. |
int |
getBitLength() Returns the number of bits required to represent the byte array wrapped by the SymmetricKey instance. |
byte[] |
getBytes() Returns a copy of the key bytes. |
byte[] |
getEncoded() Returns a copy of the key bytes. |
java.lang.String |
getFormat() Returns the format used in this key's encoding. |
int |
keySize() Returns the length of the key in bytes. |
void |
readExternal(java.io.ObjectInput is) Reads the input stream and initializes the symmetric key. |
void |
setAlgID(AlgorithmIdentifier algID) Sets the algorithm identifier of this symmetric key. |
void |
setAllowExport(boolean value) Set to false to disallow plaintext export of this SymmetricKey 's key material; set to true to allow plaintext export if the global value in FIPS_140_2 is also set to true . |
void |
setBytes(byte[] keyBytes) Sets the actual bytes of the key. |
java.lang.String |
toString() |
void |
writeExternal(java.io.ObjectOutput os) Writes to the output stream the DER encoding of this object. |
Methods inherited from class java.lang.Object |
---|
getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public SymmetricKey()
setBytes
to define the key material.public SymmetricKey(byte[] key)
key
- The bytes of the symmetric key.public SymmetricKey(byte[] key, AlgorithmIdentifier algID)
key
- The bytes of the symmetric key.algID
- The algorithm identifier for this symmetric key.Method Detail |
---|
public AlgorithmIdentifier getAlgID()
public void setAlgID(AlgorithmIdentifier algID)
public java.lang.String getAlgorithm()
getAlgorithm
in interface java.security.Key
public int keySize()
public void setBytes(byte[] keyBytes)
public byte[] getBytes()
KeyExportException
- If plaintext key export is not allowed for this key or globally.setAllowExport(boolean)
, getAllowExport()
, FIPS_140_2.setAllowKeyExport(boolean)
, FIPS_140_2.getAllowKeyExport()
, Cipher.wrapKey(SymmetricKey key)
public byte[] getEncoded()
getEncoded
in interface java.security.Key
KeyExportException
- If plaintext key export is not allowed for this key or globally.setAllowExport(boolean)
, getAllowExport()
, FIPS_140_2.setAllowKeyExport(boolean)
, FIPS_140_2.getAllowKeyExport()
, Cipher.wrapKey(SymmetricKey key)
public int getBitLength()
This will always be 8 * the number of bytes in the key array or 0 if the array is null.
public java.lang.String getFormat()
getFormat
in interface java.security.Key
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public void erase()
Key
Note: After erase()
has been invoked, no other methods of the Key
object are guaranteed to function correctly. In particular, invoking another method after erase()
may result in a NullPointerException
being thrown.
public void finalize()
Note: There is no guarantee of when, if ever, finalize
will be invoked by the Java runtime.
finalize
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.Object clone()
SymmetricKey
instance.clone
in class java.lang.Object
public void setAllowExport(boolean value)
false
to disallow plaintext export of this SymmetricKey
's key material; set to true
to allow plaintext export if the global value in FIPS_140_2
is also set to true
.
If either this value or the global value is false
, the getBytes()
and getEncoded()
methods will throw a KeyExportException
.
value
- false
to disallow plaintext key material export, true
to allow.FIPS_140_2.setAllowKeyExport(boolean)
, Cipher.wrapKey(SymmetricKey key)
public boolean getAllowExport()
false
if plaintext export of this SymmetricKey
's key material is not allowed; returns true
if plaintext export is allowed.
If either this value or the global value is false
, the getBytes()
and getEncoded()
methods will throw a KeyExportException
.
false
if plaintext key material export is not allowed, true
if allowed.FIPS_140_2.getAllowKeyExport()
, Cipher.wrapKey(SymmetricKey key)
protected void assertAllowExport()
false
, this method throws a KeyExportException
.FIPS_140_2.getAllowKeyExport()
public void writeExternal(java.io.ObjectOutput os) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
os
- The output stream to write the encoding to.java.io.IOException
public void readExternal(java.io.ObjectInput is) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal
in interface java.io.Externalizable
is
- The stream to read from.java.io.IOException
java.lang.ClassNotFoundException
|
Oracle Fusion Middleware Crypto FIPS Java API Reference for Oracle Security Developer Tools 11g Release 1 (11.1.1) E10696-04 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |