Class LMSSigner

  • All Implemented Interfaces:
    Signer

    public class LMSSigner
    extends java.lang.Object
    implements Signer
    • Constructor Summary

      Constructors 
      Constructor Description
      LMSSigner()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] generateSignature()
      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()
      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 java.lang.Object

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

      • LMSSigner

        public LMSSigner()
    • Method Detail

      • 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:
        java.lang.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:
        java.lang.IllegalStateException - if a buffered message is present, or the signer is not initialised for verification.
      • 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