com.rsa.jsafe
Interface JSAFE_Key

All Known Implementing Classes:
JSAFE_PrivateKey, JSAFE_PublicKey, JSAFE_SecretKey

public interface JSAFE_Key

The JSAFE_Key class is the generic key interface. All key objects implement this class, including both symmetric and asymmetric keys. 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.


Method Summary

 void

clearSensitiveData()

This method clears sensitive data from an object.

 String

getAlgorithm()

Returns the standard name for the algorithm.

 String

getDevice()

Returns the name of the device of record.

 byte[][]

getKeyData()

Gets the key data from the object and returns it in the default format.

 byte[][]

getKeyData(String format)

Returns a new array of byte arrays that contains the key data in the given format.

 String

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.

 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)

Sets the key to possess the data contained in the keyData array of byte arrays.

 void

setKeyData(String format, byte[][] keyData)

Sets the key with the data contained in the keyData array of byte arrays in the specified format.

 

Method Detail

getDevice

public String getDevice()
Returns the name of the device of record.

Possible device values are:

Returns:
The device name.

getAlgorithm

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

Returns:
A String giving the standard algorithm name.

getMaximumKeyLength

public int getMaximumKeyLength()
Gets the maximum number of bits this key is allowed to have.

Returns:
An int that is the maximum size, in bits, of the key.

getMinimumKeyLength

public int getMinimumKeyLength()
Gets the minimum number of bits this key is allowed to have.

Returns:
An int that is the minimum size, in bits, of the key.

getSupportedGetFormats

public String[] getSupportedGetFormats()
Gets the formats in which this key can return the data. This method returns a String array that lists the formats supported by getKeyData(). The return value can be a zero-length array if the object does not contain key data. The first element in the list is the default format.

Returns:
A String array that is the list of valid formats.

getSupportedSetFormats

public String[] getSupportedSetFormats()
Gets the formats with which this key may be set. Returns a String array that lists the formats supported by setKeyData(). The first element in the list is the default format.

Returns:
A String array that is the list of valid formats.

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 should be BER-encoded or not.

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

getKeyData

public byte[][] getKeyData()
Gets the key data from the object and returns it in the default format.

Returns:
A byte array containing the key data.

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.


setKeyData

public void setKeyData(String format,
                       byte[][] keyData)
                throws JSAFE_InvalidKeyException,
                       JSAFE_UnimplementedException
Sets the key with the data contained in the keyData array of byte arrays in the specified format.

JSAFE_Key keyData Formats

Algorithm

Supported Formats

keyData

"RC2", "RC4",
"RC5","DES","DESX"
"3DES_EDE",
"HMAC"

"Clear"
(default)

byte[] keyBytes;
byte[][] keyData = {
keyBytes
};

"RSA" (public)

"RSAPublicKey"
(default)

byte[] modulus,
publicExponent;
byte[][] keyData = {
modulus,
publicExponent
};

 

"RSAPublicKeyBER"

byte[] subjectPublicKeyInfo;
byte[][] keyData = {
subjectPublicKeyInfo
};

 

"KeyToken"

byte[] manufacturerID
byte[] internalKey


byte[][] keyData {
manufacturerID,
internalKey
};

"RSA" (private)

"RSAPrivateKeyCRT"
(default)

byte[] modulus,
publicExponent,
privateExponent,
primeP,
primeQ,
primeExponentP,
primeExponentQ,
crtCoefficient;


byte[][] keyData = {
modulus,
publicExponent,
privateExponent,
primeP,
primeQ,
primeExponentP,
primeExponentQ,
crtCoefficient
};

 

"RSAPrivateKey"

byte[] modulus,
privateExponent;
byte[][] keyData = {
modulus,
privateExponent
};

 

"RSAMultiPrimePrivateKeyCRT"

(2 prime)

byte[] modulus,
publicExponent,
privateExponent,
numberofPrimes,
primeP,
primeQ,
primeExponentP,
primeExponentQ,
crtCoefficient;


byte[][] keyData = {
modulus,
publicExponent,
privateExponent,
numberofPrimes,
primeP,
primeQ,
primeExponentP,
primeExponentQ,
crtCoefficient
};

 

"RSAMultiPrimePrivateKeyCRT"

(3 prime)

