Class Signature

  • Direct Known Subclasses:
    PKCS1Signature

    public abstract class Signature
    extends java.lang.Object
    This class provides the functionality of a signature algorithm for signing and verifying.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected Key key  
      protected int operation  
      static int OPERATION_SIGN
      Constant used to initialize this signature algorithm to sign.
      static int OPERATION_VERIFY
      Constant used to initialize this signature algorithm to verify.
    • Constructor Summary

      Constructors 
      Constructor Description
      Signature()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract void doReset()  
      protected abstract byte[] doSign​(byte[] data)  
      protected abstract boolean doVerify​(byte[] data, byte[] expected)  
      abstract java.lang.String getAlgorithm()
      Returns the name of the signature algorithm.
      protected abstract boolean isKeySupported​(Key key, int operation)  
      void reset​(int operation, Key key)
      Initializes this message signature algorithm to sign or verify.
      byte[] sign()
      Finalizes the sign operation by processing all the accumulated input data and returning the result in a new buffer.
      java.lang.String toString()
      Returns the name of the algorithm.
      void update​(byte[] data)
      Updates the input data that will be processed by this signature algorithm.
      void update​(byte[] data, int start, int count)
      Updates the input data that will be processed by this signature algorithm.
      void update​(int data)
      Updates the input data that will be processed by this signature algorithm.
      boolean verify​(byte[] signature)
      Finalizes the verify operation by processing all the accumulated input data and returning the signature comparison result.
      • Methods inherited from class java.lang.Object

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

      • operation

        protected int operation
      • key

        protected Key key
      • OPERATION_SIGN

        public static final int OPERATION_SIGN
        Constant used to initialize this signature algorithm to sign.
        See Also:
        Constant Field Values
      • OPERATION_VERIFY

        public static final int OPERATION_VERIFY
        Constant used to initialize this signature algorithm to verify.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Signature

        public Signature()
    • Method Detail

      • toString

        public final java.lang.String toString()
        Returns the name of the algorithm.
        Overrides:
        toString in class java.lang.Object
        Returns:
        The name of the algorithm used.
      • reset

        public final void reset​(int operation,
                                Key key)
                         throws CryptoException
        Initializes this message signature algorithm to sign or verify. Calling this method will also reset the input data buffer.
        Parameters:
        operation - The operation mode of this signature algorithm (OPERATION_SIGN or OPERATION_VERIFY).
        key - The key.
        Throws:
        CryptoException - If one or more initialization parameters are invalid or the signature algorithm fails to initialize with the given parameters.
      • update

        public final void update​(int data)
        Updates the input data that will be processed by this signature algorithm. The data will be accumulated in an input buffer to be processed when sign() or verify(byte[]) is finally called.
        Parameters:
        data - The input data.
      • update

        public final void update​(byte[] data)
        Updates the input data that will be processed by this signature algorithm. The data will be accumulated in an input buffer to be processed when sign() or verify(byte[]) is finally called.
        Parameters:
        data - The input data.
      • update

        public final void update​(byte[] data,
                                 int start,
                                 int count)
        Updates the input data that will be processed by this signature algorithm. The data will be accumulated in an input buffer to be processed when sign() or verify(byte[]) is finally called.
        Parameters:
        data - The input data.
        start - The offset in data where the data starts.
        count - The input length.
      • sign

        public byte[] sign()
                    throws CryptoException
        Finalizes the sign operation by processing all the accumulated input data and returning the result in a new buffer.
        Returns:
        The signature in a new buffer.
        Throws:
        CryptoException
      • verify

        public boolean verify​(byte[] signature)
                       throws CryptoException
        Finalizes the verify operation by processing all the accumulated input data and returning the signature comparison result.
        Returns:
        the signature comparison result.
        Throws:
        CryptoException
      • getAlgorithm

        public abstract java.lang.String getAlgorithm()
        Returns the name of the signature algorithm.
        Returns:
        The name of the signature algorithm used.
      • isKeySupported

        protected abstract boolean isKeySupported​(Key key,
                                                  int operation)