I have a Java code like this:
public static byte[] generateMac(byte[] key, byte[] cipherText,int offset,int length,int mac_size_bits)
{
byte[] result = null;
KeyParameter keyParam = null;
try {
keyParam = new KeyParameter(key);
CBCBlockCipherMac blockCipherMac = new CBCBlockCipherMac(new AESEngine(),mac_size_bits);
result = new byte[blockCipherMac.getMacSize()];
blockCipherMac.init(keyParam);
blockCipherMac.update(cipherText, offset, length);
blockCipherMac.doFinal(result, 0);
} catch (Exception e) {
// System.out.println(e);
return null;
} finally {
keyParam = null;
}
return result;
}
On the iPhone I am scribbling like this:
- (NSData *)generateMac:(NSData *)key cipherText:(NSData *)cipherText offset:(int)offset length:(int)length mac_size_bits:(int)mac_size_bits
My question is, which method should I use for CBCBlockCipherMac
, keyparameters
in iPhone can anyone help me please?
its MAC encryption -- AFAIK there is no one-shot replacement/equivalent on IOS
see original docs docs and wikipedia wiki
learn how the algo works and then replicate it using CommonCrypto
--sorry no better idea
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With