Class LMSSigner

java.lang.Object
org.bouncycastle.crypto.signers.LMSSigner
All Implemented Interfaces:
Signer

public class LMSSigner extends Object implements Signer
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    generate a signature for the message we've been loaded with using the key we were initialised with.
    byte[]
    generateSignature(byte[] message)
    Sign the passed in message.
    void
    init(boolean forSigning, CipherParameters param)
    Initialise for signing or verification.
    void
    reset the internal state
    void
    update(byte b)
    Absorb a byte of the message to be signed or verified.
    void
    update(byte[] in, int off, int len)
    update the internal digest with the byte array in
    boolean
    verifySignature(byte[] signature)
    return true if the internal state represents the signature described in the passed in array.
    boolean
    verifySignature(byte[] message, byte[] signature)
    Verify the passed in signature against the passed in message.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LMSSigner

      public LMSSigner()
  • Method Details

    • init

      public void init(boolean forSigning, CipherParameters param)
      Initialise for signing or verification. A ParametersWithRandom wrapper is accepted and unwrapped, so a caller that supplies a random - as the operator builders do whenever setSecureRandom() has been called - is not refused; the random itself is not used. The message randomiser C is derived from the key's seed and the one-time index (RFC 8554 sec. 4.2, following the reference implementation), so it is deterministic and cannot repeat while q does not.
      Specified by:
      init in interface Signer
      Parameters:
      forSigning - true for signing, false for verification.
      param - the key, optionally wrapped in ParametersWithRandom.
    • generateSignature

      public byte[] generateSignature(byte[] message)
      Sign the passed in message. This is the one-shot form; it must not be mixed with the buffered form, so a call made with data already absorbed through update(byte) is refused rather than silently discarding it - call reset() first, or use generateSignature() to sign what was buffered.
      Parameters:
      message - the message to be signed.
      Returns:
      the signature.
      Throws:
      IllegalStateException - if a buffered message is present, or the signer is not initialised for signing.
    • verifySignature

      public boolean verifySignature(byte[] message, byte[] signature)
      Verify the passed in signature against the passed in message. This is the one-shot form; it must not be mixed with the buffered form, so a call made with data already absorbed through update(byte) is refused rather than silently discarding it - call reset() first, or use verifySignature(byte[]) to verify what was buffered.
      Parameters:
      message - the message the signature is claimed to be over.
      signature - the candidate signature.
      Returns:
      true if the signature verifies, false otherwise.
      Throws:
      IllegalStateException - if a buffered message is present, or the signer is not initialised for verification.
    • update

      public void update(byte b)
      Absorb a byte of the message to be signed or verified. The buffered message is consumed by generateSignature() / verifySignature(byte[]), which reset the buffer.
      Specified by:
      update in interface Signer
    • update

      public void update(byte[] in, int off, int len)
      Description copied from interface: Signer
      update the internal digest with the byte array in
      Specified by:
      update in interface Signer
    • generateSignature

      public byte[] generateSignature()
      Description copied from interface: Signer
      generate a signature for the message we've been loaded with using the key we were initialised with.
      Specified by:
      generateSignature in interface Signer
    • verifySignature

      public boolean verifySignature(byte[] signature)
      Description copied from interface: Signer
      return true if the internal state represents the signature described in the passed in array.
      Specified by:
      verifySignature in interface Signer
    • reset

      public void reset()
      Description copied from interface: Signer
      reset the internal state
      Specified by:
      reset in interface Signer