- // Do not respond
- // We do not know what to answer, so lets keep quiet
- resp = resp1; respLen = 0; //order = 5;
- respdata = NULL;
- respsize = 0;
- if (breakAfterMacReceived){
- // dbprintf:ing ...
- Dbprintf("CSN: %02x %02x %02x %02x %02x %02x %02x %02x"
- ,csn[0],csn[1],csn[2],csn[3],csn[4],csn[5],csn[6],csn[7]);
- Dbprintf("RDR: (len=%02d): %02x %02x %02x %02x %02x %02x %02x %02x %02x",len,
- receivedCmd[0], receivedCmd[1], receivedCmd[2],
- receivedCmd[3], receivedCmd[4], receivedCmd[5],
- receivedCmd[6], receivedCmd[7], receivedCmd[8]);
- if (reader_mac_buf != NULL)
- {
- memcpy(reader_mac_buf,receivedCmd+1,8);
+ if(simulationMode == MODE_FULLSIM)
+ { //This is what we must do..
+ //Reader just sent us NR and MAC(k,cc * nr)
+ //The diversified key should be stored on block 3
+ //However, from a typical dump, the key will not be there
+ uint8_t *diversified_key = { 0 };
+ //Get the diversified key from emulator memory
+ memcpy(diversified_key, emulator+(8*3),8);
+ uint8_t ccnr[12] = { 0 };
+ //Put our cc there (block 2)
+ memcpy(ccnr, emulator + (8 * 2), 8);
+ //Put nr there
+ memcpy(ccnr+8, receivedCmd+1,4);
+ //Now, calc MAC
+ doMAC(ccnr,diversified_key, trace_data);
+ trace_data_size = 4;
+ CodeIClassTagAnswer(trace_data , trace_data_size);
+ memcpy(data_response, ToSend, ToSendMax);
+ modulated_response = data_response;
+ modulated_response_size = ToSendMax;
+ }else
+ { //Not fullsim, we don't respond
+ // We do not know what to answer, so lets keep quiet
+ modulated_response = resp_sof; modulated_response_size = 0;
+ trace_data = NULL;
+ trace_data_size = 0;
+ if (simulationMode == MODE_EXIT_AFTER_MAC){
+ // dbprintf:ing ...
+ Dbprintf("CSN: %02x %02x %02x %02x %02x %02x %02x %02x"
+ ,csn[0],csn[1],csn[2],csn[3],csn[4],csn[5],csn[6],csn[7]);
+ Dbprintf("RDR: (len=%02d): %02x %02x %02x %02x %02x %02x %02x %02x %02x",len,
+ receivedCmd[0], receivedCmd[1], receivedCmd[2],
+ receivedCmd[3], receivedCmd[4], receivedCmd[5],
+ receivedCmd[6], receivedCmd[7], receivedCmd[8]);
+ if (reader_mac_buf != NULL)
+ {
+ memcpy(reader_mac_buf,receivedCmd+1,8);
+ }
+ exitLoop = true;