Generate and Verify MAC
To generate and verify a MAC, perform the following steps:
Create a session object and get an instance of the key using username, password, and property file path.
NaeSession session = new NaeSession(user, passwd, propFilePath);
Create a
NaeHmacKey
object using HMAC Algorithm.NaeHmacKey hmacKey = new NaeHmacKey(session,HmacAlgo.HmacSHA256,keyName);
Pass the byte array as a input to generate the MAC in byte array.
outBytes = hmacKey.GenerateMac(inputBytes);
To verify the MAC, pass the previously generated MAC and the input data.
bool resVer = hmacKey.VerifyMac(inputBytes, outBytes);