Interface Signature

All Known Implementing Classes:
AbstractSecurityKeySignature, AbstractSignature, AbstractSignatureDSA, SignatureDSA, SignatureECDSA, SignatureEdDSA, SignatureRSA, SignatureSkEcdsa, SignatureSkEd25519

public interface Signature
Signature interface for SSH used to sign or verify data. Usually wraps a javax.crypto.Signature object.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    encode(byte[] signature)
    Encode the signature as blog
     
    void
    Initialize this signature with the given private key for signing.
    void
    Initialize this signature with the given public key for signature verification.
    default boolean
    Returns true if encode(byte[]) already produces the full wire-format signature value (type + payload) and it should be written as a single string without an additional putSignature wrapper.
    byte[]
    Compute the signature.
    void
    update(byte[] H)
    Convenience method, same as calling update(byte[], int, int) with offset as 0 and H.length.
    void
    update(byte[] H, int off, int len)
    Update the computed signature with the given data.
    boolean
    verify(byte[] sig)
    Verify against the given signature.
  • Method Details

    • getSignatureName

      String getSignatureName()
    • initVerify

      void initVerify(PublicKey pubkey)
      Initialize this signature with the given public key for signature verification. Note that subsequent calls to either initVerify(PublicKey) or initSign(PrivateKey) will overwrite prior initialization.
      Parameters:
      pubkey - the public key to use for signature verification
    • initSign

      void initSign(PrivateKey prvkey)
      Initialize this signature with the given private key for signing. Note that subsequent calls to either initVerify(PublicKey) or initSign(PrivateKey) will overwrite prior initialization.
      Parameters:
      prvkey - the private key to use for signing
    • update

      void update(byte[] H)
      Convenience method, same as calling update(byte[], int, int) with offset as 0 and H.length.
      Parameters:
      H - the byte-array to update with
    • update

      void update(byte[] H, int off, int len)
      Update the computed signature with the given data.
      Parameters:
      H - byte-array to update with
      off - offset within the array
      len - length until which to compute
    • sign

      byte[] sign()
      Compute the signature.
      Returns:
      the computed signature
    • encode

      byte[] encode(byte[] signature)
      Encode the signature as blog
      Parameters:
      signature - the signature to encode
      Returns:
      Encoded signature
    • verify

      boolean verify(byte[] sig)
      Verify against the given signature.
      Parameters:
      sig - the signature to verify against
      Returns:
      true on successful verification, false on failure
    • isSignaturePreEncoded

      default boolean isSignaturePreEncoded()
      Returns true if encode(byte[]) already produces the full wire-format signature value (type + payload) and it should be written as a single string without an additional putSignature wrapper. Returns false for all ordinary signatures.