Skip to content

Commit

Permalink
tabs to 4 spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
doegox committed Aug 22, 2023
1 parent e43e668 commit 37c99ce
Show file tree
Hide file tree
Showing 28 changed files with 3,046 additions and 3,046 deletions.
204 changes: 102 additions & 102 deletions firmware/application/src/app_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,129 +179,129 @@ data_frame_tx_t* cmd_processor_detect_mf1_darkside(uint16_t cmd, uint16_t status

data_frame_tx_t* cmd_processor_mf1_darkside_acquire(uint16_t cmd, uint16_t status, uint16_t length, uint8_t *data) {
DarksideCore dc;
if (length == 4) {
status = Darkside_Recover_Key(data[1], data[0], data[2], data[3], &dc);
if (status == HF_TAG_OK) {
length = sizeof(DarksideCore);
data = (uint8_t *)(&dc);
} else {
length = 0;
}
} else {
status = STATUS_PAR_ERR;
length = 0;
}
if (length == 4) {
status = Darkside_Recover_Key(data[1], data[0], data[2], data[3], &dc);
if (status == HF_TAG_OK) {
length = sizeof(DarksideCore);
data = (uint8_t *)(&dc);
} else {
length = 0;
}
} else {
status = STATUS_PAR_ERR;
length = 0;
}
return data_frame_make(cmd, status, length, data);
}

data_frame_tx_t* cmd_processor_detect_nested_dist(uint16_t cmd, uint16_t status, uint16_t length, uint8_t *data) {
NestedDist nd;
if (length == 8) {
status = Nested_Distacne_Detect(data[1], data[0], &data[2], &nd);
if (status == HF_TAG_OK) {
length = sizeof(NestedDist);
data = (uint8_t *)(&nd);
} else {
length = 0;
}
} else {
status = STATUS_PAR_ERR;
length = 0;
}
if (length == 8) {
status = Nested_Distacne_Detect(data[1], data[0], &data[2], &nd);
if (status == HF_TAG_OK) {
length = sizeof(NestedDist);
data = (uint8_t *)(&nd);
} else {
length = 0;
}
} else {
status = STATUS_PAR_ERR;
length = 0;
}
return data_frame_make(cmd, status, 0, NULL);
}

data_frame_tx_t* cmd_processor_mf1_nt_distance(uint16_t cmd, uint16_t status, uint16_t length, uint8_t *data) {
NestedDist nd;
if (length == 8) {
status = Nested_Distacne_Detect(data[1], data[0], &data[2], &nd);
if (status == HF_TAG_OK) {
length = sizeof(NestedDist);
data = (uint8_t *)(&nd);
} else {
length = 0;
}
} else {
status = STATUS_PAR_ERR;
length = 0;
}
if (length == 8) {
status = Nested_Distacne_Detect(data[1], data[0], &data[2], &nd);
if (status == HF_TAG_OK) {
length = sizeof(NestedDist);
data = (uint8_t *)(&nd);
} else {
length = 0;
}
} else {
status = STATUS_PAR_ERR;
length = 0;
}
return data_frame_make(cmd, status, length, data);
}

data_frame_tx_t* cmd_processor_mf1_nested_acquire(uint16_t cmd, uint16_t status, uint16_t length, uint8_t *data) {
NestedCore ncs[SETS_NR];
if (length == 10) {
status = Nested_Recover_Key(bytes_to_num(&data[2], 6), data[1], data[0], data[9], data[8], ncs);
if (status == HF_TAG_OK) {
length = sizeof(ncs);
data = (uint8_t *)(&ncs);
} else {
length = 0;
}
} else {
status = STATUS_PAR_ERR;
length = 0;
}
if (length == 10) {
status = Nested_Recover_Key(bytes_to_num(&data[2], 6), data[1], data[0], data[9], data[8], ncs);
if (status == HF_TAG_OK) {
length = sizeof(ncs);
data = (uint8_t *)(&ncs);
} else {
length = 0;
}
} else {
status = STATUS_PAR_ERR;
length = 0;
}
return data_frame_make(cmd, status, length, data);
}

data_frame_tx_t* cmd_processor_mf1_auth_one_key_block(uint16_t cmd, uint16_t status, uint16_t length, uint8_t *data) {
if (length == 8) {
status = auth_key_use_522_hw(data[1], data[0], &data[2]);
status = auth_key_use_522_hw(data[1], data[0], &data[2]);
pcd_14a_reader_mf1_unauth();
} else {
status = STATUS_PAR_ERR;
}
} else {
status = STATUS_PAR_ERR;
}
return data_frame_make(cmd, status, 0, NULL);
}

