Class RSAPrivateKey

  • All Implemented Interfaces:
    java.io.Serializable

    @NotMutable
    @ThreadSafety(level=COMPLETELY_THREADSAFE)
    public final class RSAPrivateKey
    extends DecodedPrivateKey
    This class provides a data structure for representing the information contained in an RSA private key. As per RFC 8017 section A.1.2, an RSA private key is identified by OID 1.2.840.113549.1.1.1 and the value is encoded as follows:
       RSAPrivateKey ::= SEQUENCE {
           version           Version,
           modulus           INTEGER,  -- n
           publicExponent    INTEGER,  -- e
           privateExponent   INTEGER,  -- d
           prime1            INTEGER,  -- p
           prime2            INTEGER,  -- q
           exponent1         INTEGER,  -- d mod (p-1)
           exponent2         INTEGER,  -- d mod (q-1)
           coefficient       INTEGER,  -- (inverse of q) mod p
           otherPrimeInfos   OtherPrimeInfos OPTIONAL
       }
    
       OtherPrimeInfos ::= SEQUENCE SIZE(1..MAX) OF OtherPrimeInfo
    
       OtherPrimeInfo ::= SEQUENCE {
           prime             INTEGER,  -- ri
           exponent          INTEGER,  -- di
           coefficient       INTEGER   -- ti
       }
     
    See Also:
    Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.math.BigInteger getCoefficient()
      Retrieves the coefficient for the RSA private key.
      java.math.BigInteger getExponent1()
      Retrieves the exponent1 value for the RSA private key.
      java.math.BigInteger getExponent2()
      Retrieves the exponent2 value for the RSA private key.
      java.math.BigInteger getModulus()
      Retrieves the modulus (n) for the RSA private key.
      java.util.List<java.math.BigInteger[]> getOtherPrimeInfos()
      Retrieves a list of information about other primes used by the private key.
      java.math.BigInteger getPrime1()
      Retrieves the prime1 (p) value for the RSA private key.
      java.math.BigInteger getPrime2()
      Retrieves the prime2 (q) value for the RSA private key.
      java.math.BigInteger getPrivateExponent()
      Retrieves the private exponent (d) for the RSA private key.
      java.math.BigInteger getPublicExponent()
      Retrieves the public exponent (e) for the RSA public key.
      RSAPrivateKeyVersion getVersion()
      Retrieves the version for the RSA private key.
      void toString​(java.lang.StringBuilder buffer)
      Appends a string representation of this decoded private key to the provided buffer.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Method Detail

      • getModulus

        @NotNull
        public java.math.BigInteger getModulus()
        Retrieves the modulus (n) for the RSA private key.
        Returns:
        The modulus for the RSA private key.
      • getPublicExponent

        @NotNull
        public java.math.BigInteger getPublicExponent()
        Retrieves the public exponent (e) for the RSA public key.
        Returns:
        The public exponent for the RSA public key.
      • getPrivateExponent

        @NotNull
        public java.math.BigInteger getPrivateExponent()
        Retrieves the private exponent (d) for the RSA private key.
        Returns:
        The private exponent for the RSA private key.
      • getPrime1

        @NotNull
        public java.math.BigInteger getPrime1()
        Retrieves the prime1 (p) value for the RSA private key.
        Returns:
        The prime1 value for the RSA private key.
      • getPrime2

        @NotNull
        public java.math.BigInteger getPrime2()
        Retrieves the prime2 (q) value for the RSA private key.
        Returns:
        The prime2 value for the RSA private key.
      • getExponent1

        @NotNull
        public java.math.BigInteger getExponent1()
        Retrieves the exponent1 value for the RSA private key.
        Returns:
        The exponent1 value for the RSA private key.
      • getExponent2

        @NotNull
        public java.math.BigInteger getExponent2()
        Retrieves the exponent2 value for the RSA private key.
        Returns:
        The exponent2 value for the RSA private key.
      • getCoefficient

        @NotNull
        public java.math.BigInteger getCoefficient()
        Retrieves the coefficient for the RSA private key.
        Returns:
        The coefficient for the RSA private key.
      • getOtherPrimeInfos

        @NotNull
        public java.util.List<java.math.BigInteger[]> getOtherPrimeInfos()
        Retrieves a list of information about other primes used by the private key. If the list is non-empty, then each item will be an array of three BigInteger values, which represent a prime, an exponent, and a coefficient, respectively.
        Returns:
        A list of information about other primes used by the private key.
      • toString

        public void toString​(@NotNull
                             java.lang.StringBuilder buffer)
        Appends a string representation of this decoded private key to the provided buffer.
        Specified by:
        toString in class DecodedPrivateKey
        Parameters:
        buffer - The buffer to which the information should be appended.