Class SignatureUtil
java.lang.Object
org.eclipse.milo.opcua.stack.core.util.SignatureUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]hmac(SecurityAlgorithm securityAlgorithm, byte[] secretKey, ByteBuffer... buffers) Compute the HMAC of the provided buffers.static byte[]sign(SecurityAlgorithm securityAlgorithm, PrivateKey privateKey, ByteBuffer... buffers) Sign the contents of the provided buffers using the providedSecurityAlgorithm.static voidverify(SecurityAlgorithm algorithm, X509Certificate certificate, byte[] dataBytes, byte[] signatureBytes) Verify thatsignatureBytesis a valid signature produced by the private key ofcertificatehaving signeddataBytesusingalgorithm.
-
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 providedSecurityAlgorithm. Note that only the bytes between position and limit of each buffer are considered.- Parameters:
securityAlgorithm- theSecurityAlgorithm.privateKey- thePrivateKeyto 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 thatsignatureBytesis a valid signature produced by the private key ofcertificatehaving signeddataBytesusingalgorithm.- Parameters:
algorithm- theSecurityAlgorithmused to create the signature.certificate- theX509Certificateused to verify the signature.dataBytes- the bytes thesignatureByteswas produced from.signatureBytes- the signature created by signingdataBytes.- 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- theSecurityAlgorithmthat provides the transformation forMac.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.
-