Hi, I want to calculate Mac3([ISO/IEC 9797-1] MAC algorithm 3 with blockcipher DES, zero IV(8bytes), [ISO / IEC 9797 - 1] padding method 2) by using Cyptosym module of NXP NFC Reader Library.
This is the code i wrote for test, but it does not give the expected result.
uint8_t kMac[16] = {0};
kMac[0] = 0x1C;
kMac[1] = 0x45;
kMac[2] = 0x86;
kMac[3] = 0xCD;
kMac[4] = 0x3E;
kMac[5] = 0xB6;
kMac[6] = 0xE3;
kMac[7] = 0x26;
kMac[8] = 0x1;
kMac[9] = 0x4C;
kMac[10] = 0x61;
kMac[11] = 0xDF;
kMac[12] = 0xD9;
kMac[13] = 0xCD;
kMac[14] = 0x76;
kMac[15] = 0x7F;
uint8_t eifd_Latest[32] = {0};
eifd_Latest[0] = 0xDC;
eifd_Latest[1] = 0xD0;
eifd_Latest[2] = 0xAB;
eifd_Latest[3] = 0xF5;
eifd_Latest[4] = 0x64;
eifd_Latest[5] = 0xCB;
eifd_Latest[6] = 0xF5;
eifd_Latest[7] = 0x3A;
eifd_Latest[8] = 0xF;
eifd_Latest[9] = 0x73;
eifd_Latest[10] = 0x68;
eifd_Latest[11] = 0xCA;
eifd_Latest[12] = 0x4D;
eifd_Latest[13] = 0x3A;
eifd_Latest[14] = 0x6D;
eifd_Latest[15] = 0xFE;
eifd_Latest[16] = 0x6D;
eifd_Latest[17] = 0x89;
eifd_Latest[18] = 0x37;
eifd_Latest[19] = 0x14;
eifd_Latest[20] = 0x15;
eifd_Latest[21] = 0xB8;
eifd_Latest[22] = 0x8B;
eifd_Latest[23] = 0x4B;
eifd_Latest[24] = 0x17;
eifd_Latest[25] = 0x32;
eifd_Latest[26] = 0x91;
eifd_Latest[27] = 0xB0;
eifd_Latest[28] = 0xE4;
eifd_Latest[29] = 0x3B;
eifd_Latest[30] = 0x8;
eifd_Latest[31] = 0x95;
phCryptoSym_Sw_DataParams_t sCryptoEncMac;
phCryptoSym_Sw_Init(&sCryptoEncMac,sizeof(phCryptoSym_Sw_DataParams_t), NULL);
phCryptoSym_SetConfig(&sCryptoEncMac,PH_CRYPTOSYM_CONFIG_KEEP_IV, PH_CRYPTOSYM_VALUE_KEEP_IV_OFF);
phCryptoSym_LoadKeyDirect(&sCryptoEncMac,kMac, PH_CRYPTOSYM_KEY_TYPE_3K3DES);
phCryptoSym_LoadIv(&sCryptoEncMac, iv, 8);
uint8_t maclength;
uint8_t mac[8] = {0};
phCryptoSym_CalculateMac(
&sCryptoEncMac,
(PH_CRYPTOSYM_MAC_MODE_CBCMAC),
&eifd_Latest[0],
32,
&mac[0],
&maclength);
Result MAC sshould be :
0 = 0x18
1 = 0x3E
2 = 0x7
3 = 0x61
4 = 0x55
5 = 0x7E
6 = 0x86
7 = 0xDE
But i am getting different result with above code.
Where could I be doing wrong?
Hi EE:
please refer to the description of CryptoSym implementations
Important hints for users of this component:
Regards
Daniel