byte[] modulus,
publicExponent,
privateExponent,
numberofPrimes,
primeP,
primeQ,
primeR,
primeExponentP,
primeExponentQ,
primeExponentR,
crtCoefficient1,
crtCoefficient2


byte[][] keyData = {
modulus,
publicExponent,
privateExponent,
numberofPrimes,
primeP,
primeQ,
primeR,
primeExponentP,
primeExponentQ,
primeExponentR,
crtCoefficient1,
crtCoefficient2
};

 

 

"RSAPrivateKeyBER"

byte[] privateKeyInfo;
byte[][] keyData = {
privateKeyInfo
};

 

 

"KeyToken"

byte[] manufacturerID
byte[] internalKey


byte[][] keyData {
manufacturerID,
internalKey
};

 

SSLCPKCS1RSAPrivateKeyBER

byte[][] keyData = {
privateKeyInfo
};

 

SSLCPKCS1RSAPrivateKeyPEM

byte[][] pemEncodedKeyData = {

privateKeyInfo
};

"DSA"
(public)

"DSAPublicKey"
(default)







"DSAPublicValue"




"DSAPublicKeyX957BER"
"DSAPublicKeyBER"

byte[] prime,
subPrime,
base,
publicValue;
byte[][] keyData = {
prime,
subPrime,
base,
publicValue
};

byte[] privateValue;
byte[][] keyData = {
privateValue
};

byte[] subjectPublicKeyInfo;
byte[][] keyData = {
subjectPublicKeyInfo
};

 

"KeyToken"

byte[] manufacturerID
byte[] internalKey


byte[][] keyData {
manufacturerID,
internalKey
};

"DSA"
(private)

"DSAPrivateKey"
(default)







"DSAPrivateValue"




"DSAPrivateKeyX957BER"
"DSAPrivateKeyBER"

byte[] prime,
subPrime,
base,
privateValue;
byte[][] keyData = {
prime,
subPrime,
base,
privateValue
};

byte[] privateValue;
byte[][] keyData = {
privateValue
};

byte[] privateKeyInfo;
byte[][] keyData = {
privateKeyInfo
};

 

"KeyToken"

byte[] manufacturerID
byte[] internalKey


byte[][] keyData {
manufacturerID,
internalKey
};

"Diffie-Hellman" (public)

"DHPublicKey"
(default)

byte[] prime,
base,
maxExponentLen,
publicValue;
byte[][] keyData = {
prime,
base,
maxExponentLen,
publicValue
};

 

"DHPublicValue"

byte[] privateValue;
byte[][] keyData = {
privateValue
}:

 

"DHPublicKeyBER"

byte[] subjectPublicKeyInfo;
byte[][] keyData = {
subjectPublicKeyInfo
};

"Diffie-Hellman" (private)

"DHPrivateKey"
(default)

byte[] prime,
base,
maxExponentLen,
privateValue;
byte[][] keyData = {
prime,
base,
maxExponentLen,
publicValue,
privateValue
};

 

"DHPrivateValue"

byte[] privateValue;
byte[][] keyData = {
privateValue
};

 

"DHPrivateKeyBER"

byte[] privateKeyInfo;
byte[][] keyData = {
privateKeyInfo
};

Note: If the format is DSAPublicKeyBER or DSAPrivateKeyBER, the resulting key is encoded following the X9.30 standard.

Parameters:
format - A String giving the format in which the data is returned.
keyData - An array of byte arrays holding the key data.
Throws:
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 return the data in the given format.

getKeyData

public byte[][] getKeyData(String format)
                    throws JSAFE_UnimplementedException
Returns a new array of byte arrays that contains the key data in the given format. If an object cannot return the data in the specified format, this method throws an exception.

Parameters:
format - The format in which the data is returned.
Returns:
An array of byte arrays containing the key data.
Throws:
JSAFE_UnimplementedException - If the object cannot return the data in the given format.

setKeyData

public void setKeyData(byte[][] keyData)
                throws JSAFE_InvalidKeyException
Sets the key to possess the data contained in the keyData array of byte arrays. The format of keyData is assumed to be the default format.

Parameters:
keyData - An array of byte arrays holding the key data.
Throws:
JSAFE_InvalidKeyException - If the key data is not an appropriate length (above the maximum or below the minimum length).


RSA BSAFE Crypto-J 3.5.2