public static byte[] hmac(SecurityAlgorithm securityAlgorithm,
                              byte[] secretKey,
                              ByteBuffer... buffers) throws UaException {

        String transformation = securityAlgorithm.getTransformation();

        try {
            Mac mac = Mac.getInstance(transformation);
            mac.init(new SecretKeySpec(secretKey, transformation));

            for (ByteBuffer buffer : buffers) {
                mac.update(buffer);
            }

            return mac.doFinal();
        } catch (GeneralSecurityException e) {
            throw new UaException(StatusCodes.Bad_SecurityChecksFailed, e);
        }
    }
public static byte [ ] hmac ( SecurityAlgorithm securityAlgorithm , byte [ ] secretKey , ByteBuffer ... buffers ) throws UaException { String transformation = securityAlgorithm . getTransformation ( ) ; try { Mac mac = Mac . getInstance ( transformation ) ; mac . init ( new SecretKeySpec ( secretKey , transformation ) ) ; for ( ByteBuffer buffer : buffers ) { mac . update ( buffer ) ; } return mac . doFinal ( ) ; } catch ( GeneralSecurityException e ) { throw new UaException ( StatusCodes . Bad_SecurityChecksFailed , e ) ; } }
Compute the HMAC of the provided buffers.

@param securityAlgorithm the {@link SecurityAlgorithm} that provides the transformation for
{@link Mac#getInstance(String)}}.
@param secretKey         the secret key.
@param buffers           the buffers to use.
@return the computed HMAC.
@throws UaException