data_frame_tx_t* cmd_processor_mf1_read_one_block(uint16_t cmd, uint16_t status, uint16_t length, uint8_t *data) {
uint8_t block[16] = { 0x00 };
if (length == 8) {
status = auth_key_use_522_hw(data[1], data[0], &data[2]);
if (status == HF_TAG_OK) {
status = pcd_14a_reader_mf1_read(data[1], block);
if (status == HF_TAG_OK) {
length = 16;
} else {
length = 0;
}
} else {
length = 0;
}
} else {
length = 0;
status = STATUS_PAR_ERR;
}
if (length == 8) {
status = auth_key_use_522_hw(data[1], data[0], &data[2]);
if (status == HF_TAG_OK) {
status = pcd_14a_reader_mf1_read(data[1], block);
if (status == HF_TAG_OK) {
length = 16;
} else {
length = 0;
}
} else {
length = 0;
}
} else {
length = 0;
status = STATUS_PAR_ERR;
}
return data_frame_make(cmd, status, length, block);
}

data_frame_tx_t* cmd_processor_mf1_write_one_block(uint16_t cmd, uint16_t status, uint16_t length, uint8_t *data) {
if (length == 24) {
status = auth_key_use_522_hw(data[1], data[0], &data[2]);
if (status == HF_TAG_OK) {
status = pcd_14a_reader_mf1_write(data[1], &data[8]);
} else {
length = 0;
}
} else {
status = STATUS_PAR_ERR;
}
status = auth_key_use_522_hw(data[1], data[0], &data[2]);
if (status == HF_TAG_OK) {
status = pcd_14a_reader_mf1_write(data[1], &data[8]);
} else {
length = 0;
}
} else {
status = STATUS_PAR_ERR;
}
return data_frame_make(cmd, status, 0, NULL);
}

data_frame_tx_t* cmd_processor_em410x_scan(uint16_t cmd, uint16_t status, uint16_t length, uint8_t *data) {
uint8_t id_buffer[5] = { 0x00 };
status = PcdScanEM410X(id_buffer);
status = PcdScanEM410X(id_buffer);
return data_frame_make(cmd, status, sizeof(id_buffer), id_buffer);
}

data_frame_tx_t* cmd_processor_write_em410x_2_t57(uint16_t cmd, uint16_t status, uint16_t length, uint8_t *data) {
if (length >= 13 && (length - 9) % 4 == 0) {
status = PcdWriteT55XX(data, data + 5, data + 9, (length - 9) / 4);
} else {
status = STATUS_PAR_ERR;
}
if (length >= 13 && (length - 9) % 4 == 0) {
status = PcdWriteT55XX(data, data + 5, data + 9, (length - 9) / 4);
} else {
status = STATUS_PAR_ERR;
}
return data_frame_make(cmd, status, 0, NULL);
}

Expand All @@ -319,7 +319,7 @@ data_frame_tx_t* cmd_processor_set_slot_activated(uint16_t cmd, uint16_t status,
if (length == 1 && data[0] < TAG_MAX_SLOT_NUM) {
change_slot_auto(data[0]);
status = STATUS_DEVICE_SUCCESS;
} else {
} else {
status = STATUS_PAR_ERR;
}
return data_frame_make(cmd, status, 0, NULL);
Expand All @@ -330,8 +330,8 @@ data_frame_tx_t* cmd_processor_set_slot_tag_type(uint16_t cmd, uint16_t status,
uint8_t num_slot = data[0];
uint8_t tag_type = data[1];
tag_emulation_change_type(num_slot, (tag_specific_type_t)tag_type);
status = STATUS_DEVICE_SUCCESS;
} else {
status = STATUS_DEVICE_SUCCESS;
} else {
status = STATUS_PAR_ERR;
}
return data_frame_make(cmd, status, 0, NULL);
Expand All @@ -354,7 +354,7 @@ data_frame_tx_t* cmd_processor_set_slot_data_default(uint16_t cmd, uint16_t stat
uint8_t num_slot = data[0];
uint8_t tag_type = data[1];
status = tag_emulation_factory_data(num_slot, (tag_specific_type_t)tag_type) ? STATUS_DEVICE_SUCCESS : STATUS_NOT_IMPLEMENTED;
} else {
} else {
status = STATUS_PAR_ERR;
}
return data_frame_make(cmd, status, 0, NULL);
Expand All @@ -375,7 +375,7 @@ data_frame_tx_t* cmd_processor_set_slot_enable(uint16_t cmd, uint16_t status, ui
}
}
status = STATUS_DEVICE_SUCCESS;
} else {
} else {
status = STATUS_PAR_ERR;
}
return data_frame_make(cmd, status, 0, NULL);
Expand Down Expand Up @@ -416,7 +416,7 @@ data_frame_tx_t* cmd_processor_set_em410x_emu_id(uint16_t cmd, uint16_t status,
memcpy(buffer->buffer, data, LF_EM410X_TAG_ID_SIZE);
tag_emulation_load_by_buffer(TAG_TYPE_EM410X, false);
status = STATUS_DEVICE_SUCCESS;
} else {
} else {
status = STATUS_PAR_ERR;
}
return data_frame_make(cmd, status, 0, NULL);
Expand All @@ -435,7 +435,7 @@ data_frame_tx_t* cmd_processor_set_mf1_detection_enable(uint16_t cmd, uint16_t s
nfc_tag_mf1_detection_log_clear();
nfc_tag_mf1_set_detection_enable(data[0]);
status = STATUS_DEVICE_SUCCESS;
} else {
} else {
status = STATUS_PAR_ERR;
}
return data_frame_make(cmd, status, 0, NULL);
Expand Down Expand Up @@ -640,7 +640,7 @@ data_frame_tx_t* cmd_processor_set_mf1_gen1a_magic_mode(uint16_t cmd, uint16_t s
if (length == 1 && (data[0] == 0 || data[0] == 1)) {
nfc_tag_mf1_set_gen1a_magic_mode(data[0]);
status = STATUS_DEVICE_SUCCESS;
} else {
} else {
status = STATUS_PAR_ERR;
}
return data_frame_make(cmd, status, 0, NULL);
Expand All @@ -659,7 +659,7 @@ data_frame_tx_t* cmd_processor_set_mf1_gen2_magic_mode(uint16_t cmd, uint16_t st
if (length == 1 && (data[0] == 0 || data[0] == 1)) {
nfc_tag_mf1_set_gen2_magic_mode(data[0]);
status = STATUS_DEVICE_SUCCESS;
} else {
} else {
status = STATUS_PAR_ERR;
}
return data_frame_make(cmd, status, 0, NULL);
Expand All @@ -678,7 +678,7 @@ data_frame_tx_t* cmd_processor_set_mf1_use_coll_res(uint16_t cmd, uint16_t statu
if (length == 1 && (data[0] == 0 || data[0] == 1)) {
nfc_tag_mf1_set_use_mf1_coll_res(data[0]);
status = STATUS_DEVICE_SUCCESS;
} else {
} else {
status = STATUS_PAR_ERR;
}
return data_frame_make(cmd, status, 0, NULL);
Expand Down Expand Up @@ -711,7 +711,7 @@ data_frame_tx_t* cmd_processor_set_mf1_write_mode(uint16_t cmd, uint16_t status,
nfc_tag_mf1_set_write_mode(NFC_TAG_MF1_WRITE_SHADOW);
}
status = STATUS_DEVICE_SUCCESS;
} else {
} else {
status = STATUS_PAR_ERR;
}
return data_frame_make(cmd, status, 0, NULL);
Expand Down Expand Up @@ -851,15 +851,15 @@ static cmd_data_map_t m_data_cmd_map[] = {
* @param resp data
*/
void auto_response_data(data_frame_tx_t* resp) {
// TODO Please select the reply source automatically according to the message source,
// TODO Please select the reply source automatically according to the message source,
// and do not reply by checking the validity of the link layer by layer
if (is_usb_working()) {
usb_cdc_write(resp->buffer, resp->length);
} else if (is_nus_working()) {
nus_data_reponse(resp->buffer, resp->length);
} else {
NRF_LOG_ERROR("No connection valid found at response client.");
}
if (is_usb_working()) {
usb_cdc_write(resp->buffer, resp->length);
} else if (is_nus_working()) {
nus_data_reponse(resp->buffer, resp->length);
} else {
NRF_LOG_ERROR("No connection valid found at response client.");
}
}


Expand Down
4 changes: 2 additions & 2 deletions firmware/application/src/app_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,11 +494,11 @@ static void offline_status_blink_color(uint8_t blink_color) {
}

static void offline_status_error(void) {
offline_status_blink_color(0);
offline_status_blink_color(0);
}

static void offline_status_ok(void) {
offline_status_blink_color(1);
offline_status_blink_color(1);
}

// fast detect a 14a tag uid to sim
Expand Down
34 changes: 17 additions & 17 deletions firmware/application/src/app_status.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,38 @@
/////////////////////////////////////////////////////////////////////
// 14a status
/////////////////////////////////////////////////////////////////////
#define HF_TAG_OK (0x00) // IC卡操作成功
#define HF_TAG_NO (0x01) // 没有发现IC卡
#define HF_ERRSTAT (0x02) // IC卡通信异常
#define HF_ERRCRC (0x03) // IC卡通信校验异常
#define HF_COLLISION (0x04) // IC卡冲突
#define HF_ERRBCC (0x05) // IC卡BCC错误
#define MF_ERRAUTH (0x06) // MF卡验证失败
#define HF_ERRPARITY (0x07) // IC卡奇偶校验错误
#define HF_TAG_OK (0x00) // IC卡操作成功
#define HF_TAG_NO (0x01) // 没有发现IC卡
#define HF_ERRSTAT (0x02) // IC卡通信异常
#define HF_ERRCRC (0x03) // IC卡通信校验异常
#define HF_COLLISION (0x04) // IC卡冲突
#define HF_ERRBCC (0x05) // IC卡BCC错误
#define MF_ERRAUTH (0x06) // MF卡验证失败
#define HF_ERRPARITY (0x07) // IC卡奇偶校验错误


/////////////////////////////////////////////////////////////////////
// MIFARE status
/////////////////////////////////////////////////////////////////////
#define DARKSIDE_CANT_FIXED_NT (0x20) // Darkside,无法固定随机数,这个情况可能出现在UID卡上
#define DARKSIDE_LUCK_AUTH_OK (0x21) // Darkside,直接验证成功了,可能刚好密钥是空的
#define DARKSIDE_NACK_NO_SEND (0x22) // Darkside,卡片不响应nack,可能是一张修复了nack逻辑漏洞的卡片
#define DARKSIDE_TAG_CHANGED (0x23) // Darkside,在运行darkside的过程中出现了卡片切换,可能信号问题,或者真的是两张卡迅速切换了
#define NESTED_TAG_IS_STATIC (0x24) // Nested,检测到卡片应答的随机数是固定的
#define NESTED_TAG_IS_HARD (0x25) // Nested,检测到卡片应答的随机数是不可预测的
#define DARKSIDE_CANT_FIXED_NT (0x20) // Darkside,无法固定随机数,这个情况可能出现在UID卡上
#define DARKSIDE_LUCK_AUTH_OK (0x21) // Darkside,直接验证成功了,可能刚好密钥是空的
#define DARKSIDE_NACK_NO_SEND (0x22) // Darkside,卡片不响应nack,可能是一张修复了nack逻辑漏洞的卡片
#define DARKSIDE_TAG_CHANGED (0x23) // Darkside,在运行darkside的过程中出现了卡片切换,可能信号问题,或者真的是两张卡迅速切换了
#define NESTED_TAG_IS_STATIC (0x24) // Nested,检测到卡片应答的随机数是固定的
#define NESTED_TAG_IS_HARD (0x25) // Nested,检测到卡片应答的随机数是不可预测的


/////////////////////////////////////////////////////////////////////
// lf status
/////////////////////////////////////////////////////////////////////
#define LF_TAG_OK (0x40) // 低频卡的一些操作成功!
#define EM410X_TAG_NO_FOUND (0x41) // 无法搜索到有效的EM410X标签
#define LF_TAG_OK (0x40) // 低频卡的一些操作成功!
#define EM410X_TAG_NO_FOUND (0x41) // 无法搜索到有效的EM410X标签


/////////////////////////////////////////////////////////////////////
// other status
/////////////////////////////////////////////////////////////////////
#define STATUS_PAR_ERR (0x60) // BLE指令传递的参数错误,或者是调用某些函数传递的参数错误
#define STATUS_PAR_ERR (0x60) // BLE指令传递的参数错误,或者是调用某些函数传递的参数错误
#define STATUS_DEVIEC_MODE_ERROR (0x66) // 当前设备所处的模式错误,无法调用对应的API
#define STATUS_INVALID_CMD (0x67) // 无效的指令
#define STATUS_DEVICE_SUCCESS (0x68) // 设备相关操作成功执行
Expand Down
Loading

0 comments on commit 37c99ce

Please sign in to comment.