use of org.spongycastle.crypto.Mac in project jmulticard by ctt-gob-es.
the class AmAESCrypto method getMAC.
@Override
public byte[] getMAC(final byte[] data) {
byte[] n = new byte[this.sscBytes.length + data.length];
System.arraycopy(this.sscBytes, 0, n, 0, this.sscBytes.length);
System.arraycopy(data, 0, n, this.sscBytes.length, data.length);
n = addPadding(n);
final BlockCipher cipher = new AESEngine();
final Mac mac = new CMac(cipher, 64);
mac.init(this.keyP);
mac.update(n, 0, n.length);
final byte[] out = new byte[mac.getMacSize()];
mac.doFinal(out, 0);
return out;
}
Aggregations