Class SHA2withRSA


  • public final class SHA2withRSA
    extends java.security.SignatureSpi
    This class is a concrete implementation for RSA signing with SHA2.
    • Field Summary

      • Fields inherited from class java.security.SignatureSpi

        appRandom
    • Constructor Summary

      Constructors 
      Constructor Description
      SHA2withRSA()
      Construct a blank RSA object.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      protected java.lang.Object engineGetParameter​(java.lang.String key)
      Deprecated. 
      protected void engineInitSign​(java.security.PrivateKey privateKey)
      Initialize this signature object with a RSA private key.
      protected void engineInitVerify​(java.security.PublicKey publicKey)
      Initialize the RSA object with a RSA public key.
      protected void engineSetParameter​(java.lang.String key, java.lang.Object param)
      Deprecated. 
      protected byte[] engineSign()
      Get message digest for all the data thus far updated, then sign the message digest.
      protected void engineUpdate​(byte b)
      Add a byte to the digest to be signed or verified.
      protected void engineUpdate​(byte[] data, int off, int len)
      Add an array of bytes to the digest to be signed or verified.
      protected boolean engineVerify​(byte[] signature)
      Verify the signature (compare the result with the message digest).
      • Methods inherited from class java.security.SignatureSpi

        clone, engineGetParameters, engineInitSign, engineSetParameter, engineSign, engineUpdate, engineVerify
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SHA2withRSA

        public SHA2withRSA()
                    throws java.security.NoSuchAlgorithmException,
                           java.security.NoSuchProviderException
        Construct a blank RSA object. It must be initialized before being usable for signing or verifying.
        Throws:
        java.security.NoSuchAlgorithmException - is thrown when if the Algorithm can not be found.
        java.security.NoSuchProviderException - is thrown the provider can not be found.
    • Method Detail

      • engineSetParameter

        @Deprecated
        protected void engineSetParameter​(java.lang.String key,
                                          java.lang.Object param)
                                   throws java.lang.UnsupportedOperationException
        Deprecated.
        Have to implement Signature's abstract method engineSetParameter to be a concrete class. However, this method has no meaning for this provider.
        Specified by:
        engineSetParameter in class java.security.SignatureSpi
        Throws:
        java.lang.UnsupportedOperationException - is always thrown.
      • engineGetParameter

        @Deprecated
        protected java.lang.Object engineGetParameter​(java.lang.String key)
                                               throws java.lang.UnsupportedOperationException
        Deprecated.
        Have to implement Signature's abstract method engineGetParameter to be a concrete class. However, this method has no meaning for this provider.
        Specified by:
        engineGetParameter in class java.security.SignatureSpi
        Throws:
        java.lang.UnsupportedOperationException - is always thrown.
      • engineInitSign

        protected void engineInitSign​(java.security.PrivateKey privateKey)
                               throws java.security.InvalidKeyException
        Initialize this signature object with a RSA private key.
        Specified by:
        engineInitSign in class java.security.SignatureSpi
        Parameters:
        privateKey - the RSA private key
        Throws:
        java.security.InvalidKeyException - if privateKey is not a valid RSA private key.
      • engineInitVerify

        protected void engineInitVerify​(java.security.PublicKey publicKey)
                                 throws java.security.InvalidKeyException
        Initialize the RSA object with a RSA public key.
        Specified by:
        engineInitVerify in class java.security.SignatureSpi
        Parameters:
        publicKey - the RSA public key.
        Throws:
        java.security.InvalidKeyException - if the key is not a valid RSA public key.
      • engineUpdate

        protected void engineUpdate​(byte b)
                             throws java.security.SignatureException
        Add a byte to the digest to be signed or verified.
        Specified by:
        engineUpdate in class java.security.SignatureSpi
        Parameters:
        b - the byte to updated.
        Throws:
        java.security.SignatureException
      • engineUpdate

        protected void engineUpdate​(byte[] data,
                                    int off,
                                    int len)
                             throws java.security.SignatureException
        Add an array of bytes to the digest to be signed or verified.
        Specified by:
        engineUpdate in class java.security.SignatureSpi
        Parameters:
        data - the array bytes to be added to the digest.
        off - the offset into the array to start the update.
        len - length of the array.
        Throws:
        java.security.SignatureException
      • engineSign

        protected byte[] engineSign()
                             throws java.security.SignatureException
        Get message digest for all the data thus far updated, then sign the message digest.
        Specified by:
        engineSign in class java.security.SignatureSpi
        Returns:
        the signature.
        Throws:
        java.security.SignatureException - if the signature object was not properly initialized, or if another exception occurs.
      • engineVerify

        protected boolean engineVerify​(byte[] signature)
                                throws java.security.SignatureException
        Verify the signature (compare the result with the message digest).
        Specified by:
        engineVerify in class java.security.SignatureSpi
        Parameters:
        signature - the signature to be verified.
        Throws:
        java.security.SignatureException - if the signature object was not properly initialized, or if another exception occurs.