|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.rsa.jsafe.JSAFE_Object
com.rsa.jsafe.JSAFE_SecretKey
JSAFE_SecretKey holds and generates secret (symmetric) keys
and implements the JSAFE_Key interface.
See Overview of Crypto-J for background and reference material on using and understanding Crypto-J.
Copyright © RSA Security Inc., 1997-2005. All rights reserved.
| Field Summary | |
static int |
ENCRYPT_KEY
|
static int |
MAC_KEY
|
| Method Summary | |
boolean |
checkKeyLength(int len)
Checks whether the proposed length is valid. |
void |
clearSensitiveData()
This method clears sensitive data from an object. |
clone()
Overrides the default clone to produce a deep clone. |
|
void |
generate()
Generates key data to be held by this key object. |
void |
generateInit(int[] parameters,
SecureRandom random)
Initializes this object to generate a key based on the given
|
void |
generateReInit()
Re-initializes this object to generate a key with the
keyGenParameters using the parameters and
random objects passed in during a previous call
to |
getAlgorithm()
Returns the standard algorithm name. |
|
getDevice()
Returns the name of the device of record. |
|
String[] |
getDeviceList()
Returns a |
static JSAFE_SecretKey |
getInstance(String transformation,
String device)
Builds an object that holds a secret key for the
|
byte[][] |
getKeyData()
Gets the key data from the object and returns it in the default format. |
byte[][] |
getKeyData(String format)
Gets the key data from the object and returns it in the specified
|
getKeyWrappingFormat(boolean ber)
Returns the name of the format to use when getting the data for key wrapping. |
|
int |
getMaximumKeyLength()
Gets the maximum number of bits this key is allowed to have. |
int |
getMinimumKeyLength()
Gets the minimum number of bits this key is allowed to have. |
char[] |
getPassword()
Returns a new |
byte[] |
getSecretKeyData()
Gets the key data from the object and returns it in the default format. |
byte[] |
getSecretKeyData(String format)
Gets the key data from the object and returns it in the specified
|
String[] |
getSupportedGetFormats()
Gets the formats in which this key can return the data. |
String[] |
getSupportedSetFormats()
Gets the formats with which this key may be set. |
void |
setKeyData(byte[][] keyData)
This method sets the key to possess the data contained in the
|
void |
setKeyData(String format,
byte[][] keyData)
This method is here to fit with the |
void |
setPassword(char[] newPassword,
int offset,
int passwordLen)
Sets this object to contain the given password. |
void |
setSecretKeyData(byte[] keyData,
int offset,
int keyDataLen)
Sets the key to possess the |
void |
setSecretKeyData(String format,
byte[] keyData,
int offset,
int keyDataLen)
Sets the key to possess the |
| 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 |
| Field Detail |
public static final int ENCRYPT_KEY
public static final int MAC_KEY
| Method Detail |
public static JSAFE_SecretKey getInstance(String transformation,
String device)
throws JSAFE_UnimplementedException
transformation on the given device.
The value of the algorithm must be one of
the following:
device value is as follows
"choice1[/choice2[...[/choicen]]]"
where the choices are as follows:
Note: Do not attempt to use hardware versions of Crypto-J classes unless you are very familiar with the hardware. See the "Random Number Generation" section of the Crypto-J Developer's Guide, which describes hardware usage, its benefits, and its problems.
transformation - The representation of the desired operation
(for example, "RC5").device - A list of devices used to build the object
(for example, "Java", "Native/Java").
JSAFE_SecretKey object to use with objects that
perform the transformation.
JSAFE_UnimplementedException - If the device or devices cannot
perform the designated algorithm.public String getDevice()
Possible device values are:
getDevice in interface JSAFE_Keypublic String[] getDeviceList()
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. This method
returns the names of the devices used by each component.
String array that describes the device used for a
specific component.public String getAlgorithm()
getAlgorithm in interface JSAFE_KeyString that describes the algorithm.
public void setPassword(char[] newPassword,
int offset,
int passwordLen)
passwordLen chars of
newPassword, beginning at offset.
newPassword - A char array containing the characters
of the password.offset - The offset into newPassword where the data
begins.passwordLen - The length of the password (the number of
chars, not the number of bytes).
public char[] getPassword()
throws JSAFE_InvalidKeyException
char array that contains the password.
If the object is not set with a password, this method throws an exception.
char array that contains the characters of the
password.
JSAFE_InvalidKeyException - If the object is not set with
a password.public int getMaximumKeyLength()
getMaximumKeyLength in interface JSAFE_Keyint that is the maximum size, in bits, of the key.public int getMinimumKeyLength()
getMinimumKeyLength in interface JSAFE_Keyint that is the minimum size, in bits, of the key.public String[] getSupportedSetFormats()
getSupportedSetFormats in interface JSAFE_KeyString array that is the list of valid formats.public String[] getSupportedGetFormats()
0, if the object is not set with a key.
getSupportedGetFormats in interface JSAFE_KeyString array that is the list of valid formats.public String getKeyWrappingFormat(boolean ber)
ber to specify whether the returned data should
be BER encoded or not.
getKeyWrappingFormat in interface JSAFE_Keyber - A boolean that indicates whether the data will
be wrapped BER-encoded (true) or not (false).
String that is the format.
public void setSecretKeyData(String format,
byte[] keyData,
int offset,
int keyDataLen)
throws JSAFE_InvalidKeyException,
JSAFE_UnimplementedException
keyDataLen bytes of
keyData, beginning at offset. The format of
keyData is given as the format argument.
Sets the object to the data given in the specified format.
Refer to setKeyData() for a description of the formats.
format - The format of the data being passed in.keyData - A buffer containing the key data.offset - The offset into keyData where the data begins.keyDataLen - The length of the key data.
JSAFE_InvalidKeyException - If the key data is not an
appropriate length (above the maximum or below the minimum length).
JSAFE_UnimplementedException - If the object cannot set the
data in the given format.setKeyData(java.lang.String, byte[][])
public void setSecretKeyData(byte[] keyData,
int offset,
int keyDataLen)
throws JSAFE_InvalidKeyException
keyDataLen bytes of
keyData, beginning at offset. The format of
keyData is assumed to be the default format.
Sets the object to the data given.
keyData - A buffer containing the key data.offset - The offset into keyData where the data
begins.keyDataLen - The length of the key data.
JSAFE_InvalidKeyException - If the key data is not an
appropriate length (above the maximum or below the minimum length).
public void setKeyData(String format,
byte[][] keyData)
throws JSAFE_InvalidKeyException,
JSAFE_UnimplementedException
JSAFE_Key interface
but simply calls the other setKeyData() method.
setKeyData in interface JSAFE_Keyformat - A String giving the format in which the data
is returned.keyData - An array of byte arrays holding the key data.
JSAFE_UnimplementedException - If the object cannot return
the data in the given format.
JSAFE_InvalidKeyException - If the key data is not an
appropriate length (above the maximum or below the minimum length).
public void setKeyData(byte[][] keyData)
throws JSAFE_InvalidKeyException
keyData array of byte arrays. The format of
keyData is assumed to be the default format, and the
parameters should only be the keyData.
setKeyData in interface JSAFE_KeykeyData - An array of byte arrays holding the key data.
JSAFE_InvalidKeyException - If the key data is not an
appropriate length (above the maximum or below the minimum length).
public byte[][] getKeyData(String format)
throws JSAFE_UnimplementedException
format.
getKeyData in interface JSAFE_Keyformat - The format the data is returned in.
byte arrays containing the key data.
JSAFE_UnimplementedException - If the object cannot return
the data in the given format.public byte[][] getKeyData()
getKeyData in interface JSAFE_Keybyte arrays containing the key data.
public byte[] getSecretKeyData(String format)
throws JSAFE_UnimplementedException
format.
Returns a new byte array that contains the key data in the
default format.
format - The format the data is returned in.
byte array that contains the key data.
JSAFE_UnimplementedException - If the object cannot return
the data in the given format.public byte[] getSecretKeyData()
byte array that contains the key data.public boolean checkKeyLength(int len)
len - The proposed length.
boolean that returns true if the length
is valid, false if not.
public void generateInit(int[] parameters,
SecureRandom random)
throws JSAFE_InvalidParameterException,
JSAFE_InvalidUseException
parameters using random. This
method initializes the key-generation process with the proper
Key Generation parameters and a random number generator
that generates the key bits. The key-generation process generates
valid, non-weak key data.
The JSAFE_SecureRandom object is a subclass of
java.security.SecureRandom, so an object of that class is
valid input for random.
parameters - The key generating parameters, currently this can
only be the length (in bits) of the key desired.random - A SecureRandom object from which this object
draws random bytes.
JSAFE_InvalidParameterException - If the parameters given are
not allowed by this algorithm (for example, 128 bits for a DES key).
JSAFE_InvalidUseException - If there is no random object.
public void generateReInit()
throws JSAFE_InvalidUseException
generateInit().
JSAFE_InvalidUseException - If the object is not
initialized for generation.
public void generate()
throws JSAFE_InvalidParameterException
generateInit()), this method throws an exception.
JSAFE_InvalidParameterException - If the object is
not initialized.
public Object clone()
throws CloneNotSupportedException
clone in class JSAFE_ObjectCloneNotSupportedException - If the object cannot be cloned.public void clearSensitiveData()
clearSensitiveData(),
an Init (not a ReInit) method should
be called to perform other operations with the object.
clearSensitiveData in interface JSAFE_Key
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||