012*_*346 5 iphone authentication code-signing aes objective-c
我有这样的Java代码:
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;
}
Run Code Online (Sandbox Code Playgroud)
在iPhone上,我这样涂鸦:
- (NSData *)generateMac:(NSData *)key cipherText:(NSData *)cipherText offset:(int)offset length:(int)length mac_size_bits:(int)mac_size_bits
我的问题是,我应该使用哪种方法CBCBlockCipherMac,keyparameters在iPhone中有人可以帮助我吗?
| 归档时间: |
|
| 查看次数: |
314 次 |
| 最近记录: |