Mac defined in GP can be converted to MAC in PBOC through simple computing, as follows:
Data = 84820000100102030405060708800000
Icv= 0000000000000000
Key = 404142434445464748494a4b4c4d4e4f
Security Channel Protocol identifier algscp = 02
3des_mac_1 is the calculation Mac method specified in PBOC.
3des_mac_1 (icv + data, key, mac1) // mac1 = 106729a5f51bfc24
Gp_mac is the calculation Mac method specified in GP, which is equivalent to the last 8 bytes of cbc_mac.
Datal = last (data, 16)
Datab = copy (data, 1, 16)
Key1 = copy (Key, 1, 16)
Cbc_3des_en (icv + datab, key1, _ data)
Xdata = XOR (_ data, datal)
Gp_mac (xdata, key, mac2) // mac2 = 106729a5f51bfc24
After carefully reading the following pboc_mac source code, I believe you will understand the Conversion Relationship Between gp_mac and pboc_mac.
Void dossmac (const byte * input, intninlen, const byte * Key, int nkeylen, byte * output) {byte byinitvec [8]; // initial vector byte bytemp [8]; memset (byinitvec, 0x00, sizeof (byinitvec); memset (bytemp, 0x00, sizeof (bytemp); memcpy (byinitvec, input, 8 ); bytebysubkey [3] [16] [48]; // key memset (bysubkey, 0x01, sizeof (bysubkey); int I = 0; int J = (ninlen> 3); // construct and generate subkeys byte nkey = (nkeylen> 3)> 3? 3: (nkeylen> 3); for (I = 0; I <nkey; I ++) {setsubkey (& bysubkey [I], & Key [I <3]);} memcpy (output, input, 8); if (1 = nkey) // key (8 bytes) {J --; for (INT I = 0; I <j; ++ I) {XOR (input + 8 * (I + 1), output, 8, output); rundes (output, 0, & bysubkey [0], output); // memcpy (byinitvec, output, 8); // set the output to the reverse variable }}< span style = "color: # ff0000; "> // The Conversion Relationship is here else if (2 = nkey) // double long key (16 bytes) {J-= 2; for (I = 0; I <j; ++ I) {XOR (input + 8 * (I + 1), output, 8, output); rundes (output, 0, & bysubkey [0], output); // set the output to the reverse variable} XOR (input + 8 * (++ I), output, 8, output ); // The last data block is different from the preceding encryption result or rundes (output, 0, & bysubkey [0], output); rundes (output, 1, & bysubkey [1], output); rundes (output, 0, & bysubkey [0], output) ;}</span> else // three times the key length (24 bytes) not verified {// J-= 2; for (I = 0, j = (ninlen> 3)-2; I <j; ++ I, input ++ = 8) {XOR (input + 8 * (I + 1), output, 8, bytemp); rundes (bytemp, 0, & bysubkey [0], output); memcpy (byinitvec, output, 8); // set the output to reverse variable} XOR (input + 8 * I, output, 8, output); rundes (output, 2, & bysubkey [0], output); rundes (output, 1, & bysubkey [1], output); rundes (output, 0, & bysubkey [0], output );}}