bool AsciiDecorator::checkAnAnswer(Request &req) { if(convertToBin(req)) { return CommandDecorator::checkAnAnswer(req); } return false; }
void f2_5(u8* keyArr, u8* response_arr) { u8* out2; out2 = malloc(16); for (i = 0; i < 16; i++) { out2[i] = temp[i] ^ opc[i]; } convertToBin(out2, binArr); rotWord(binArr, 128, 0x3A); convertToHex(binArr, out2); for (i = 0; i < 16; i++) { out2[i] ^= c2[i]; } encrypt(out2, keyArr, out2); for (i = 0; i < 16; i++) { out2[i] ^= opc[i]; } printf("\r\nAK: "); for (i = 0; i < 6; i++) { ak[i] = out2[i]; printf("%02x", ak[i]); } printf("\r\nRES: "); for (i = 8; i < 16; i++) { sprintf(&response_arr[(i-8)*2], "%02x", out2[i]); printf("%02x", out2[i]); } }
void f1(u8* keyArr, u8* mrand) { printf("\nSQN: "); for (i = 0; i < 6; i++) { printf("%02x", sqn[i]); } printf("\nAMF: "); for (i = 0; i < 2; i++) { printf("%02x", amf[i]); } // create IN1 for (i = 0; i < 6; i++) { in1[i] = sqn[i]; in1[i + 8] = sqn[i]; } for (i = 0; i < 2; i++) { in1[i + 6] = amf[i]; in1[i + 14] = amf[i]; } printf("\nRAND: "); for (i = 0; i < 16; i++) { printf("%02x", mrand[i]); } for (i = 0; i < 16; i++) { toEncrypt[i] = mrand[i] ^ opc[i]; } encrypt(toEncrypt, keyArr, temp); for (i = 0; i < 16; i++) { out1[i] = in1[i]^opc[i]; } convertToBin(out1, binArr); rotWord(binArr, 128, 0x1F); convertToHex(binArr, out1); for (i = 0; i < 16; i++) { out1[i] ^= temp[i]^c1[i]; } encrypt(out1, keyArr, out1); for (i = 0; i < 16; i++) { out1[i] ^= opc[i]; } printf("\nMAC-A: "); for (i = 0; i < 8; i++) { printf("%02x", out1[i]); } printf("\nMAC-S: "); for (i = 8; i < 16; i++) { printf("%02x", out1[i]); } }
void f5star(u8* keyArr, u8* sqn_ak) { u8* out5; out5 = malloc(16); for (i = 0; i < 16; i++) { out5[i] = temp[i] ^ opc[i]; } convertToBin(out5, binArr); rotWord(binArr, 128, 0x08); convertToHex(binArr, out5); for (i = 0; i < 16; i++) { out5[i] ^= c5[i]; } encrypt(out5, keyArr, out5); for (i = 0; i < 16; i++) { out5[i] ^= opc[i]; } printf("\r\nAK (f5*): "); for (i = 0; i < 6; i++) { ak[i] = out5[i]; printf("%02x", ak[i]); } for (i = 0; i < 6; i++) { sqn[i] = ak[i] ^ sqn_ak[i]; } u8 ind = (sqn[5] & 0b00011111); u8 seq = (sqn[5] & 0b11100000); ind = (ind + 1) % 32; sqn[5] = 0; sqn[5] |= ind; seq += 0b00100000; if (seq == 0) { sqn[4] += 1; } sqn[5] |= seq; }