Package org.mozilla.jss.pkcs11
Class PK11PrivKey
java.lang.Object
org.mozilla.jss.pkcs11.PK11Key
org.mozilla.jss.pkcs11.PK11PrivKey
- All Implemented Interfaces:
Serializable
,AutoCloseable
,Key
,PrivateKey
,Destroyable
,PrivateKey
- Direct Known Subclasses:
PK11DSAPrivateKey
,PK11ECPrivateKey
,PK11RSAPrivateKey
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.mozilla.jss.crypto.PrivateKey
PrivateKey.Type
-
Field Summary
FieldsFields inherited from interface org.mozilla.jss.crypto.PrivateKey
DiffieHellman, DSA, EC, RSA
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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.static PK11PrivKey
fromPrivateKeyInfo
(PKCS8EncodedKeySpec spec, CryptoToken token) Imports a PrivateKeyInfo, storing it as a temporary PrivateKey on the given token.protected DSAParameterSpec
private byte[][]
Returns a new CryptoToken where this key resides.Returns the corresponding public key from a private key instance.int
Returns the size in bits of the modulus of an RSA Private key.getType()
Returns the type (RSA or DSA) of this private key.byte[]
Returns the unique ID of this key.void
verifyKeyIsOnToken
(PK11Token token) Make sure this key lives on the given token.Methods inherited from class org.mozilla.jss.pkcs11.PK11Key
close, finalize, getEncoded, getFormat
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface javax.security.auth.Destroyable
destroy, isDestroyed
Methods inherited from interface java.security.Key
getEncoded, getFormat
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
-
Constructor Details
-
PK11PrivKey
private PK11PrivKey() -
PK11PrivKey
protected PK11PrivKey(byte[] pointer)
-
-
Method Details
-
verifyKeyIsOnToken
Make sure this key lives on the given token.- Throws:
NoSuchItemOnTokenException
-
getOwningToken
Returns a new CryptoToken where this key resides.- Specified by:
getOwningToken
in interfacePrivateKey
- Returns:
- The PK11Token that owns this key.
-
getUniqueID
Description copied from interface:PrivateKey
Returns the unique ID of this key. Unique IDs can be used to match certificates to keys.- Specified by:
getUniqueID
in interfacePrivateKey
- Throws:
TokenException
- See Also:
-
getKeyType
-
getType
Description copied from interface:PrivateKey
Returns the type (RSA or DSA) of this private key.- Specified by:
getType
in interfacePrivateKey
-
getAlgorithm
- Specified by:
getAlgorithm
in interfaceKey
-
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 interfacePrivateKey
-
getPublicKey
Returns the corresponding public key from a private key instance. -
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.- Throws:
TokenException
-
fromPrivateKeyInfo
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.- Throws:
TokenException
-
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.- Throws:
TokenException
-
getDSAParams
- Throws:
TokenException
-
getDSAParamsNative
- Throws:
TokenException
-