mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
if no carrier clear former authentication
This commit is contained in:
parent
a931cea2f6
commit
6b6f104d9a
1 changed files with 17 additions and 26 deletions
|
@ -78,6 +78,7 @@ static void wait_timer(uint32_t period) {
|
|||
while (AT91C_BASE_TC0->TC_CV < period);
|
||||
}
|
||||
|
||||
|
||||
// extract and check parities
|
||||
// return result of parity check and extracted plain data
|
||||
static bool extract_parities(uint64_t word, uint32_t *data) {
|
||||
|
@ -177,17 +178,9 @@ static void em4x50_setup_read(void) {
|
|||
}
|
||||
|
||||
static void em4x50_setup_sim(void) {
|
||||
StopTicks();
|
||||
|
||||
FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
|
||||
|
||||
sample_config *sc = getSamplingConfig();
|
||||
sc->decimation = 1;
|
||||
sc->averaging = 0;
|
||||
sc->divisor = LF_DIVISOR_125;
|
||||
|
||||
FpgaSendCommand(FPGA_CMD_SET_DIVISOR, sc->divisor);
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_EDGE_DETECT);
|
||||
FpgaSendCommand(FPGA_CMD_SET_DIVISOR, LF_DIVISOR_125);
|
||||
|
||||
AT91C_BASE_PIOA->PIO_PER = GPIO_SSC_DOUT | GPIO_SSC_CLK;
|
||||
AT91C_BASE_PIOA->PIO_OER = GPIO_SSC_DOUT;
|
||||
|
@ -463,6 +456,7 @@ static int find_double_listen_window(bool bcommand) {
|
|||
// send RM for request mode
|
||||
em4x50_reader_send_bit(0);
|
||||
em4x50_reader_send_bit(0);
|
||||
|
||||
LED_B_OFF();
|
||||
|
||||
return PM3_SUCCESS;
|
||||
|
@ -661,12 +655,11 @@ static bool login(uint32_t password) {
|
|||
// send password
|
||||
em4x50_reader_send_word(password);
|
||||
|
||||
wait_timer(T0 * (EM4X50_T_TAG_TPP));
|
||||
wait_timer(T0 * EM4X50_T_TAG_TPP);
|
||||
|
||||
// check if ACK is returned
|
||||
if (check_ack(false)) {
|
||||
if (check_ack(false))
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
} else {
|
||||
if (DBGLEVEL >= DBG_DEBUG)
|
||||
|
@ -941,7 +934,6 @@ void em4x50_reader(void) {
|
|||
|
||||
LOW(GPIO_SSC_DOUT);
|
||||
lf_finalize();
|
||||
|
||||
reply_ng(CMD_LF_EM4X50_READER, now, (uint8_t *)words, 4 * now);
|
||||
}
|
||||
|
||||
|
@ -970,17 +962,16 @@ static int write(uint32_t word, uint32_t addresses) {
|
|||
// look for ACK sequence
|
||||
if (check_ack(false)) {
|
||||
|
||||
// now EM4x50 needs T0 * EM4X50_T_TAG_TWEE (EEPROM write time)
|
||||
// now EM4x50 needs T0 * EM4X50_T_TAG_TWEE (EEPROM write time = 3.2ms = 50 * 64 periods)
|
||||
// for saving data and should return with ACK
|
||||
for (int i = 0; i < 50; i++) {
|
||||
wait_timer(T0 * EM4X50_T_TAG_FULL_PERIOD);
|
||||
}
|
||||
|
||||
if (check_ack(false)) {
|
||||
if (check_ack(false))
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (DBGLEVEL >= DBG_DEBUG)
|
||||
Dbprintf("error in command request");
|
||||
|
@ -1019,18 +1010,17 @@ static int write_password(uint32_t password, uint32_t new_password) {
|
|||
|
||||
if (check_ack(false)) {
|
||||
|
||||
// now EM4x50 needs T0 * EM4X50_T_TAG_TWEE (EEPROM write time)
|
||||
// now EM4x50 needs T0 * EM4X50_T_TAG_TWEE (EEPROM write time = 3.2ms = 50 * 64 periods)
|
||||
// for saving data and should return with ACK
|
||||
for (int i = 0; i < 50; i++) {
|
||||
wait_timer(T0 * EM4X50_T_TAG_FULL_PERIOD);
|
||||
}
|
||||
|
||||
if (check_ack(false)) {
|
||||
if (check_ack(false))
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (DBGLEVEL >= DBG_DEBUG)
|
||||
Dbprintf("error in command request");
|
||||
|
@ -1425,8 +1415,6 @@ static void em4x50_sim_send_nak(void) {
|
|||
|
||||
SHORT_COIL();
|
||||
wait_cycles(EM4X50_T_TAG_HALF_PERIOD);
|
||||
|
||||
OPEN_COIL();
|
||||
}
|
||||
|
||||
// standard read mode process (simulation mode)
|
||||
|
@ -1821,9 +1809,12 @@ void em4x50_sim(uint32_t *password) {
|
|||
break;
|
||||
}
|
||||
|
||||
// if timeout (e.g. no reader field) continue with standard read mode
|
||||
// if timeout (e.g. no reader field) continue with standard read
|
||||
// mode and reset former authentication
|
||||
if (command == PM3_ETIMEOUT) {
|
||||
command = EM4X50_COMMAND_STANDARD_READ;
|
||||
gLogin = false;
|
||||
LED_A_OFF();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue