From 315a71e268d6e8bf4f6dfe580c10ff0eefcad223 Mon Sep 17 00:00:00 2001 From: whowechina Date: Wed, 13 Mar 2024 20:34:30 +0800 Subject: [PATCH] "Optimize" FeliCa following Bottersnike's advice --- Production/Firmware/aic_pico.uf2 | Bin 121344 -> 119296 bytes README.md | 2 +- README_CN.md | 2 +- firmware/src/aime.c | 198 ++----------------------------- 4 files changed, 14 insertions(+), 188 deletions(-) diff --git a/Production/Firmware/aic_pico.uf2 b/Production/Firmware/aic_pico.uf2 index 925c85e862b99b672517988b8a50f82c69647fd4..476589bbf984f0cb0bc1f493126999770902212f 100644 GIT binary patch delta 15104 zcmbt*4Rlk*w*SmYnx-Ft(3Fyvw48hZfmR4@g<7~+3Wl^PwUmmb7qNVZ5h?~mOaW;@ z#KJ`{GRUbF6#>11=)VF*REkv*vGRDSU#|*cQLaI+a*tOoP1B@#dvfw|j_bbr)?5Fs zwR2`>@7epe_nw(EXU=KkvG~RV@jJBm$2Zc082?DpnQs-1=aBlqxuXM2MyN$Tx#0k` zbRfjCI>gGaA~iyCmQtv!hB77ibIwe#DR@%=%|uA~3+jO;H|;Zj3SytALh2z3q;9(d zsqdVNkOEa!yn3{DPV>h|P0L$!GG=eMTxHnz++irkLHnh9uFD+qt4F_-7l+^|@|d1> zQm!ym_p}3&wntl+Te0D*Or;aE3H+~K`g_DHYentqw!|`|XHgRWogbOyZp6C=Xl=hA zvzTAt_pwM{gk=0nfxmfrvJvZU+te!KHw=)o3Ins#fAnWX4qosh_%Jv4rz@8{N~7Mj z2%Jga*Y&d~!JtP8mU#Z@{+Abe7Jlz(JcZQeOvDxy4@Ta$^VXTx#x~3k@>2Pk{m889 z!qi-`k~jM>U*tysp}(K3QO>Q(?mz1pgPtm?apC-J(`%f+csi`xL0#P~h;_DY0Zcyy zl2IJOJnwt47=NW`b+*H`>y_fZ?)$COm*#*OxcdWC>CV8IvNQvyKaVdGe}b+d;=mY0 zeZLM+JZ>Wzi!_~@4`iLP4^o=UD5DX;1hQR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nsNqc;JH0Zv9baRR5>Ca(F}oA4=)eo3SS&cle7 zixMp_;X00g37a^2GaQ@rfe&#Hha>NIkt)ibi_~}EaEnlXQ9JZZeARdHlSOjz(0=!6 zq%MW)CtcTkXp{T@KsD-V|A9%K?}KBw-C)fBKZ=cjhmypp8bn3_DXDeP+hjepjhcbRiQa=Dv!1H@u*L`r^+SOhI*YRC# z`zz1}vH%fzLjAj*h3-YynPDLX2;JX~)W5?1Ys?O$etjoWZ+~3~&8;`#IZ(_lr2Y{o zW{>bZ{Vk-f+Kto`feL}h{l8MEs?wZ744tAF`a%A4prdbb)vsYaMLXYn?KM0XvnB|b z7x&~;yF~*XkaD@5^;n%~zYKFa1wWi2SD*~QK75%wQ;%nGbb}CVVf(*V)St68;1k^L zowzT@?8L#}GIE|jN;0w&|C!Uhfk%dn=2ZJ70B-;Qy$cj{%|x2N3r_uA

