use of org.bouncycastle.crypto.macs.CMac in project openremote by openremote.
the class SecureUtils method calculateCMAC.
public static byte[] calculateCMAC(final byte[] data, final byte[] key) {
final byte[] cmac = new byte[16];
CipherParameters cipherParameters = new KeyParameter(key);
BlockCipher blockCipher = new AESEngine();
CMac mac = new CMac(blockCipher);
mac.init(cipherParameters);
mac.update(data, 0, data.length);
mac.doFinal(cmac, 0);
return cmac;
}
Aggregations