Interface Signature

All Superinterfaces:
AlgorithmNameProvider
All Known Implementing Classes:
AbstractSecurityKeySignature, AbstractSignature, SignatureDSA, SignatureECDSA, SignatureECDSA.SignatureECDSA256, SignatureECDSA.SignatureECDSA384, SignatureECDSA.SignatureECDSA521, SignatureEd25519, SignatureRSA, SignatureRSASHA1, SignatureRSASHA256, SignatureRSASHA512, SignatureSkECDSA, SignatureSkED25519

public interface Signature extends AlgorithmNameProvider
Signature interface for SSH used to sign or verify packets. Usually wraps a javax.crypto.Signature object. The reported algorithm name refers to the signature type being applied.
  • Method Details

    • initVerifier

      void initVerifier(SessionContext session, PublicKey key) throws Exception
      Parameters:
      session - The SessionContext for calling this method - may be null if not called within a session context
      key - The PublicKey to be used for verifying signatures
      Throws:
      Exception - If failed to initialize
    • initSigner

      void initSigner(SessionContext session, PrivateKey key) throws Exception
      Parameters:
      session - The SessionContext for calling this method - may be null if not called within a session context
      key - The PrivateKey to be used for signing
      Throws:
      Exception - If failed to initialize
    • update

      default void update(SessionContext session, byte[] hash) throws Exception
      Update the computed signature with the given data
      Parameters:
      session - The SessionContext for calling this method - may be null if not called within a session context
      hash - The hash data buffer
      Throws:
      Exception - If failed to update
      See Also:
    • update

      void update(SessionContext session, byte[] hash, int off, int len) throws Exception
      Update the computed signature with the given data
      Parameters:
      session - The SessionContext for calling this method - may be null if not called within a session context
      hash - The hash data buffer
      off - Offset of hash data in buffer
      len - Length of hash data
      Throws:
      Exception - If failed to update
    • verify

      boolean verify(SessionContext session, byte[] sig) throws Exception
      Verify against the given signature
      Parameters:
      session - The SessionContext for calling this method - may be null if not called within a session context
      sig - The signed data
      Returns:
      true if signature is valid
      Throws:
      Exception - If failed to extract signed data for validation
    • sign

      byte[] sign(SessionContext session) throws Exception
      Compute the signature
      Parameters:
      session - The SessionContext for calling this method - may be null if not called within a session context
      Returns:
      The signature value
      Throws:
      Exception - If failed to calculate the signature
    • getSshAlgorithmName

      default String getSshAlgorithmName(String algo)
      Parameters:
      algo - - the negotiated value
      Returns:
      The original ssh name of the signature algorithm