org.bouncycastle.crypto.macs.CMac Java Examples
The following examples show how to use
org.bouncycastle.crypto.macs.CMac.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PseudoRandomFunctionAES.java From protect with MIT License | 5 votes |
public PseudoRandomFunctionAES(final PrfKey key) { super(key); // Create CMAC instance based on AES final BlockCipher cipher = new AESEngine(); this.cipherMac = new CMac(cipher); // Initialize with key final KeyParameter params = new KeyParameter(key.getKeyBytes()); cipherMac.init(params); }
Example #2
Source File: GPBouncy.java From openjavacard-tools with GNU Lesser General Public License v3.0 | 5 votes |
private static byte[] scp03_mac(byte[] keybytes, byte[] msg, int lengthBits) { // Use BouncyCastle light interface. BlockCipher cipher = new AESEngine(); CMac cmac = new CMac(cipher); cmac.init(new KeyParameter(keybytes)); cmac.update(msg, 0, msg.length); byte[] out = new byte[cmac.getMacSize()]; cmac.doFinal(out, 0); return Arrays.copyOf(out, lengthBits / 8); }
Example #3
Source File: GPBouncy.java From openjavacard-tools with GNU Lesser General Public License v3.0 | 5 votes |
private static byte[] scp03_kdf(byte[] key, byte[] a, byte[] b, int bytes) { BlockCipher cipher = new AESEngine(); CMac cmac = new CMac(cipher); KDFCounterBytesGenerator kdf = new KDFCounterBytesGenerator(cmac); kdf.init(new KDFCounterParameters(key, a, b, 8)); byte[] cgram = new byte[bytes]; kdf.generateBytes(cgram, 0, cgram.length); return cgram; }
Example #4
Source File: CryptoPrimitives.java From Clusion with GNU General Public License v3.0 | 5 votes |
public static byte[] generateCmac(byte[] key, String msg) throws UnsupportedEncodingException { CMac cmac = new CMac(new AESFastEngine()); byte[] data = msg.getBytes("UTF-8"); byte[] output = new byte[cmac.getMacSize()]; cmac.init(new KeyParameter(key)); cmac.reset(); cmac.update(data, 0, data.length); cmac.doFinal(output, 0); return output; }
Example #5
Source File: GPCrypto.java From GlobalPlatformPro with GNU Lesser General Public License v3.0 | 5 votes |
public static byte[] scp03_kdf(byte[] key, byte[] a, byte[] b, int bytes) { BlockCipher cipher = new AESEngine(); CMac cmac = new CMac(cipher); KDFCounterBytesGenerator kdf = new KDFCounterBytesGenerator(cmac); kdf.init(new KDFCounterParameters(key, a, b, 8)); // counter size is in bits byte[] cgram = new byte[bytes]; kdf.generateBytes(cgram, 0, cgram.length); return cgram; }
Example #6
Source File: GPCrypto.java From GlobalPlatformPro with GNU Lesser General Public License v3.0 | 4 votes |
public static byte[] scp03_mac(byte[] keybytes, byte[] msg, int lengthBits) { // Use BouncyCastle light interface. BlockCipher cipher = new AESEngine(); CMac cmac = new CMac(cipher); cmac.init(new KeyParameter(keybytes)); cmac.update(msg, 0, msg.length); byte[] out = new byte[cmac.getMacSize()]; cmac.doFinal(out, 0); return Arrays.copyOf(out, lengthBits / 8); }