MyMWl9% z%{VMU*-iL+1wQ9FBC%jE;qAjE!OwT{`F%yua7ChFACcNG*3cx;u%GY`M);a91(Yu( zCKm9{f~mD2#lNd>QB!Aku5Q zj$3;Q4@sYP0W<+Afp)^XLkV!r0D@n{sx23|FHXU#SN{R-OTAOZm41NJLj#4mEhOU)XQB_efMBy~@ax+jskjQ47vh06KX d4wLxrkop^_!oe~Kdata; - - if (virtual_aic.active) { - memcpy(poll_resp->pmm, virtual_aic.pmm, 8); - memcpy(poll_resp->syscode, virtual_aic.syscode, 2); - } else { - memcpy(poll_resp->pmm, card->pmm, 8); - memcpy(poll_resp->syscode, card->syscode, 2); - } - - return sizeof(*poll_resp); -} - -static int cmd_felica_get_syscode(const nfc_card_t *card) -{ - felica_resp_t *felica_resp = (felica_resp_t *) response.payload; - felica_resp->data[0] = 0x01; - if (virtual_aic.active) { - memcpy(felica_resp->data, virtual_aic.syscode, 2); - } else { - felica_resp->data[1] = card->syscode[0]; - felica_resp->data[2] = card->syscode[1]; - } - return 3; -} - -static int cmd_felica_read() -{ - uint8_t *req_data = request.felica.data; - - if (req_data[8] != 1) { - printf("\nFelica Encap READ Error: service_num != 1"); - return -1; - } - - uint16_t svc_code = req_data[9] | (req_data[10] << 8); - - typedef struct __attribute__((packed)) { - uint8_t rw_status[2]; - uint8_t block_num; - uint8_t block_data[0][16]; - } encap_read_resp_t; - - felica_resp_t *felica_resp = (felica_resp_t *) response.payload; - encap_read_resp_t *read_resp = (encap_read_resp_t *) felica_resp->data; - - uint8_t *block = req_data + 11; - uint8_t block_num = block[0]; - - memset(read_resp->block_data, 0, block_num * 16); - - for (int i = 0; i < block_num; i++) { - uint16_t block_id = (block[i * 2 + 1] << 8) | block[i * 2 + 2]; - if (virtual_aic.active) { - if (block_id == 0x8082) { - memcpy(read_resp->block_data[i], virtual_aic.idm, 8); - } - } else { - nfc_felica_read_wo_encrypt(svc_code, block_id, read_resp->block_data[i]); - } - } - - read_resp->rw_status[0] = 0x00; - read_resp->rw_status[1] = 0x00; - read_resp->block_num = block_num; - - return sizeof(*read_resp) + block_num * 16; -} - -static int cmd_felica_write() -{ - uint8_t *req_data = request.felica.data; - - if (req_data[8] != 1) { - printf("\nFelica Encap Write Error: service_num != 1"); - return -1; - } - - /* No, we don't actually write */ - - felica_resp_t *felica_resp = (felica_resp_t *) response.payload; - uint8_t *rw_status = felica_resp->data; - - rw_status[0] = 0x00; - rw_status[1] = 0x00; - return 2; - -} - -#if 0 - - case CMD_FELICA_OP_NDA_A4: - printf("\tNDA_A4\n"); - build_response(11); - resp->payload[0] = 0x00; - break; - default: - printf("\tUnknown through: %02x\n", code); - build_response(0); - response.status = STATUS_OK; -#endif - static void cmd_felica() { - nfc_card_t card = nfc_poll_felica(); - if ((card.card_type != NFC_CARD_FELICA) && (!virtual_aic.active)) { - send_simple_response(STATUS_FELICA_ERROR); - return; - } - - uint8_t felica_op = request.felica.code; - - int datalen = -1; - switch (felica_op) { - case CMD_FELICA_OP_GET_SYSTEM_CODE: - datalen = cmd_felica_get_syscode(&card); - break; - case CMD_FELICA_OP_POLL: - datalen = cmd_felica_poll(&card); - break; - case CMD_FELICA_OP_READ: - datalen = cmd_felica_read(); - break; - case CMD_FELICA_OP_WRITE: - datalen = cmd_felica_write(); - break; - default: - printf("\nUnknown code %d", felica_op); - break; - } - - if (datalen < 0) { - send_simple_response(STATUS_FELICA_ERROR); - return; - } - - felica_resp_t *felica_resp = (felica_resp_t *) response.payload; - build_response(sizeof(*felica_resp) + datalen); - felica_resp->len = response.payload_len; - felica_resp->code = felica_op + 1; - if (virtual_aic.active) { - memcpy(felica_resp->idm, virtual_aic.idm, 8); - } else { - memcpy(felica_resp->idm, card.idm, 8); - } - - send_response(); - -/* - printf("Felica Response:"); - for (int i = 0; i < felica_resp->len - 10; i++) { - printf(" %02x", felica_resp->data[i]); - } - printf("\n"); -*/ + send_simple_response(STATUS_INVALID_COMMAND); + return; } static uint32_t led_color; @@ -552,6 +376,8 @@ static void aime_handle_frame() case CMD_CARD_DETECT: cmd_detect_card(); break; + + case CMD_FELICA_PUSH: case CMD_FELICA_OP: cmd_felica(); break;