java.lang.Object
org.eclipse.milo.opcua.stack.core.util.SignatureUtil

public class SignatureUtil extends Object
  • Constructor Details

    • SignatureUtil

      public SignatureUtil()
  • Method Details

    • sign

      public static byte[] sign(SecurityAlgorithm securityAlgorithm, PrivateKey privateKey, ByteBuffer... buffers) throws UaException
      Sign the contents of the provided buffers using the provided SecurityAlgorithm. Note that only the bytes between position and limit of each buffer are considered.
      Parameters:
      securityAlgorithm - the SecurityAlgorithm.
      privateKey - the PrivateKey to sign with.
      buffers - the data to sign.
      Returns:
      the signature bytes.
      Throws:
      UaException - if the signature fails for any reason.
    • verify

      public static void verify(SecurityAlgorithm algorithm, X509Certificate certificate, byte[] dataBytes, byte[] signatureBytes) throws UaException
      Verify that signatureBytes is a valid signature produced by the private key of certificate having signed dataBytes using algorithm.
      Parameters:
      algorithm - the SecurityAlgorithm used to create the signature.
      certificate - the X509Certificate used to verify the signature.
      dataBytes - the bytes the signatureBytes was produced from.
      signatureBytes - the signature created by signing dataBytes.
      Throws:
      UaException - if verification fails for any reason.
    • hmac

      public static byte[] hmac(SecurityAlgorithm securityAlgorithm, byte[] secretKey, ByteBuffer... buffers) throws UaException
      Compute the HMAC of the provided buffers.
      Parameters:
      securityAlgorithm - the SecurityAlgorithm that provides the transformation for Mac.getInstance(String)}.
      secretKey - the secret key.
      buffers - the buffers to use.
      Returns:
      the computed HMAC.
      Throws:
      UaException - if the HMAC operation fails for any reason.