org.mozilla.jss.crypto
Interface CryptoStore


public interface CryptoStore

This is an interface for a permanent repository of cryptographic objects, such as keys, certs, and passwords.


Method Summary
 void deleteCert(X509Certificate cert)
          Deletes a certificate from a token.
 void deletePrivateKey(PrivateKey key)
          Deletes the given PrivateKey from the CryptoToken.
 X509Certificate[] getCertificates()
          Returns all user certificates stored on this token.
 PrivateKey[] getPrivateKeys()
          Returns all private keys stored on this token.
 void importEncryptedPrivateKey(byte[] encodedKey, Password password, byte[] salt, byte[] globalSalt)
          Deprecated. A key type should be specified so that the correct usages can be enabled on the key.
 void importEncryptedPrivateKey(byte[] encodedKey, Password password, byte[] salt, byte[] globalSalt, PrivateKey.Type type)
          Deprecated. Use importPrivateKey instead.
 void importPrivateKey(byte[] key, PrivateKey.Type type)
          Imports a raw private key into this token.
 void importTemporaryEncryptedPrivateKey(byte[] encodedKey, Password password, byte[] salt, byte[] globalSalt, PrivateKey.Type type)
          Imports an encoded, encrypted private key into this token, and stores it as a temporary (session) object.
 

Method Detail

importEncryptedPrivateKey

public void importEncryptedPrivateKey(byte[] encodedKey,
                                      Password password,
                                      byte[] salt,
                                      byte[] globalSalt)
                               throws InvalidKeyFormatException,
                                      TokenException
Deprecated. A key type should be specified so that the correct usages can be enabled on the key.

Imports an encoded, encrypted private key into this token.
Parameters:
encodedKey - The encoded, encrypted private key. These bytes are expected to be a DER-encoded PKCS #8 EncryptedKeyInfo. Currently, the only encryption algorithm is RC4.
password - The password that encodes this key. The password will be cleared by this method. This password, together with the salt, are used to construct the decrypting key.
salt - The password salt.
Throws:
InvalidKeyFormatException - If the key cannot be decoded. This may be caused by supplying an incorrect password, or it may be due to corrupted data.
TokenException - If the key cannot be imported to this token.

importEncryptedPrivateKey

public void importEncryptedPrivateKey(byte[] encodedKey,
                                      Password password,
                                      byte[] salt,
                                      byte[] globalSalt,
                                      PrivateKey.Type type)
                               throws InvalidKeyFormatException,
                                      TokenException
Deprecated. Use importPrivateKey instead.

Imports an encoded, encrypted private key into this token.
Parameters:
encodedKey - The encoded, encrypted private key. These bytes are expected to be a DER-encoded PKCS #8 EncryptedKeyInfo. Currently, the only encryption algorithm is RC4.
password - The password that encodes this key. The password will be cleared by this method. This password, together with the salt, are used to construct the decrypting key.
salt - The password salt.
type - The type of the private key. This is used to enable the right operations for the key.
Throws:
InvalidKeyFormatException - If the key cannot be decoded. This may be caused by supplying an incorrect password, or it may be due to corrupted data.
TokenException - If the key cannot be imported to this token.

importPrivateKey

public void importPrivateKey(byte[] key,
                             PrivateKey.Type type)
                      throws TokenException,
                             KeyAlreadyImportedException
Imports a raw private key into this token.
Parameters:
key - The private key.
Throws:
TokenException - If the key cannot be imported to this token.
KeyAlreadyImportedException - If the key already exists on this token.

importTemporaryEncryptedPrivateKey

public void importTemporaryEncryptedPrivateKey(byte[] encodedKey,
                                               Password password,
                                               byte[] salt,
                                               byte[] globalSalt,
                                               PrivateKey.Type type)
                                        throws InvalidKeyFormatException,
                                               TokenException
Imports an encoded, encrypted private key into this token, and stores it as a temporary (session) object. The key will be deleted when it is garbage collected.
Parameters:
encodedKey - The encoded, encrypted private key. These bytes are expected to be a DER-encoded PKCS #8 EncryptedKeyInfo. Currently, the only encryption algorithm is RC4.
password - The password that encodes this key. The password will be cleared by this method. This password, together with the salt, are used to construct the decrypting key.
salt - The password salt.
type - The type of the private key. This is used to enable the right operations for the key.
Throws:
InvalidKeyFormatException - If the key cannot be decoded. This may be caused by supplying an incorrect password, or it may be due to corrupted data.
TokenException - If the key cannot be imported to this token.

getPrivateKeys

public PrivateKey[] getPrivateKeys()
                            throws TokenException
Returns all private keys stored on this token.
Returns:
An array of all private keys stored on this token.
Throws:
TokenException - If an error occurs on the token while gathering the keys.

deletePrivateKey

public void deletePrivateKey(PrivateKey key)
                      throws NoSuchItemOnTokenException,
                             TokenException
Deletes the given PrivateKey from the CryptoToken. This is a very dangerous call: it deletes the key from the underlying token. After calling this, the PrivateKey passed in must no longer be used, or a TokenException will occur.
Parameters:
key - A PrivateKey to be permanently deleted. It must reside on this token.
Throws:
NoSuchItemOnTokenException - If the given privae key does not reside on this token.
TokenException - If an error occurs on the token while deleting the key.

getCertificates

public X509Certificate[] getCertificates()
                                  throws TokenException
Returns all user certificates stored on this token. A user certificate is one that has a matching private key.
Returns:
An array of all user certificates present on this token.
Throws:
TokenException - If an error occurs on the token while gathering the certificates.

deleteCert

public void deleteCert(X509Certificate cert)
                throws NoSuchItemOnTokenException,
                       TokenException
Deletes a certificate from a token.
Parameters:
cert - A certificate to be deleted from this token. The cert must actually reside on this token.
Throws:
NoSuchItemOnTokenException - If the given cert does not reside on this token.
TokenException - If an error occurred on the token while deleting the certificate.