Class DSAPrivateKey

  • All Implemented Interfaces:
    java.io.Serializable, java.security.interfaces.DSAKey, java.security.interfaces.DSAPrivateKey, java.security.Key, java.security.PrivateKey, javax.security.auth.Destroyable

    public final class DSAPrivateKey
    extends PKCS8Key
    implements java.security.interfaces.DSAPrivateKey
    A PKCS#8 private key for the Digital Signature Algorithm.
    See Also:
    DSAPublicKey, AlgIdDSA, Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      DSAPrivateKey()  
      DSAPrivateKey​(byte[] encoded)
      Make a DSA private key from its DER encoding (PKCS #8).
      DSAPrivateKey​(java.math.BigInteger x, java.math.BigInteger p, java.math.BigInteger q, java.math.BigInteger g)
      Make a DSA private key out of a private key and three parameters.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)
      Compares two private keys.
      java.security.interfaces.DSAParams getParams()
      Returns the DSA parameters associated with this key, or null if the parameters could not be parsed.
      java.math.BigInteger getX()
      Get the raw private key, x, without the parameters.
      int hashCode()
      Calculates a hash code value for this object.
      protected void parseKeyBits()
      Parse the key bits.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

        destroy, isDestroyed
      • Methods inherited from interface java.security.Key

        getAlgorithm, getEncoded, getFormat
    • Constructor Detail

      • DSAPrivateKey

        public DSAPrivateKey()
      • DSAPrivateKey

        public DSAPrivateKey​(java.math.BigInteger x,
                             java.math.BigInteger p,
                             java.math.BigInteger q,
                             java.math.BigInteger g)
                      throws java.security.InvalidKeyException
        Make a DSA private key out of a private key and three parameters.
        Throws:
        java.security.InvalidKeyException
      • DSAPrivateKey

        public DSAPrivateKey​(byte[] encoded)
                      throws java.security.InvalidKeyException
        Make a DSA private key from its DER encoding (PKCS #8).
        Throws:
        java.security.InvalidKeyException
    • Method Detail

      • getParams

        public java.security.interfaces.DSAParams getParams()
        Returns the DSA parameters associated with this key, or null if the parameters could not be parsed.
        Specified by:
        getParams in interface java.security.interfaces.DSAKey
      • getX

        public java.math.BigInteger getX()
        Get the raw private key, x, without the parameters.
        Specified by:
        getX in interface java.security.interfaces.DSAPrivateKey
      • toString

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

        protected void parseKeyBits()
                             throws java.security.InvalidKeyException
        Description copied from class: PKCS8Key
        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 PKCS#8 SubjectPublicKeyInfo values using the PKCS8Key member functions, such as parse and decode.

        Overrides:
        parseKeyBits in class PKCS8Key
        Throws:
        java.security.InvalidKeyException - if the key encoding is invalid.
      • hashCode

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

        public boolean equals​(java.lang.Object obj)
        Description copied from class: PKCS8Key
        Compares two private keys. This returns false if the object with which to compare is not of type Key. Otherwise, the encoding of this key object is compared with the encoding of the given key object.
        Overrides:
        equals in class PKCS8Key
        Parameters:
        obj - the object with which to compare
        Returns:
        true if this key has the same encoding as the object argument; false otherwise.