org.mozilla.jss.pkcs11

Class PK11PrivKey

Implemented Interfaces:
PrivateKey

public class PK11PrivKey
extends org.mozilla.jss.pkcs11.PK11Key
implements PrivateKey

Field Summary

Fields inherited from class org.mozilla.jss.pkcs11.PK11Key

keyProxy

Fields inherited from interface org.mozilla.jss.crypto.PrivateKey

DSA, DiffieHellman, EC, RSA

Constructor Summary

PK11PrivKey(byte[] pointer)

Method Summary

static PK11PrivKey
fromPrivateKeyInfo(PKCS8EncodedKeySpec spec, CryptoToken token)
Imports a PrivateKeyInfo, storing it as a temporary PrivateKey on the given token.
static PK11PrivKey
fromPrivateKeyInfo(byte[] pki, CryptoToken token)
Imports a PrivateKeyInfo, storing it as a temporary PrivateKey on the given token.
static PK11PrivKey
fromPrivateKeyInfo(byte[] pki, CryptoToken token, byte[] publicValue)
Imports a PrivateKeyInfo, storing it as a temporary PrivateKey on the given token.
String
getAlgorithm()
protected DSAParameterSpec
getDSAParams()
KeyType
getKeyType()
CryptoToken
getOwningToken()
Returns a new CryptoToken where this key resides.
int
getStrength()
Returns the size in bits of the modulus of an RSA Private key.
PrivateKey.Type
getType()
Returns the type (RSA or DSA) of this private key.
byte[]
getUniqueID()
Deprecated. This ID is based on an implementation that might change.
void
verifyKeyIsOnToken(PK11Token token)
Make sure this key lives on the given token.

Methods inherited from class org.mozilla.jss.pkcs11.PK11Key

getEncoded, getFormat

Constructor Details

PK11PrivKey

protected PK11PrivKey(byte[] pointer)

Method Details

fromPrivateKeyInfo

public static PK11PrivKey fromPrivateKeyInfo(PKCS8EncodedKeySpec spec,
                                             CryptoToken token)
            throws TokenException
Imports a PrivateKeyInfo, storing it as a temporary PrivateKey on the given token. The key will be a temporary (session) key until it is imported into a KeyStore, at which point it will be made a permanent (token) object.

fromPrivateKeyInfo

public static PK11PrivKey fromPrivateKeyInfo(byte[] pki,
                                             CryptoToken token)
            throws TokenException
Imports a PrivateKeyInfo, storing it as a temporary PrivateKey on the given token. The key will be a temporary (session) key until it is imported into a KeyStore, at which point it will be made a permanent (token) object.

fromPrivateKeyInfo

public static PK11PrivKey fromPrivateKeyInfo(byte[] pki,
                                             CryptoToken token,
                                             byte[] publicValue)
            throws TokenException
Imports a PrivateKeyInfo, storing it as a temporary PrivateKey on the given token. The key will be a temporary (session) key until it is imported into a KeyStore, at which point it will be made a permanent (token) object.
Parameters:
publicValue - An encoding of the public key, as used by the NSS pk11wrap code. Don't use this unless you know what you're doing.

getAlgorithm

public String getAlgorithm()

getDSAParams

protected DSAParameterSpec getDSAParams()
            throws TokenException

getKeyType

public KeyType getKeyType()

getOwningToken

public CryptoToken getOwningToken()
Returns a new CryptoToken where this key resides.
Specified by:
getOwningToken in interface PrivateKey
Returns:
The PK11Token that owns this key.

getStrength

public int getStrength()
Returns the size in bits of the modulus of an RSA Private key. Returns -1 for other types of keys.
Specified by:
getStrength in interface PrivateKey

getType

public PrivateKey.Type getType()
Returns the type (RSA or DSA) of this private key.
Specified by:
getType in interface PrivateKey

getUniqueID

public byte[] getUniqueID()
            throws TokenException

Deprecated. This ID is based on an implementation that might change. If this functionality is required, it should be provided in another way, such as a function that directly matches a cert and key.

Returns the unique ID of this key. Unique IDs can be used to match certificates to keys.
Specified by:
getUniqueID in interface PrivateKey

verifyKeyIsOnToken

public void verifyKeyIsOnToken(PK11Token token)
            throws NoSuchItemOnTokenException
Make sure this key lives on the given token.