Files
Momentum-Firmware/lib/nfc/protocols/slix.c
g3gg0 75f5e6604b separate ISO15693 basic and SLIX extensions a bit more
changed save format to reflect this
executing emulation from browser now also works
2022-11-17 01:35:39 +01:00

102 lines
2.3 KiB
C

#include <limits.h>
#include "nfcv.h"
#include "slix.h"
#include "nfc_util.h"
#include <furi.h>
#include "furi_hal_nfc.h"
bool slix_check_card_type(FuriHalNfcDevData* nfc_data) {
if((nfc_data->uid[0] == 0xE0)
&& (nfc_data->uid[1] == 0x04)
&& (nfc_data->uid[2] == 0x01)
&& (((nfc_data->uid[3] >> 4) & 3) == 2)) {
return true;
}
return false;
}
bool slix2_check_card_type(FuriHalNfcDevData* nfc_data) {
if((nfc_data->uid[0] == 0xE0)
&& (nfc_data->uid[1] == 0x04)
&& (nfc_data->uid[2] == 0x01)
&& (((nfc_data->uid[3] >> 4) & 3) == 1)) {
return true;
}
return false;
}
bool slix_s_check_card_type(FuriHalNfcDevData* nfc_data) {
if((nfc_data->uid[0] == 0xE0)
&& (nfc_data->uid[1] == 0x04)
&& (nfc_data->uid[2] == 0x02)) {
return true;
}
return false;
}
bool slix_l_check_card_type(FuriHalNfcDevData* nfc_data) {
if((nfc_data->uid[0] == 0xE0)
&& (nfc_data->uid[1] == 0x04)
&& (nfc_data->uid[2] == 0x03)) {
return true;
}
return false;
}
ReturnCode slix_l_get_random(uint8_t* rand) {
uint16_t received = 0;
uint8_t rxBuf[32];
ReturnCode ret = rfalNfcvPollerTransceiveReq(
ISO15693_CMD_NXP_GET_RANDOM_NUMBER,
RFAL_NFCV_REQ_FLAG_DEFAULT,
ISO15693_MANUFACTURER_NXP,
NULL,
NULL,
0,
rxBuf,
sizeof(rxBuf),
&received);
if(ret == ERR_NONE) {
if(received != 3) {
return ERR_PROTO;
}
if(rand != NULL) {
memcpy(rand, &rxBuf[1], 2);
}
}
return ret;
}
ReturnCode slix_l_unlock(uint32_t id, uint8_t* rand, uint32_t password) {
furi_assert(rand);
uint16_t received = 0;
uint8_t rxBuf[32];
uint8_t cmd_set_pass[] = {
id,
rand[0] ^ ((password >> 0) & 0xFF),
rand[1] ^ ((password >> 8) & 0xFF),
rand[0] ^ ((password >> 16) & 0xFF),
rand[1] ^ ((password >> 24) & 0xFF)
};
ReturnCode ret = rfalNfcvPollerTransceiveReq(
ISO15693_CMD_NXP_SET_PASSWORD,
RFAL_NFCV_REQ_FLAG_DATA_RATE,
ISO15693_MANUFACTURER_NXP,
NULL,
cmd_set_pass,
sizeof(cmd_set_pass),
rxBuf,
sizeof(rxBuf),
&received);
return ret;
}