Package org.conscrypt

Class OpenSSLRSAPrivateKey

  • All Implemented Interfaces:
    java.io.Serializable, java.security.interfaces.RSAKey, java.security.interfaces.RSAPrivateKey, java.security.Key, java.security.PrivateKey, javax.security.auth.Destroyable, OpenSSLKeyHolder
    Direct Known Subclasses:
    OpenSSLRSAPrivateCrtKey

    class OpenSSLRSAPrivateKey
    extends java.lang.Object
    implements java.security.interfaces.RSAPrivateKey, OpenSSLKeyHolder
    An implementation of PrivateKey for RSA keys which uses BoringSSL to perform all the operations.
    • Field Detail

      • fetchedParams

        transient boolean fetchedParams
      • modulus

        java.math.BigInteger modulus
      • privateExponent

        java.math.BigInteger privateExponent
    • Constructor Detail

      • OpenSSLRSAPrivateKey

        OpenSSLRSAPrivateKey​(OpenSSLKey key)
      • OpenSSLRSAPrivateKey

        OpenSSLRSAPrivateKey​(OpenSSLKey key,
                             byte[][] params)
      • OpenSSLRSAPrivateKey

        public OpenSSLRSAPrivateKey​(java.security.spec.RSAPrivateKeySpec rsaKeySpec)
                             throws java.security.spec.InvalidKeySpecException
        Throws:
        java.security.spec.InvalidKeySpecException
    • Method Detail

      • init

        private static OpenSSLKey init​(java.security.spec.RSAPrivateKeySpec rsaKeySpec)
                                throws java.security.spec.InvalidKeySpecException
        Throws:
        java.security.spec.InvalidKeySpecException
      • wrapPlatformKey

        static OpenSSLKey wrapPlatformKey​(java.security.interfaces.RSAPrivateKey rsaPrivateKey)
                                   throws java.security.InvalidKeyException
        Throws:
        java.security.InvalidKeyException
      • wrapJCAPrivateKeyForTLSStackOnly

        static OpenSSLKey wrapJCAPrivateKeyForTLSStackOnly​(java.security.PrivateKey privateKey,
                                                           java.security.PublicKey publicKey)
                                                    throws java.security.InvalidKeyException
        Wraps the provided private key for use in the TLS/SSL stack only. Sign/decrypt operations using the key will be delegated to the Signature/Cipher implementation of the provider which accepts the key.
        Throws:
        java.security.InvalidKeyException
      • getInstance

        static OpenSSLKey getInstance​(java.security.interfaces.RSAPrivateKey rsaPrivateKey)
                               throws java.security.InvalidKeyException
        Throws:
        java.security.InvalidKeyException
      • ensureReadParams

        final void ensureReadParams()
      • readParams

        void readParams​(byte[][] params)
      • getPrivateExponent

        public final java.math.BigInteger getPrivateExponent()
        Specified by:
        getPrivateExponent in interface java.security.interfaces.RSAPrivateKey
      • getModulus

        public final java.math.BigInteger getModulus()
        Specified by:
        getModulus in interface java.security.interfaces.RSAKey
      • getEncoded

        public final byte[] getEncoded()
        Specified by:
        getEncoded in interface java.security.Key
      • getFormat

        public final java.lang.String getFormat()
        Specified by:
        getFormat in interface java.security.Key
      • getAlgorithm

        public final java.lang.String getAlgorithm()
        Specified by:
        getAlgorithm in interface java.security.Key
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • readObject

        private void readObject​(java.io.ObjectInputStream stream)
                         throws java.io.IOException,
                                java.lang.ClassNotFoundException
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • writeObject

        private void writeObject​(java.io.ObjectOutputStream stream)
                          throws java.io.IOException
        Throws:
        java.io.IOException