com.rsa.jsafe
Class JSAFE_PrivateKey

java.lang.Object
  extended bycom.rsa.jsafe.JSAFE_Object
      extended bycom.rsa.jsafe.JSAFE_PrivateKey
All Implemented Interfaces:
Cloneable, JSAFE_Key, Serializable

public abstract class JSAFE_PrivateKey
extends JSAFE_Object
implements JSAFE_Key, Cloneable, Serializable

This class holds private keys for all asymmetric operations and implements the JSAFE_Key class interface.

See Overview of Crypto-J for background and reference material on using and understanding Crypto-J.

Note: Not all Crypto-J transformations have OIDs assigned to them. See Crypto-J Transformations and Their Associated Classes for a list of transformations that have assigned OIDs.

Copyright © RSA Security Inc., 1997-2005. All rights reserved.

See Also:
Serialized Form

Constructor Summary
JSAFE_PrivateKey()

 

 
Method Summary

 void

clearSensitiveData()

This method clears sensitive data from an object.

abstract  Object

clone()

Overrides the default clone method to produce a deep clone.

abstract  boolean

dataEquals(Object obj)

Compares only the data of the objects, ignoring token info, if any.

abstract  String

getAlgorithm()

Returns the standard algorithm name.

 String

getDevice()

Returns the standard name of the device of record.

 String[]

getDeviceList()

Returns a String array that describes all the devices used to execute the transformation.

static JSAFE_PrivateKey

getInstance(byte[] berInfo, int offset, String device)

Builds an object that contains the private key defined in berInfo, beginning at offset.

static JSAFE_PrivateKey

getInstance(String transformation, String device)

Builds an object that holds a private key for the transformation on the given device.

 String

getKeyWrappingFormat(boolean ber)

Returns the name of the format to use when getting the data for key wrapping.

static int

getNextBEROffset(byte[] keyBER, int offset)

Gets the next offset after the algorithm ID.

 
Methods inherited from class com.rsa.jsafe.JSAFE_Object
overwrite, overwrite
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.rsa.jsafe.JSAFE_Key
getKeyData, getKeyData, getMaximumKeyLength, getMinimumKeyLength, getSupportedGetFormats, getSupportedSetFormats, setKeyData, setKeyData
 

Constructor Detail

JSAFE_PrivateKey

public JSAFE_PrivateKey()
Method Detail

getInstance

public static JSAFE_PrivateKey getInstance(byte[] berInfo,
                                           int offset,
                                           String device)
                                    throws JSAFE_UnimplementedException
Builds an object that contains the private key defined in berInfo, beginning at offset. This is the BER encoding of the private-key information. The specified device is used.

Parameters:
berInfo - A byte array containing the BER encoding of the key.
offset - The offset into berInfo where the encoding begins.
device - A list of devices used to build the object.
Returns:
A new JSAFE_PrivateKey object for the specified algorithm.
Throws:
JSAFE_UnimplementedException - If the device or devices cannot perform the designated algorithm, or the toolkit cannot decode the BER encoding.

getNextBEROffset

public static int getNextBEROffset(byte[] keyBER,
                                   int offset)
                            throws JSAFE_UnimplementedException
Gets the next offset after the algorithm ID. Given the berAlgID, the BER encoding of the algorithm ID, beginning at offset, returns the index to the next byte in the array.

Parameters:
keyBER - A byte array containing the BER encoding of a private key.
offset - The offset into keyBER where the encoding begins.
Returns:
The index into keyBER of the byte following the key.
Throws:
JSAFE_UnimplementedException - If the toolkit cannot decode the BER encoding.

getInstance

public static JSAFE_PrivateKey getInstance(String transformation,
                                           String device)
                                    throws JSAFE_UnimplementedException
Builds an object that holds a private key for the transformation on the given device.

Parameters:
transformation - The representation of the desired operation (for example, "RSA").
device - A list of devices used to build the object (for example, "Java", "Native/Java").
Returns:
A new JSAFE_PrivateKey object to use with objects that perform the transformation.
Throws:
JSAFE_UnimplementedException - If the device or devices cannot perform the designated algorithm.

getDevice

public String getDevice()
Returns the standard name of the device of record. The choices are as follows: choice1[/choice2[...[/choicen]]]. The device values are as follows:

Specified by:
getDevice in interface JSAFE_Key
Returns:
The device name.

getDeviceList

public String[] getDeviceList()
Returns a String array that describes all the devices used to execute the transformation. Because a transformation often consists of component algorithms, the implementation can consist of several component objects. A device can perform one or more of the algorithms, but it may let Java or another device perform one or more. For example, because padding is not time-consuming, a device might let the Crypto-J implementation perform padding. Returns the names of the devices used by each component.

Returns the names of the devices used by each component.

Returns:
A String array that describes the device used for a specific component.

getAlgorithm

public abstract String getAlgorithm()
Returns the standard algorithm name.

Specified by:
getAlgorithm in interface JSAFE_Key
Returns:
A String that describes the algorithm.

clone

public abstract Object clone()
                      throws CloneNotSupportedException
Overrides the default clone method to produce a deep clone.

Overrides:
clone in class JSAFE_Object
Returns:
A copy of this object.
Throws:
CloneNotSupportedException - If the object cannot be cloned.

getKeyWrappingFormat

public String getKeyWrappingFormat(boolean ber)
Returns the name of the format to use when getting the data for key wrapping. Use ber to specify whether the data returned should be BER-encoded.

Specified by:
getKeyWrappingFormat in interface JSAFE_Key
Parameters:
ber - A boolean indicating whether the data is wrapped BER-encoded (true) or not (false).
Returns:
A String that is the format.

dataEquals

public abstract boolean dataEquals(Object obj)
Compares only the data of the objects, ignoring token info, if any. If both objects are empty, returns false.

Parameters:
obj - The object to compare with.
Returns:
A boolean. Returns true if the two objects contain the same data; false otherwise.

clearSensitiveData

public void clearSensitiveData()
This method clears sensitive data from an object. Although the finalizer clears the data, there is no guarantee the garbage collector will quickly call the finalizer. Allows a user to clear data as soon as possible. After calling clearSensitiveData(), an Init (not a ReInit) method is called to perform other operations with the object.

Specified by:
clearSensitiveData in interface JSAFE_Key


RSA BSAFE Crypto-J 3.5.2