Commit graph

1009 commits

Author SHA1 Message Date
Tim Gates
126cf9c1be
docs: fix simple typo, mecanism -> mechanism
There is a small typo in contrib/win32/libnfc/buses/uart.c, libnfc/drivers/acr122_usb.c, libnfc/drivers/acr122s.c, libnfc/drivers/arygon.c, libnfc/drivers/pn532_uart.c, libnfc/drivers/pn53x_usb.c.

Should read `mechanism` rather than `mecanism`.
2020-10-11 07:43:16 +11:00
Unknown
f56bbabf6c easy reading condition 2020-07-08 13:06:45 +02:00
Unknown
7ad18a2120 some cleanings 2020-07-07 19:41:07 +02:00
WangYi
82f23c411d Make it compile under MSVC2017. 2020-07-05 00:54:54 +02:00
hongbin@ftsafe.com
435e2ffc81 Add length check to have compatible with R502
improve the code, to have compatible with OEM R502 firmware.
2020-06-22 14:33:15 +08:00
Feitian Technologies
b02f94d7da
Update pcsc.c
1. Fix bug for Mifare card, before do authentication, need to load PIN/password first
2. Fix bug when to get card ATS
2020-05-28 00:54:20 +08:00
Philippe Teuwen
f02ff51449 Prepare 1.8.0 version 2020-05-22 12:20:17 +02:00
Ludovic Rousseau
63cf0acb0b pcsc: remove unused function pcsc_initiator_deselect_target
pcsc.c:763:12: warning: ‘pcsc_initiator_deselect_target’ defined but not used [-Wunused-function]
 static int pcsc_initiator_deselect_target(struct nfc_device *pnd)
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2020-05-22 10:13:52 +02:00
Ludovic Rousseau
5294c0290f Fix compiler warnings: no previous prototype
Local function should be declared static.

Fix:
pcsc.c:107:1: warning: no previous prototype for ‘pcsc_get_scardcontext’ [-Wmissing-prototypes]
 pcsc_get_scardcontext(void)
 ^~~~~~~~~~~~~~~~~~~~~
pcsc.c:119:1: warning: no previous prototype for ‘pcsc_free_scardcontext’ [-Wmissing-prototypes]
 pcsc_free_scardcontext(void)
 ^~~~~~~~~~~~~~~~~~~~~~
pcsc.c:135:5: warning: no previous prototype for ‘pcsc_transmit’ [-Wmissing-prototypes]
 int pcsc_transmit(struct nfc_device *pnd, const uint8_t *tx, const size_t tx_len, uint8_t *rx, size_t *rx_len)
     ^~~~~~~~~~~~~
pcsc.c:160:5: warning: no previous prototype for ‘pcsc_get_status’ [-Wmissing-prototypes]
 int pcsc_get_status(struct nfc_device *pnd, int *target_present, uint8_t *atr, size_t *atr_len)
     ^~~~~~~~~~~~~~~
pcsc.c:178:5: warning: no previous prototype for ‘pcsc_reconnect’ [-Wmissing-prototypes]
 int pcsc_reconnect(struct nfc_device *pnd, DWORD share_mode, DWORD protocol, DWORD disposition)
     ^~~~~~~~~~~~~~
pcsc.c:194:9: warning: no previous prototype for ‘pcsc_get_icc_type’ [-Wmissing-prototypes]
 uint8_t pcsc_get_icc_type(const struct nfc_device *pnd)
         ^~~~~~~~~~~~~~~~~
pcsc.c:203:6: warning: no previous prototype for ‘is_pcsc_reader_vendor’ [-Wmissing-prototypes]
 bool is_pcsc_reader_vendor(const struct nfc_device *pnd, const char *target_vendor_name)
      ^~~~~~~~~~~~~~~~~~~~~
pcsc.c:219:5: warning: no previous prototype for ‘pcsc_get_atqa’ [-Wmissing-prototypes]
 int pcsc_get_atqa(struct nfc_device *pnd, uint8_t *atqa, size_t atqa_len)
     ^~~~~~~~~~~~~
pcsc.c:245:5: warning: no previous prototype for ‘pcsc_get_ats’ [-Wmissing-prototypes]
 int pcsc_get_ats(struct nfc_device *pnd, uint8_t *ats, size_t ats_len)
     ^~~~~~~~~~~~
