Package org.mozilla.jss.pkcs11
Class PK11PrivKey
- java.lang.Object
-
- org.mozilla.jss.pkcs11.PK11PrivKey
-
- All Implemented Interfaces:
java.io.Serializable,java.security.Key,java.security.PrivateKey,javax.security.auth.Destroyable,PrivateKey
public class PK11PrivKey extends java.lang.Object implements PrivateKey
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.mozilla.jss.crypto.PrivateKey
PrivateKey.Type
-
-
Field Summary
Fields Modifier and Type Field Description protected org.mozilla.jss.pkcs11.KeyProxykeyProxy-
Fields inherited from interface org.mozilla.jss.crypto.PrivateKey
DiffieHellman, DSA, EC, RSA
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedPK11PrivKey(byte[] pointer)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PK11PrivKeyfromPrivateKeyInfo(byte[] pki, CryptoToken token)Imports a PrivateKeyInfo, storing it as a temporary PrivateKey on the given token.static PK11PrivKeyfromPrivateKeyInfo(byte[] pki, CryptoToken token, byte[] publicValue)Imports a PrivateKeyInfo, storing it as a temporary PrivateKey on the given token.static PK11PrivKeyfromPrivateKeyInfo(java.security.spec.PKCS8EncodedKeySpec spec, CryptoToken token)Imports a PrivateKeyInfo, storing it as a temporary PrivateKey on the given token.java.lang.StringgetAlgorithm()protected java.security.spec.DSAParameterSpecgetDSAParams()byte[]getEncoded()Subclasses that support encoding can overload this method.java.lang.StringgetFormat()Subclasses that support encoding can overload this method.KeyTypegetKeyType()CryptoTokengetOwningToken()Returns a new CryptoToken where this key resides.PK11PubKeygetPublicKey()Returns the corresponding public key from a private key instance.intgetStrength()Returns the size in bits of the modulus of an RSA Private key.PrivateKey.TypegetType()Returns the type (RSA or DSA) of this private key.byte[]getUniqueID()Returns the unique ID of this key.voidverifyKeyIsOnToken(PK11Token token)Make sure this key lives on the given token.
-
-
-
Method Detail
-
verifyKeyIsOnToken
public void verifyKeyIsOnToken(PK11Token token) throws NoSuchItemOnTokenException
Make sure this key lives on the given token.- Throws:
NoSuchItemOnTokenException
-
getOwningToken
public CryptoToken getOwningToken()
Returns a new CryptoToken where this key resides.- Specified by:
getOwningTokenin interfacePrivateKey- Returns:
- The PK11Token that owns this key.
-
getUniqueID
public byte[] getUniqueID() throws TokenExceptionDescription copied from interface:PrivateKeyReturns the unique ID of this key. Unique IDs can be used to match certificates to keys.- Specified by:
getUniqueIDin interfacePrivateKey- Throws:
TokenException- See Also:
TokenCertificate.getUniqueID()
-
getKeyType
public KeyType getKeyType()
-
getType
public PrivateKey.Type getType()
Description copied from interface:PrivateKeyReturns the type (RSA or DSA) of this private key.- Specified by:
getTypein interfacePrivateKey
-
getAlgorithm
public java.lang.String getAlgorithm()
- Specified by:
getAlgorithmin interfacejava.security.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:
getStrengthin interfacePrivateKey
-
getPublicKey
public PK11PubKey getPublicKey()
Returns the corresponding public key from a private key instance.
-
fromPrivateKeyInfo
public static PK11PrivKey fromPrivateKeyInfo(java.security.spec.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
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.- 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
protected java.security.spec.DSAParameterSpec getDSAParams() throws TokenException- Throws:
TokenException
-
getEncoded
public byte[] getEncoded()
Subclasses that support encoding can overload this method.- Specified by:
getEncodedin interfacejava.security.Key
-
getFormat
public java.lang.String getFormat()
Subclasses that support encoding can overload this method.- Specified by:
getFormatin interfacejava.security.Key
-
-