+static int l_iso14443b_crc(lua_State *L)
+{
+ /* void ComputeCrc14443(int CrcType,
+ const unsigned char *Data, int Length,
+ unsigned char *TransmitFirst,
+ unsigned char *TransmitSecond)
+ */
+ size_t size = 0;
+ const char *data = luaL_checklstring(L, 1, &size);
+
+ unsigned char buf[USB_CMD_DATA_SIZE] = {0x00};
+
+ for (int i = 0; i < size; i += 2)
+ sscanf(&data[i], "%02x", (unsigned int *)&buf[i / 2]);
+
+ size /= 2;
+ ComputeCrc14443(CRC_14443_B, buf, size, &buf[size], &buf[size+1]);
+ lua_pushlstring(L, (const char *)&buf, size+2);
+ return 1;
+}
+