I have 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) {
return null;
} finally {
keyParam = null;
}
return result;
}
On the iPhone, I write it 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: what method should I use for CBCBlockCipherMac, keyparameterson the iPhone, can anyone help me?
source
share