Class AbstractSignature

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.security.Signature signature  
      private java.lang.String signatureName  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractSignature​(java.lang.String algorithm, java.lang.String signatureName)  
      protected AbstractSignature​(java.security.Signature signatureEngine, java.lang.String signatureName)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected byte[] extractSig​(byte[] sig, java.lang.String expectedKeyAlgorithm)
      Check whether the signature is generated using the expected algorithm, and if so, return the signature blob
      java.lang.String getSignatureName()  
      void initSign​(java.security.PrivateKey privateKey)
      Initialize this signature with the given private key for signing.
      void initVerify​(java.security.PublicKey publicKey)
      Initialize this signature with the given public key for signature verification.
      byte[] sign()
      Compute the signature.
      void update​(byte[] foo)
      Convenience method, same as calling Signature.update(byte[], int, int) with offset as 0 and H.length.
      void update​(byte[] foo, int off, int len)
      Update the computed signature with the given data.
      • Methods inherited from class java.lang.Object

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

      • signature

        protected final java.security.Signature signature
      • signatureName

        private final java.lang.String signatureName
    • Constructor Detail

      • AbstractSignature

        protected AbstractSignature​(java.lang.String algorithm,
                                    java.lang.String signatureName)
      • AbstractSignature

        protected AbstractSignature​(java.security.Signature signatureEngine,
                                    java.lang.String signatureName)
    • Method Detail

      • initVerify

        public void initVerify​(java.security.PublicKey publicKey)
        Description copied from interface: Signature
        Initialize this signature with the given public key for signature verification. Note that subsequent calls to either Signature.initVerify(PublicKey) or Signature.initSign(PrivateKey) will overwrite prior initialization.
        Specified by:
        initVerify in interface Signature
        Parameters:
        publicKey - the public key to use for signature verification
      • update

        public void update​(byte[] foo,
                           int off,
                           int len)
        Description copied from interface: Signature
        Update the computed signature with the given data.
        Specified by:
        update in interface Signature
        Parameters:
        foo - byte-array to update with
        off - offset within the array
        len - length until which to compute
      • sign

        public byte[] sign()
        Description copied from interface: Signature
        Compute the signature.
        Specified by:
        sign in interface Signature
        Returns:
        the computed signature
      • extractSig

        protected byte[] extractSig​(byte[] sig,
                                    java.lang.String expectedKeyAlgorithm)
        Check whether the signature is generated using the expected algorithm, and if so, return the signature blob
        Parameters:
        sig - The full signature
        expectedKeyAlgorithm - The expected key algorithm
        Returns:
        The blob part of the signature