Skip navigation links

Oracle Fusion Middleware Crypto Java API Reference for Oracle Security Developer Tools
11g Release 1 (11.1.1)

E10668-04


oracle.security.crypto.core
Interface Key

All Superinterfaces:
java.lang.Cloneable, java.io.Externalizable, java.security.Key, java.io.Serializable
All Known Subinterfaces:
PrivateKey, PublicKey

public interface Key
extends java.lang.Cloneable, java.io.Externalizable, java.security.Key

An interface for a key, which may be used for encryption or decryption, for generating or verifying signatures, or for generating or verifying MACs.

A key may be a private key, a public key, or a symmetric key.

The code using this API is responsible for erasing any keys it has to when it is done with them to prevent leakage of sensitive key material.

See Also:
PrivateKey, PublicKey, SymmetricKey

Field Summary

 

Fields inherited from interface java.security.Key
serialVersionUID

 

Method Summary
 java.lang.Object clone()
          Performs a deep clone of the Key instance.
 void erase()
          Erases the sensitive key material of a private or symmetric key, making the key un-usable.
 java.lang.String getAlgorithm()
          Returns the algorithm for which this key is primarily used.
 boolean getAllowExport()
          If false, this key's material may not be exported in plaintext; if true, and if the global export flag is true, the key's material may be exported in plaintext.
 int getBitLength()
          Returns the number of bits required to represent this key's defining key material.
 byte[] getEncoded()
          Returns the encoded form of this key.
 java.lang.String getFormat()
          Returns the format of this key's encoded form.

 

Methods inherited from interface java.io.Externalizable
readExternal, writeExternal

 

Method Detail

getAlgorithm

java.lang.String getAlgorithm()
Returns the algorithm for which this key is primarily used.
Specified by:
getAlgorithm in interface java.security.Key

getFormat

java.lang.String getFormat()
Returns the format of this key's encoded form.
Specified by:
getFormat in interface java.security.Key

getEncoded

byte[] getEncoded()
Returns the encoded form of this key.
Specified by:
getEncoded in interface java.security.Key

getBitLength

int getBitLength()
Returns the number of bits required to represent this key's defining key material. For example, in the case of an RSA key, the bit length of the modulus would be returned.

erase

void erase()
Erases the sensitive key material of a private or symmetric key, making the key un-usable. Keys may be erased multiple times with no consequences.

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.


clone

java.lang.Object clone()
Performs a deep clone of the Key instance.
Returns:
A deep clone of the Key instance.

getAllowExport

boolean getAllowExport()
If false, this key's material may not be exported in plaintext; if true, and if the global export flag is true, the key's material may be exported in plaintext.

If plaintext export is not allowed, the key's output methods, such as getEncoded() will throw a KeyExportException.

Returns:
Whether or not this key's material may be exported in plaintext.
Since:
3.0
See Also:
FIPS_140_2.getAllowKeyExport(), Cipher.wrapKey(oracle.security.crypto.core.PrivateKey)

Skip navigation links

Oracle Fusion Middleware Crypto Java API Reference for Oracle Security Developer Tools
11g Release 1 (11.1.1)

E10668-04


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