Class HmacSHA256

java.lang.Object
de.christofreichardt.json.websignature.HmacSHA256
All Implemented Interfaces:
de.christofreichardt.diagnosis.Traceable, JWSAlgorithm

public class HmacSHA256 extends Object implements JWSAlgorithm
An apapter to the underlying MAC instance provided by the Java platform which has the same name.
Author:
Christof Reichardt
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the name of the underlying algorithm object.
    de.christofreichardt.diagnosis.AbstractTracer
     
    void
    init(Key key)
    Initialises the underlying algorithm provided by the Java platform with the given key.
    postSigning(byte[] signature)
    Optional post-processing of the signature bytes, for example the signature bytes might be DER encoded and RFC 7515 or rather RFC 7518 require a different format.
    byte[]
    preValidating(byte[] signature)
    Optional pre-processing of the to be validated signature bytes, for example the verifying algorithm instance given by the Java runtime might require DER encoded signature bytes.
    byte[]
    Requests a signature from the underlying algorithm for the delivered bytes.
    void
    update(byte[] data)
    Hands over the given bytes to the underlying algorithm provided by the Java platform.
    boolean
    verify(byte[] signature)
    Requests the validation of the delivered data agianst the given signature.

    Methods inherited from class Object

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

    • init

      public void init(Key key) throws InvalidKeyException
      Description copied from interface: JWSAlgorithm
      Initialises the underlying algorithm provided by the Java platform with the given key.
      Specified by:
      init in interface JWSAlgorithm
      Parameters:
      key - the cryptographic key used for signing or validating.
      Throws:
      InvalidKeyException
    • update

      public void update(byte[] data)
      Description copied from interface: JWSAlgorithm
      Hands over the given bytes to the underlying algorithm provided by the Java platform.
      Specified by:
      update in interface JWSAlgorithm
      Parameters:
      data - the data to be signed or to be validated.
    • signature

      public byte[] signature()
      Description copied from interface: JWSAlgorithm
      Requests a signature from the underlying algorithm for the delivered bytes.
      Specified by:
      signature in interface JWSAlgorithm
      Returns:
      the signature bytes
    • verify

      public boolean verify(byte[] signature)
      Description copied from interface: JWSAlgorithm
      Requests the validation of the delivered data agianst the given signature.
      Specified by:
      verify in interface JWSAlgorithm
      Parameters:
      signature - the signature bytes.
      Returns:
      indicates if the signature has been valid.
    • algorithm

      public String algorithm()
      Description copied from interface: JWSAlgorithm
      Returns the name of the underlying algorithm object.
      Specified by:
      algorithm in interface JWSAlgorithm
      Returns:
      the name of the underlying algorithm object.
    • postSigning

      public String postSigning(byte[] signature)
      Description copied from interface: JWSAlgorithm
      Optional post-processing of the signature bytes, for example the signature bytes might be DER encoded and RFC 7515 or rather RFC 7518 require a different format.
      Specified by:
      postSigning in interface JWSAlgorithm
      Parameters:
      signature - the signature bytes.
      Returns:
      the optionally processed signature bytes
    • preValidating

      public byte[] preValidating(byte[] signature)
      Description copied from interface: JWSAlgorithm
      Optional pre-processing of the to be validated signature bytes, for example the verifying algorithm instance given by the Java runtime might require DER encoded signature bytes.
      Specified by:
      preValidating in interface JWSAlgorithm
      Parameters:
      signature - the signature bytes.
      Returns:
      the optionally processed signature bytes
    • getCurrentTracer

      public de.christofreichardt.diagnosis.AbstractTracer getCurrentTracer()
      Specified by:
      getCurrentTracer in interface de.christofreichardt.diagnosis.Traceable