AES计算CMAC Java到Swift

时间:2015-10-02 23:56:05

标签: swift authentication aes

我正在尝试计算CMAC

byte[] key={0x09,0x11,0x12,0x34,0x56,0x78,0x00,0x01,0x01,0x13,0x14,0x36,0x58,0x7A,0x02,0x03};
AES mAES=new AES();
mAES.AesInit(key);
byte[] response = mAES.calcCMAC(challenge);

Swift我正在使用lib CryptoSwift

let key = [0x09,0x11,0x12,0x34,0x56,0x78,0x00,0x01,0x01,0x13,0x14,0x36,0x58,0x7A,0x02,0x03] as [UInt8]
let message:NSData = NSData.fromHexString("DA55C255")
let mac = Authenticator.Poly1305(key: key).authenticate(message.arrayOfBytes())

但它没有按预期工作。

预期结果是

挑战是DA55C255
回复是ED7CA01A

1 个答案:

答案 0 :(得分:0)

我们没有找到任何解决方案,我们创建了自己的classe

https://gist.github.com/bolom/b426a0163943b576175b