added login function

This commit is contained in:
tharexde
2020-09-27 23:22:51 +02:00
parent ab8b5814b0
commit 2e5cf12d7d
7 changed files with 88 additions and 25 deletions

View File

@@ -1041,6 +1041,10 @@ static void PacketReceived(PacketCommandNG *packet) {
em4x50_brute((em4x50_data_t *)packet->data.asBytes);
break;
}
case CMD_LF_EM4X50_LOGIN: {
em4x50_login((em4x50_data_t *)packet->data.asBytes);
break;
}
#endif
#ifdef WITH_ISO15693

View File

@@ -1184,3 +1184,30 @@ void em4x50_brute(em4x50_data_t *etd) {
lf_finalize();
reply_ng(CMD_ACK, bsuccess, (uint8_t *)(&pwd), 32);
}
void em4x50_login(em4x50_data_t *etd) {
// login into EM4x50
uint8_t status = 0;
uint8_t bytes[4] = {0x0, 0x0, 0x0, 0x0};
uint32_t rpwd = 0x0;
em4x50_setup_read();
// set gHigh and gLow
if (get_signalproperties() && find_em4x50_tag()) {
// lsb -> msb
rpwd = reflect32(etd->login_password);
// convert to "old" data format
for (int i = 0; i < 4; i++)
bytes[i] = (rpwd >> ((3 - i) * 8)) & 0xFF;
status = login(bytes);
}
lf_finalize();
reply_ng(CMD_ACK, status, 0, 0);
}

View File

@@ -27,5 +27,6 @@ void em4x50_write_password(em4x50_data_t *etd);
void em4x50_read(em4x50_data_t *etd);
void em4x50_wipe(em4x50_data_t *etd);
void em4x50_brute(em4x50_data_t *etd);
void em4x50_login(em4x50_data_t *etd);
#endif /* EM4X50_H */