Class AbstractSignature

java.lang.Object
net.schmizz.sshj.signature.AbstractSignature
All Implemented Interfaces:
Signature
Direct Known Subclasses:
AbstractSignatureDSA, SignatureEdDSA, SignatureRSA

public abstract class AbstractSignature extends Object implements Signature
An abstract class for Signature that implements common functionality.
  • Field Details

    • signature

      protected final Signature signature
    • signatureName

      private final String signatureName
  • Constructor Details

    • AbstractSignature

      protected AbstractSignature(String algorithm, String signatureName)
    • AbstractSignature

      protected AbstractSignature(Signature signatureEngine, String signatureName)
  • Method Details

    • getSignatureName

      public String getSignatureName()
      Specified by:
      getSignatureName in interface Signature
    • initVerify

      public void initVerify(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
    • initSign

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

      public void update(byte[] foo)
      Description copied from interface: Signature
      Convenience method, same as calling Signature.update(byte[], int, int) with offset as 0 and H.length.
      Specified by:
      update in interface Signature
      Parameters:
      foo - the byte-array to update with
    • 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, 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