[...]
2020-05-22 10:11:52 +02:00
Philippe Teuwen
4525cd1c32 make style 2020-05-21 15:06:17 +02:00
Philippe Teuwen
f52d04e0a7 remove warnings 2020-05-21 15:05:48 +02:00
Philippe Teuwen
5a059db901 remove warnings 2020-05-21 14:50:30 +02:00
Philippe Teuwen
730f705c0d pcsc.c: fix error and remove warnings 2020-05-21 14:42:45 +02:00
Feitian Technologies
beb8fdd759
Update pcsc.c
Remove call pcsc_get_vendor_name, get the vendor name from struct nfc_device
2020-05-14 11:08:23 +08:00
hongbin@ftsafe.com
8352c80679 Modify pcsc.c to have support for Mifare classic and Ultralight card
Modify pcsc.c and mifare.c files.
1. add code into pcsc.c to have support Mifare classic card.
2. The PCSC reader has SW value, add response data length for PCSC
reader
2020-05-13 12:15:28 +08:00
Adam Laurie
f1bb27d1af
Merge pull request #598 from h3xx/add-check-libnfc-nci
Add check for Libnfc-NCI before enabling pn71xx
thanks @h3xx
2020-05-12 12:36:55 +01:00
Dan Church
17e615e8b1
Add check for Libnfc-NCI before enabling pn71xx
If the user specifically requests the driver, throw an error if it
cannot find libnfc-nci.

Also use the value from pkg-config to determine the library name,
instead of hard-coding it.
2020-05-11 13:45:53 -05:00
Philippe Teuwen
a07d879496 rework NMT_END_ENUM 2020-05-11 20:00:04 +02:00
Philippe Teuwen
96568a1023 fix nfc-list for types B 2020-05-11 19:46:46 +02:00
Adam Laurie
dcc52cd4d5 updates as per @goedox comments 2020-05-11 18:04:57 +01:00
Adam Laurie
19a51dc2bd first cut iClass support - get nfc-list to see UID 2020-05-11 11:45:28 +01:00
hongbin@ftsafe.com
cbc4e7b5c4 Update readme and add Feitian R502 and bR500 support into pcsc driver
1. Modify pcsc.c code, add R502 and bR500 support into PCSC driver
2. Update readme, tell user how to build with pcsc driver
3. Add FAQ for bR500 and R502 in readme
2020-04-09 11:29:11 +08:00
Adam Laurie
692038ceaf
Merge pull request #561 from jpwidera/master
Added check for USB alternate settings
2020-04-05 14:37:22 +01:00
Adam Laurie
fbae17186b
Merge branch 'master' into pcsc 2020-04-04 18:35:27 +01:00
Adam Laurie
004eff8e96
Merge pull request #544 from kraj/kraj/musl
usbbus: Include stdint.h for uintX_t
2020-04-04 18:31:26 +01:00
Adam Laurie
54ba7359ce
Merge branch 'master' into master 2020-04-04 18:15:56 +01:00
Adam Laurie
fba969472d
Merge pull request #469 from jgeslin/master
Adding pn71xx NXP's NFC Controllers through Linux Libnfc-nci
(note I have only tested this does not break build etc. as I do not have a reader with this chipset)
2020-04-04 18:06:13 +01:00
Adam Laurie
2a6a8e6e29 add debugging for high level config requests 2020-04-04 15:10:02 +01:00
jpwidera
07f918283b Fixed missing whitespaces 2019-09-05 22:33:33 +02:00
jpwidera
6e035c33f3 Re-enabled claim
If there are alternative interfaces, claim interface 0. Otherwise skip this step.
2019-09-05 22:32:03 +02:00
jpwidera
a77a2a8497 Removed USB alternate setting.
Quick and dirty fix for https://github.com/nfc-tools/libnfc/issues/535
2019-09-05 21:59:46 +02:00
Frank Morgner
6f793da1c1 cleanup 2019-09-03 22:44:44 +02:00
Frank Morgner
75e5e23c81 Added driver for contactless PC/SC readers
- only initiator mode is supported
- properties are choosen as they are available via PC/SC, the rest of
the defaults are chosen to be compatible with Mifare DESFire
- This commit allows reading Mifare DESFire via PC/SC with libfreefare
2019-09-03 14:54:13 +02:00
Philippe Teuwen
a4af2be66c Fix PN533 hardcoded ednpoints table 2019-07-17 22:29:09 +02:00
Khem Raj
91f7db5b4d usbbus: Include stdint.h for uintX_t
stdint.h is needed for uintX_t typedefs which are
used to replace u_intX_t in libusb API headers in the cmake files

Signed-off-by: Khem Raj <raj.khem@gmail.com>
2019-05-20 23:50:49 -07:00
Mikolaj Stawiski
793d5adde6 Fixed format warnings. 2018-11-25 13:48:04 +11:00
Emmanuel Dreyfus
7ca85a02de Fix typos 2018-11-19 19:16:26 +01:00
Emmanuel Dreyfus
85100c0aae Prefer hardcoded PN533 descriptors to the real ones
PN533 easily corrupts its USB descriptors. We know that and we
already try to detect and even repair them.

