Class RSAPublicKey

  • All Implemented Interfaces:
    java.io.Serializable, java.security.Key, java.security.PublicKey

    public final class RSAPublicKey
    extends X509Key
    An X.509 public key for the RSA Algorithm.
    See Also:
    Serialized Form
    • Constructor Detail

      • RSAPublicKey

        public RSAPublicKey()
      • RSAPublicKey

        public RSAPublicKey​(BigInt modulus,
                            BigInt publicExponent)
                     throws java.security.InvalidKeyException
        Make a RSA public key out of a public exponent and modulus
        Throws:
        java.security.InvalidKeyException
      • RSAPublicKey

        public RSAPublicKey​(byte[] encoded)
                     throws java.security.InvalidKeyException
        Make a RSA public key from its DER encoding (X.509).
        Throws:
        java.security.InvalidKeyException
    • Method Detail

      • getKeySize

        public int getKeySize()
        Get key size as number of bits in modulus (Always rounded up to a multiple of 8)
      • getPublicExponent

        public BigInt getPublicExponent()
        Get the raw public exponent
      • getModulus

        public BigInt getModulus()
        Get the raw modulus
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class X509Key
      • parseKeyBits

        protected void parseKeyBits()
                             throws java.security.InvalidKeyException
        Description copied from class: X509Key
        Parse the key bits. This may be redefined by subclasses to take advantage of structure within the key. For example, RSA public keys encapsulate two unsigned integers (modulus and exponent) as DER values within the key bits; Diffie-Hellman and DSS/DSA keys encapsulate a single unsigned integer.

        This function is called when creating X.509 SubjectPublicKeyInfo values using the X509Key member functions, such as parse and decode.

        Overrides:
        parseKeyBits in class X509Key
        Throws:
        java.security.InvalidKeyException - on invalid key encodings.
      • hashCode

        public int hashCode()
        Description copied from class: X509Key
        Calculates a hash code value for the object. Objects which are equal will also have the same hashcode.
        Overrides:
        hashCode in class X509Key
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class X509Key
      • bigIntEquals

        public boolean bigIntEquals​(BigInt x,
                                    BigInt y)