use of org.openecard.bouncycastle.crypto.engines.AESEngine in project open-ecard by ecsec.
the class AuthenticationToken method generateToken.
/**
* Generate an authentication token.
*
* @param keyMac Key for message authentication
* @param key Key
* @throws GeneralSecurityException
*/
public void generateToken(byte[] keyMac, byte[] key) throws GeneralSecurityException {
byte[] tmp = new byte[16];
byte[] macData = getMACObject(key);
CMac cMAC = new CMac(new AESEngine());
cMAC.init(new KeyParameter(keyMac));
cMAC.update(macData, 0, macData.length);
cMAC.doFinal(tmp, 0);
System.arraycopy(tmp, 0, token, 0, 8);
}
Aggregations