com.ibm.crypto.pkcs11impl.provider
Class RSAPrivateKey
- java.lang.Object
-
- com.ibm.security.pkcsutil.PKCSDerObject
-
- com.ibm.security.pkcs8.PrivateKeyInfo
-
- com.ibm.crypto.pkcs11impl.provider.RSAPrivateKey
-
- All Implemented Interfaces:
- PKCS11Key, PKCS11PrivateKey, PKCS11RSAPrivateKey, com.ibm.pkcs11.P11Key, java.io.Serializable, java.lang.Cloneable, java.security.interfaces.RSAKey, java.security.interfaces.RSAPrivateCrtKey, java.security.interfaces.RSAPrivateKey, java.security.Key, java.security.PrivateKey, javax.security.auth.Destroyable
public final class RSAPrivateKey extends com.ibm.security.pkcs8.PrivateKeyInfo implements PKCS11RSAPrivateKey, java.io.Serializable
A PKCS11 RSA Private Key- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description RSAPrivateKey(Session session, com.ibm.pkcs11.PKCS11Object object)RSAPrivateKey(Session session, com.ibm.pkcs11.PKCS11Object object, byte[] id, byte[] subject, java.lang.String label, java.lang.Boolean isToken, java.lang.Boolean isSensitive, java.lang.Boolean isSign, java.lang.Boolean isDecrypt, java.lang.Boolean isUnwrap, java.lang.Boolean isExtractable, java.math.BigInteger modulus, java.math.BigInteger publicExponent)Creates a RSA private hardware keyRSAPrivateKey(Session session, com.ibm.pkcs11.PKCS11Object object, byte[] id, byte[] subject, java.lang.String label, java.lang.Boolean isToken, java.lang.Boolean isSensitive, java.lang.Boolean isSign, java.lang.Boolean isDecrypt, java.lang.Boolean isUnwrap, java.lang.Boolean isExtractable, java.math.BigInteger modulus, java.math.BigInteger publicExponent, java.math.BigInteger privateExponent, java.math.BigInteger prime1, java.math.BigInteger prime2, java.math.BigInteger exponent1, java.math.BigInteger exponent2, java.math.BigInteger coefficient)Creates a RSA private hardware key
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description java.lang.StringgetAlgorithm()Get algorithm which always returns RSAjava.lang.BooleangetAlwaysSensitive()Return is this key AlwaysSensitivejava.lang.IntegergetAuthPinFlags()Returns the auth pin flagsjava.math.BigIntegergetCoefficient()Returns the coefficient.java.math.BigIntegergetCrtCoefficient()Returns the coefficient.java.lang.BooleangetDecrypt()Return if the key can be used for decryption.java.lang.BooleangetDerive()Returns if key supports key derivationjava.util.DategetEndDate()Returns the end datejava.math.BigIntegergetExponent1()Returns the exponent1.java.math.BigIntegergetExponent2()Returns the exponent2.java.lang.BooleangetExtractable()Return if this key can be wrapped by another key.java.lang.StringgetFormat()Get format which always returns PKCS#11byte[]getID()Return the IDjava.lang.IntegergetKeyType()Return the key typejava.lang.StringgetLabel()Return the label of the key.java.lang.BooleangetLocal()Returns true if key was either: 1, generated locally with a C_GenerateKey or C_GenerateKeyPair call 2, created with a C_CopyObject call as a copy of a key which had its CKA_LOCAL attrobute set to TRUEjava.lang.BooleangetModifiable()Returns if the attributes of the are modifiable.java.math.BigIntegergetModulus()Return the modulus.java.lang.BooleangetNeverExtractable()Return is this key Never Extractablecom.ibm.pkcs11.PKCS11ObjectgetObject()Return the PKCS11Objectjava.math.BigIntegergetPrime1()Returns the prime1.java.math.BigIntegergetPrime2()Returns the prime2.java.math.BigIntegergetPrimeExponentP()Returns the exponent1.java.math.BigIntegergetPrimeExponentQ()Returns the exponent2.java.math.BigIntegergetPrimeP()Returns the prime1.java.math.BigIntegergetPrimeQ()Returns the prime2.java.lang.BooleangetPrivate()Returns if the key is a private objectjava.math.BigIntegergetPrivateExponent()Return the private exponent.java.math.BigIntegergetPublicExponent()Returns the public exponent.java.lang.BooleangetSecondaryAuth()Returns if the key requires secondary authenticationjava.lang.BooleangetSensitive()Returns if the key is sensitiveSessiongetSession()Return the session associated with the key.SessionManagergetSessionManager()Returns the session manager associated with the keyjava.lang.BooleangetSign()Return if this key can be used to create a signaturejava.lang.BooleangetSignRecover()Return if this key supports sign recoverjava.util.DategetStartDate()Returns the start datebyte[]getSubject()Return subject of the key in the DER encoded byte arrayjava.lang.BooleangetToken()Returns if the key is a token objectjava.lang.BooleangetUnwrap()Return if the key supports unwrapping other keys.voidrm()Delete the hardware key object and release the session associated with this PKCS11 keyvoidsetKeyAsToken(boolean token)Sets the token attribute within a Java software keyvoidsetSession(Session sess)-
Methods inherited from class com.ibm.security.pkcs8.PrivateKeyInfo
addAttribute, addAttributes, clone, encode, equals, getAlgorithmId, getAttribute, getAttributes, getEncoded, getKeyBytes, hasAttribute, hasAttributes, hashCode, parseKey, parseKey, toString
-
-
-
-
Constructor Detail
-
RSAPrivateKey
public RSAPrivateKey(Session session, com.ibm.pkcs11.PKCS11Object object) throws java.security.InvalidKeyException
- Throws:
java.security.InvalidKeyException
-
RSAPrivateKey
public RSAPrivateKey(Session session, com.ibm.pkcs11.PKCS11Object object, byte[] id, byte[] subject, java.lang.String label, java.lang.Boolean isToken, java.lang.Boolean isSensitive, java.lang.Boolean isSign, java.lang.Boolean isDecrypt, java.lang.Boolean isUnwrap, java.lang.Boolean isExtractable, java.math.BigInteger modulus, java.math.BigInteger publicExponent) throws java.security.InvalidKeyException
Creates a RSA private hardware key- Parameters:
sessionManager- the PKCS#11 session manager associated with the keyobject- the PKCS11 object that is the actaully representation of the key to the hardware.ID- The identifier for this key.subject- DER encoded byte array of the Subject of this keylabel- Label of this keyisToken- Is this key a token?isSensitive- Is this key sensitive?isSign- Can this key be used for signature creation.isDecrypt- Can the key be used to decrypt data.isUnwrap- Can the key be used to unwrap another key.isExtractable- Can the key be wrapped by another key.modulus- Modulus of the keyPublicExponent- the public exponent of the key.- Throws:
java.security.InvalidKeyException
-
RSAPrivateKey
public RSAPrivateKey(Session session, com.ibm.pkcs11.PKCS11Object object, byte[] id, byte[] subject, java.lang.String label, java.lang.Boolean isToken, java.lang.Boolean isSensitive, java.lang.Boolean isSign, java.lang.Boolean isDecrypt, java.lang.Boolean isUnwrap, java.lang.Boolean isExtractable, java.math.BigInteger modulus, java.math.BigInteger publicExponent, java.math.BigInteger privateExponent, java.math.BigInteger prime1, java.math.BigInteger prime2, java.math.BigInteger exponent1, java.math.BigInteger exponent2, java.math.BigInteger coefficient) throws java.security.InvalidKeyException
Creates a RSA private hardware key- Parameters:
session- the PKCS#11 session associated with the keyobject- the PKCS11 object that is the actaully representation of the key to the hardware.ID- The identifier for this key.subject- DER encoded byte array of the Subject of this keylabel- Label of this keyisToken- Is this key a token?isSensitive- Is this key sensitive?isSign- Can this key be used for signature creation.isDecrypt- Can the key be used to decrypt data.isUnwrap- Can the key be used to unwrap another key.isExtractable- Can the key be wrapped by another key.modulus- Modulus of the keyPublicExponent- the public exponent of the key.PrivateExponent- the private exponent of the key.Prime1- the prime one of the key.Prime2- the prime two of the key.exponent1- the exponent one of the key.exponent2- the exponent two of the key.coefficient- the coefficient of the key.- Throws:
java.security.InvalidKeyException
-
-
Method Detail
-
getObject
public com.ibm.pkcs11.PKCS11Object getObject()
Return the PKCS11Object
-
getToken
public java.lang.Boolean getToken()
Returns if the key is a token object
-
rm
public void rm()
Delete the hardware key object and release the session associated with this PKCS11 key
-
getPrivate
public java.lang.Boolean getPrivate()
Returns if the key is a private object- Specified by:
getPrivatein interfacePKCS11Key- Specified by:
getPrivatein interfacecom.ibm.pkcs11.P11Key- Returns:
- true if object is a private object; null if not assigned.
-
getLabel
public java.lang.String getLabel()
Return the label of the key.
-
getModifiable
public java.lang.Boolean getModifiable()
Returns if the attributes of the are modifiable.- Specified by:
getModifiablein interfacePKCS11Key- Specified by:
getModifiablein interfacecom.ibm.pkcs11.P11Key- Returns:
- true if object can be modified; null if not assigned.
-
getKeyType
public java.lang.Integer getKeyType()
Return the key type- Specified by:
getKeyTypein interfacePKCS11Key- Specified by:
getKeyTypein interfacecom.ibm.pkcs11.P11Key- Returns:
- the key type
-
getID
public byte[] getID()
Return the ID
-
getStartDate
public java.util.Date getStartDate()
Returns the start date- Specified by:
getStartDatein interfacePKCS11Key- Specified by:
getStartDatein interfacecom.ibm.pkcs11.P11Key- Returns:
- the start date
-
getEndDate
public java.util.Date getEndDate()
Returns the end date- Specified by:
getEndDatein interfacePKCS11Key- Specified by:
getEndDatein interfacecom.ibm.pkcs11.P11Key- Returns:
- the end date
-
getDerive
public java.lang.Boolean getDerive()
Returns if key supports key derivation
-
getLocal
public java.lang.Boolean getLocal()
Returns true if key was either: 1, generated locally with a C_GenerateKey or C_GenerateKeyPair call 2, created with a C_CopyObject call as a copy of a key which had its CKA_LOCAL attrobute set to TRUE
-
getSubject
public byte[] getSubject()
Return subject of the key in the DER encoded byte array- Specified by:
getSubjectin interfacePKCS11PrivateKey- Returns:
- the subject
-
getSensitive
public java.lang.Boolean getSensitive()
Returns if the key is sensitive- Specified by:
getSensitivein interfacePKCS11PrivateKey- Returns:
- true if sensitive; null if not assigned.
-
getSecondaryAuth
public java.lang.Boolean getSecondaryAuth()
Returns if the key requires secondary authentication- Specified by:
getSecondaryAuthin interfacePKCS11PrivateKey- Returns:
- true if requires secondary authentication; null if not assigned.
-
getAuthPinFlags
public java.lang.Integer getAuthPinFlags()
Returns the auth pin flags- Specified by:
getAuthPinFlagsin interfacePKCS11PrivateKey- Returns:
- mask indicating the current state of the secondary authentication PIN.
-
getDecrypt
public java.lang.Boolean getDecrypt()
Return if the key can be used for decryption.- Specified by:
getDecryptin interfacePKCS11PrivateKey- Returns:
- Boolean of value true if the key supports decryption null if this is not specified
-
getSign
public java.lang.Boolean getSign()
Return if this key can be used to create a signature- Specified by:
getSignin interfacePKCS11PrivateKey- Returns:
- Boolean of value true if the key supports signing null if this is not specified
-
getSignRecover
public java.lang.Boolean getSignRecover()
Return if this key supports sign recover- Specified by:
getSignRecoverin interfacePKCS11PrivateKey- Returns:
- true if key supports signatures where the data can be recovered from the signature; null if not assigned.
-
getUnwrap
public java.lang.Boolean getUnwrap()
Return if the key supports unwrapping other keys.- Specified by:
getUnwrapin interfacePKCS11PrivateKey- Returns:
- true if key supports unwrapping; null otherwise;
-
getExtractable
public java.lang.Boolean getExtractable()
Return if this key can be wrapped by another key.- Specified by:
getExtractablein interfacePKCS11PrivateKey- Returns:
- true if key is extractable;; null otherwise;
-
getAlwaysSensitive
public java.lang.Boolean getAlwaysSensitive()
Return is this key AlwaysSensitive- Specified by:
getAlwaysSensitivein interfacePKCS11PrivateKey- Returns:
- true if key has always had the CKA_SENSITIVE attribute set to TRUE; null otherwise
-
getNeverExtractable
public java.lang.Boolean getNeverExtractable()
Return is this key Never Extractable- Specified by:
getNeverExtractablein interfacePKCS11PrivateKey- Returns:
- true if key has never had the CKA_EXTRACTABLE attribute set to TRUE; null otherwise
-
getModulus
public java.math.BigInteger getModulus()
Return the modulus.- Specified by:
getModulusin interfacePKCS11RSAPrivateKey- Specified by:
getModulusin interfacejava.security.interfaces.RSAKey- Returns:
- the modulus of the key
-
getPublicExponent
public java.math.BigInteger getPublicExponent()
Returns the public exponent.- Specified by:
getPublicExponentin interfacePKCS11RSAPrivateKey- Specified by:
getPublicExponentin interfacejava.security.interfaces.RSAPrivateCrtKey- Returns:
- the public exponent.
-
getPrivateExponent
public java.math.BigInteger getPrivateExponent()
Return the private exponent.- Specified by:
getPrivateExponentin interfacePKCS11RSAPrivateKey- Specified by:
getPrivateExponentin interfacejava.security.interfaces.RSAPrivateKey- Returns:
- the private exponent.
-
getPrime1
public java.math.BigInteger getPrime1()
Returns the prime1.- Specified by:
getPrime1in interfacePKCS11RSAPrivateKey- Returns:
- the prime1.
-
getPrime2
public java.math.BigInteger getPrime2()
Returns the prime2.- Specified by:
getPrime2in interfacePKCS11RSAPrivateKey- Returns:
- the prime2.
-
getExponent1
public java.math.BigInteger getExponent1()
Returns the exponent1.- Specified by:
getExponent1in interfacePKCS11RSAPrivateKey- Returns:
- the exponent1.
-
getExponent2
public java.math.BigInteger getExponent2()
Returns the exponent2.- Specified by:
getExponent2in interfacePKCS11RSAPrivateKey- Returns:
- the exponent2.
-
getCoefficient
public java.math.BigInteger getCoefficient()
Returns the coefficient.- Specified by:
getCoefficientin interfacePKCS11RSAPrivateKey- Returns:
- the coefficient.
-
getPrimeP
public java.math.BigInteger getPrimeP()
Returns the prime1.- Specified by:
getPrimePin interfacejava.security.interfaces.RSAPrivateCrtKey- Returns:
- prime1 as prime P.
-
getPrimeQ
public java.math.BigInteger getPrimeQ()
Returns the prime2.- Specified by:
getPrimeQin interfacejava.security.interfaces.RSAPrivateCrtKey- Returns:
- prime2 as prime Q.
-
getPrimeExponentP
public java.math.BigInteger getPrimeExponentP()
Returns the exponent1.- Specified by:
getPrimeExponentPin interfacejava.security.interfaces.RSAPrivateCrtKey- Returns:
- exponent1 as exponent P
-
getPrimeExponentQ
public java.math.BigInteger getPrimeExponentQ()
Returns the exponent2.- Specified by:
getPrimeExponentQin interfacejava.security.interfaces.RSAPrivateCrtKey- Returns:
- exponent2 as exponent Q
-
getCrtCoefficient
public java.math.BigInteger getCrtCoefficient()
Returns the coefficient.- Specified by:
getCrtCoefficientin interfacejava.security.interfaces.RSAPrivateCrtKey- Returns:
- the coefficient.
-
getSession
public Session getSession()
Return the session associated with the key.
-
getSessionManager
public SessionManager getSessionManager()
Description copied from interface:PKCS11KeyReturns the session manager associated with the key- Specified by:
getSessionManagerin interfacePKCS11Key- Returns:
- the session manager associated with the key
-
getFormat
public java.lang.String getFormat()
Get format which always returns PKCS#11- Specified by:
getFormatin interfacejava.security.Key- Overrides:
getFormatin classcom.ibm.security.pkcs8.PrivateKeyInfo
-
getAlgorithm
public java.lang.String getAlgorithm()
Get algorithm which always returns RSA- Specified by:
getAlgorithmin interfacejava.security.Key- Overrides:
getAlgorithmin classcom.ibm.security.pkcs8.PrivateKeyInfo
-
setSession
public void setSession(Session sess)
-
setKeyAsToken
public void setKeyAsToken(boolean token)
Description copied from interface:PKCS11PrivateKeySets the token attribute within a Java software key- Specified by:
setKeyAsTokenin interfacePKCS11PrivateKey
-
-