However there are situations where lower software layers get
confused before libnfc can help. On Windows, libusb may set
dev->config to NULL, but we can also have a non NULL dev->config
referencing corrupted data.

In order to get more robust, let us replace the Windows libusb
specific (dev->config == NULL) test by an inconditionnal use of
hardcoded descriptors when they are available.
2018-11-19 19:16:26 +01:00
Emmanuel Dreyfus
2418d946a3 Add missing timeout
Add a tiemout in pn53x_initiator_select_passive_target()
so that we do not get stuck forever when pn533 misses a toggle
bit change.
2018-11-12 14:46:31 +00:00
Philippe Teuwen
14f48d0122 Fix mem leak 2017-05-18 10:40:46 +02:00
Philippe Teuwen
dcdbff0705 New NFC modulation type NMT_BARCODE 2017-05-17 13:58:16 +02:00
Philippe Teuwen
9f4290b61b Add nfc-barcode 2017-05-16 13:22:30 +02:00
Philippe Teuwen
c9ac17c9f5 Fix USB descriptors in SCL3711, NXP_PN533 and ASK LoGO also when corrupted by received data
The problem occurs in the following succession of events:

* Emit commands returning an answer larger than 16 bytes
* Re-enumerate USB devices without power cycle, e.g. a warm reboot of the PC

The bug can be reproduced for testing purposes with usbreset.c from
https://askubuntu.com/questions/645/how-do-you-reset-a-usb-device-from-the-command-line#661

$ lsusb|grep NFC
Bus 001 Device 010: ID 04e6:5591 SCM Microsystems, Inc. SCL3711-NFC&RW
$ sudo ./usbreset /dev/bus/usb/001/010
Resetting USB device /dev/bus/usb/001/010
Reset successful
$ echo -e "4a 01 00\n423000" |pn53x-tamashell
$ sudo ./usbreset /dev/bus/usb/001/010
Resetting USB device /dev/bus/usb/001/010
Error in ioctl: No such device
$ lsusb|grep NFC
... device disappeared

In the example above, reading 4 pages of a MFUL corrupted one single byte.
The entire buffer can be corrupted e.g. with fast-reading a MFUL EV1:
$ echo -e "4a 01 00\n423a0013"|pn53x-tamashell
2017-04-20 09:06:47 +02:00
Philippe Teuwen
1bf542b9e2 cosmetic 2017-04-20 09:06:41 +02:00
Philippe Teuwen
767abe50e2 PN533: Abuse the overflow bug to restore USB descriptors in one go 2017-04-20 08:35:46 +02:00
Philippe Teuwen
38164c49ef Fix USB descriptors in SCL3711, NXP_PN533 and ASK LoGO if needed when closing device
The problem occurs in the following succession of events:

* Emit commands larger than 17 bytes
* Re-enumerate USB devices without power cycle, e.g. a warm reboot of the PC

The bug can be reproduced for testing purposes with usbreset.c from
https://askubuntu.com/questions/645/how-do-you-reset-a-usb-device-from-the-command-line#661

$ lsusb|grep NFC
Bus 001 Device 010: ID 04e6:5591 SCM Microsystems, Inc. SCL3711-NFC&RW
$ sudo ./usbreset /dev/bus/usb/001/010
Resetting USB device /dev/bus/usb/001/010
Reset successful
$ echo 06000000000000000000000000000000000000 |pn53x-tamashell
$ sudo ./usbreset /dev/bus/usb/001/010
Resetting USB device /dev/bus/usb/001/010
Error in ioctl: No such device
$ lsusb|grep NFC
... device disappeared
2017-04-20 01:46:32 +02:00
Philippe Teuwen
c958b2c25d Enable missing USB desc workaround for NXP_PN533 too 2017-04-19 20:24:55 +02:00
Emmanuel Dreyfus
a06bfe50a5 Workaround missing USB config
After a DESfire operation SCL3711 will sometimes enter a state where
libusb-0.x is unable to fill config field in struct usb_device. The
USB device has to be power-cycled to restore a sane state.

This introduce a work around, by using hardcoded values for endpoints
and packet size when they are unavailable.
2017-04-19 19:46:14 +02:00
Philippe Teuwen
b59f8fb3b4 Add more missing files 2017-04-04 13:31:39 +02:00
Philippe Teuwen
b65674a8e3 Some systems (e.g. glibc < 2.17) require librt to get clock_gettime -> CMAKE 2017-03-02 23:42:36 +01:00