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
    • Field Summary

      • Fields inherited from class com.ibm.security.pkcs8.PrivateKeyInfo

        version
    • 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 key
      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)
      Creates a RSA private hardware key
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      java.lang.String getAlgorithm()
      Get algorithm which always returns RSA
      java.lang.Boolean getAlwaysSensitive()
      Return is this key AlwaysSensitive
      java.lang.Integer getAuthPinFlags()
      Returns the auth pin flags
      java.math.BigInteger getCoefficient()
      Returns the coefficient.
      java.math.BigInteger getCrtCoefficient()
      Returns the coefficient.
      java.lang.Boolean getDecrypt()
      Return if the key can be used for decryption.
      java.lang.Boolean getDerive()
      Returns if key supports key derivation
      java.util.Date getEndDate()
      Returns the end date
      java.math.BigInteger getExponent1()
      Returns the exponent1.
      java.math.BigInteger getExponent2()
      Returns the exponent2.
      java.lang.Boolean getExtractable()
      Return if this key can be wrapped by another key.
      java.lang.String getFormat()
      Get format which always returns PKCS#11
      byte[] getID()
      Return the ID
      java.lang.Integer getKeyType()
      Return the key type
      java.lang.String getLabel()
      Return the label of the key.
      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
      java.lang.Boolean getModifiable()
      Returns if the attributes of the are modifiable.
      java.math.BigInteger getModulus()
      Return the modulus.
      java.lang.Boolean getNeverExtractable()
      Return is this key Never Extractable
      com.ibm.pkcs11.PKCS11Object getObject()
      Return the PKCS11Object
      java.math.BigInteger getPrime1()
      Returns the prime1.
      java.math.BigInteger getPrime2()
      Returns the prime2.
      java.math.BigInteger getPrimeExponentP()
      Returns the exponent1.
      java.math.BigInteger getPrimeExponentQ()
      Returns the exponent2.
      java.math.BigInteger getPrimeP()
      Returns the prime1.
      java.math.BigInteger getPrimeQ()
      Returns the prime2.
      java.lang.Boolean getPrivate()
      Returns if the key is a private object
      java.math.BigInteger getPrivateExponent()
      Return the private exponent.
      java.math.BigInteger getPublicExponent()
      Returns the public exponent.
      java.lang.Boolean getSecondaryAuth()
      Returns if the key requires secondary authentication
      java.lang.Boolean getSensitive()
      Returns if the key is sensitive
      Session getSession()
      Return the session associated with the key.
      SessionManager getSessionManager()
      Returns the session manager associated with the key
      java.lang.Boolean getSign()
      Return if this key can be used to create a signature
      java.lang.Boolean getSignRecover()
      Return if this key supports sign recover
      java.util.Date getStartDate()
      Returns the start date
      byte[] getSubject()
      Return subject of the key in the DER encoded byte array
      java.lang.Boolean getToken()
      Returns if the key is a token object
      java.lang.Boolean getUnwrap()
      Return if the key supports unwrapping other keys.
      void rm()
      Delete the hardware key object and release the session associated with this PKCS11 key
      void setKeyAsToken(boolean token)
      Sets the token attribute within a Java software key
      void setSession(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
      • Methods inherited from class com.ibm.security.pkcsutil.PKCSDerObject

        encode, getObjectIdentifier, write
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface javax.security.auth.Destroyable

        destroy, isDestroyed
    • 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 key
        object - 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 key
        label - Label of this key
        isToken - 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 key
        PublicExponent - 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 key
        object - 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 key
        label - Label of this key
        isToken - 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 key
        PublicExponent - 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
        Specified by:
        getObject in interface PKCS11Key
        Specified by:
        getObject in interface com.ibm.pkcs11.P11Key
        Returns:
        object
      • getToken

        public java.lang.Boolean getToken()
        Returns if the key is a token object
        Specified by:
        getToken in interface PKCS11Key
        Specified by:
        getToken in interface com.ibm.pkcs11.P11Key
        Returns:
        true if object is a token object; null if not assigned.
      • rm

        public void rm()
        Delete the hardware key object and release the session associated with this PKCS11 key
        Specified by:
        rm in interface PKCS11Key
        Specified by:
        rm in interface com.ibm.pkcs11.P11Key
      • getPrivate

        public java.lang.Boolean getPrivate()
        Returns if the key is a private object
        Specified by:
        getPrivate in interface PKCS11Key
        Specified by:
        getPrivate in interface com.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.
        Specified by:
        getLabel in interface PKCS11Key
        Specified by:
        getLabel in interface com.ibm.pkcs11.P11Key
        Returns:
        the label
      • getModifiable

        public java.lang.Boolean getModifiable()
        Returns if the attributes of the are modifiable.
        Specified by:
        getModifiable in interface PKCS11Key
        Specified by:
        getModifiable in interface com.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:
        getKeyType in interface PKCS11Key
        Specified by:
        getKeyType in interface com.ibm.pkcs11.P11Key
        Returns:
        the key type
      • getID

        public byte[] getID()
        Return the ID
        Specified by:
        getID in interface PKCS11Key
        Specified by:
        getID in interface com.ibm.pkcs11.P11Key
        Returns:
        the ID
      • getStartDate

        public java.util.Date getStartDate()
        Returns the start date
        Specified by:
        getStartDate in interface PKCS11Key
        Specified by:
        getStartDate in interface com.ibm.pkcs11.P11Key
        Returns:
        the start date
      • getEndDate

        public java.util.Date getEndDate()
        Returns the end date
        Specified by:
        getEndDate in interface PKCS11Key
        Specified by:
        getEndDate in interface com.ibm.pkcs11.P11Key
        Returns:
        the end date
      • getDerive

        public java.lang.Boolean getDerive()
        Returns if key supports key derivation
        Specified by:
        getDerive in interface PKCS11Key
        Specified by:
        getDerive in interface com.ibm.pkcs11.P11Key
        Returns:
        true if key supports key derivation; null if not assigned.
      • 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
        Specified by:
        getLocal in interface PKCS11Key
        Specified by:
        getLocal in interface com.ibm.pkcs11.P11Key
        Returns:
        true if key was either generated locally or created as a copy of a key which had its CKA_local sttribute set to TRUE
      • getSubject

        public byte[] getSubject()
        Return subject of the key in the DER encoded byte array
        Specified by:
        getSubject in interface PKCS11PrivateKey
        Returns:
        the subject
      • getSensitive

        public java.lang.Boolean getSensitive()
        Returns if the key is sensitive
        Specified by:
        getSensitive in interface PKCS11PrivateKey
        Returns:
        true if sensitive; null if not assigned.
      • getSecondaryAuth

        public java.lang.Boolean getSecondaryAuth()
        Returns if the key requires secondary authentication
        Specified by:
        getSecondaryAuth in interface PKCS11PrivateKey
        Returns:
        true if requires secondary authentication; null if not assigned.
      • getAuthPinFlags

        public java.lang.Integer getAuthPinFlags()
        Returns the auth pin flags
        Specified by:
        getAuthPinFlags in interface PKCS11PrivateKey
        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:
        getDecrypt in interface PKCS11PrivateKey
        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:
        getSign in interface PKCS11PrivateKey
        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:
        getSignRecover in interface PKCS11PrivateKey
        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:
        getUnwrap in interface PKCS11PrivateKey
        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:
        getExtractable in interface PKCS11PrivateKey
        Returns:
        true if key is extractable;; null otherwise;
      • getAlwaysSensitive

        public java.lang.Boolean getAlwaysSensitive()
        Return is this key AlwaysSensitive
        Specified by:
        getAlwaysSensitive in interface PKCS11PrivateKey
        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:
        getNeverExtractable in interface PKCS11PrivateKey
        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:
        getModulus in interface PKCS11RSAPrivateKey
        Specified by:
        getModulus in interface java.security.interfaces.RSAKey
        Returns:
        the modulus of the key
      • getPublicExponent

        public java.math.BigInteger getPublicExponent()
        Returns the public exponent.
        Specified by:
        getPublicExponent in interface PKCS11RSAPrivateKey
        Specified by:
        getPublicExponent in interface java.security.interfaces.RSAPrivateCrtKey
        Returns:
        the public exponent.
      • getPrivateExponent

        public java.math.BigInteger getPrivateExponent()
        Return the private exponent.
        Specified by:
        getPrivateExponent in interface PKCS11RSAPrivateKey
        Specified by:
        getPrivateExponent in interface java.security.interfaces.RSAPrivateKey
        Returns:
        the private exponent.
      • getPrime1

        public java.math.BigInteger getPrime1()
        Returns the prime1.
        Specified by:
        getPrime1 in interface PKCS11RSAPrivateKey
        Returns:
        the prime1.
      • getPrime2

        public java.math.BigInteger getPrime2()
        Returns the prime2.
        Specified by:
        getPrime2 in interface PKCS11RSAPrivateKey
        Returns:
        the prime2.
      • getExponent1

        public java.math.BigInteger getExponent1()
        Returns the exponent1.
        Specified by:
        getExponent1 in interface PKCS11RSAPrivateKey
        Returns:
        the exponent1.
      • getExponent2

        public java.math.BigInteger getExponent2()
        Returns the exponent2.
        Specified by:
        getExponent2 in interface PKCS11RSAPrivateKey
        Returns:
        the exponent2.
      • getCoefficient

        public java.math.BigInteger getCoefficient()
        Returns the coefficient.
        Specified by:
        getCoefficient in interface PKCS11RSAPrivateKey
        Returns:
        the coefficient.
      • getPrimeP

        public java.math.BigInteger getPrimeP()
        Returns the prime1.
        Specified by:
        getPrimeP in interface java.security.interfaces.RSAPrivateCrtKey
        Returns:
        prime1 as prime P.
      • getPrimeQ

        public java.math.BigInteger getPrimeQ()
        Returns the prime2.
        Specified by:
        getPrimeQ in interface java.security.interfaces.RSAPrivateCrtKey
        Returns:
        prime2 as prime Q.
      • getPrimeExponentP

        public java.math.BigInteger getPrimeExponentP()
        Returns the exponent1.
        Specified by:
        getPrimeExponentP in interface java.security.interfaces.RSAPrivateCrtKey
        Returns:
        exponent1 as exponent P
      • getPrimeExponentQ

        public java.math.BigInteger getPrimeExponentQ()
        Returns the exponent2.
        Specified by:
        getPrimeExponentQ in interface java.security.interfaces.RSAPrivateCrtKey
        Returns:
        exponent2 as exponent Q
      • getCrtCoefficient

        public java.math.BigInteger getCrtCoefficient()
        Returns the coefficient.
        Specified by:
        getCrtCoefficient in interface java.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: PKCS11Key
        Returns the session manager associated with the key
        Specified by:
        getSessionManager in interface PKCS11Key
        Returns:
        the session manager associated with the key
      • getFormat

        public java.lang.String getFormat()
        Get format which always returns PKCS#11
        Specified by:
        getFormat in interface java.security.Key
        Overrides:
        getFormat in class com.ibm.security.pkcs8.PrivateKeyInfo
      • getAlgorithm

        public java.lang.String getAlgorithm()
        Get algorithm which always returns RSA
        Specified by:
        getAlgorithm in interface java.security.Key
        Overrides:
        getAlgorithm in class com.ibm.security.pkcs8.PrivateKeyInfo
      • setSession

        public void setSession(Session sess)

© Portions Copyright 2003, 2017 IBM Corporation. All rights reserved.
© Portions Copyright 2003, 2017, Oracle and/or its affiliates. All rights reserved.