+ return (((uint8_t *)BigBuf) + MIFARE_BUFF_OFFSET); // was 3560 - tied to other size changes\r
+}\r
+uint8_t* eml_get_bigbufptr_sendbuf(void) {\r
+ return (((uint8_t *)BigBuf) + RECV_CMD_OFFSET); \r
+}\r
+uint8_t* eml_get_bigbufptr_recbuf(void) {\r
+ return (((uint8_t *)BigBuf) + MIFARE_BUFF_OFFSET);\r
+}\r
+uint8_t* eml_get_bigbufptr_cardmem(void) {\r
+ return (((uint8_t *)BigBuf) + CARD_MEMORY);\r
+}\r
+\r
+// crypto1 helpers\r
+void mf_crypto1_decrypt(struct Crypto1State *pcs, uint8_t *data, int len){\r
+ uint8_t bt = 0;\r
+ int i;\r
+ \r
+ if (len != 1) {\r
+ for (i = 0; i < len; i++)\r
+ data[i] = crypto1_byte(pcs, 0x00, 0) ^ data[i];\r
+ } else {\r
+ bt = 0;\r
+ for (i = 0; i < 4; i++)\r
+ bt |= (crypto1_bit(pcs, 0, 0) ^ BIT(data[0], i)) << i;\r
+ \r
+ data[0] = bt;\r
+ }\r
+ return;\r
+}\r
+\r
+void mf_crypto1_encrypt(struct Crypto1State *pcs, uint8_t *data, int len, uint32_t *par) {\r
+ uint8_t bt = 0;\r
+ int i;\r
+ uint32_t mltpl = 1 << (len - 1); // for len=18 it=0x20000\r
+ *par = 0;\r
+ for (i = 0; i < len; i++) {\r
+ bt = data[i];\r
+ data[i] = crypto1_byte(pcs, 0x00, 0) ^ data[i];\r
+ *par = (*par >> 1) | ( ((filter(pcs->odd) ^ oddparity(bt)) & 0x01) * mltpl );\r
+ } \r
+ return;\r
+}\r
+\r
+uint8_t mf_crypto1_encrypt4bit(struct Crypto1State *pcs, uint8_t data) {\r
+ uint8_t bt = 0;\r
+ int i;\r
+\r
+ for (i = 0; i < 4; i++)\r
+ bt |= (crypto1_bit(pcs, 0, 0) ^ BIT(data, i)) << i;\r
+ \r
+ return bt;\r
+}\r
+\r
+// send commands\r
+int mifare_sendcmd_short(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd, uint8_t data, uint8_t* answer, uint32_t *timing)\r
+{\r
+ return mifare_sendcmd_shortex(pcs, crypted, cmd, data, answer, NULL, timing);\r