Commit Graph
100 Commits
Author SHA1 Message Date
Philippe Teuwen 9f1a68530a nfc-barcode: add options -r & -n 2017-05-16 14:35:58 +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
Philippe Teuwen 6235a8a26b Update example script to support PCard 2017-04-16 00:05:21 +02:00
Philippe Teuwen b59f8fb3b4 Add more missing files 2017-04-04 13:31:39 +02:00
Philippe Teuwen fead8d6849 Add missing files to autotools release process 2017-04-04 11:10:46 +02:00
Philippe Teuwen e41a42cf96 nfc-mfultralight: avoid compilation warning 2017-04-01 01:03:41 +02:00
Philippe Teuwen 024fca9cb7 make style 2017-04-01 00:46:12 +02:00
Philippe Teuwen 3ec9ecf800 nfc-mfultralight: fix support for MF0UL21 2017-04-01 00:25:14 +02:00
Philippe Teuwen 560f6a6413 nfc-mfultralight: better parameters checks 2017-03-31 23:21:17 +02:00
Philippe Teuwen abae2bb17b Merge remote-tracking branch 'adam/master'
* adam/master:
  allow partial writes. tidy up usage.
  vary expected dump size based on tag type
  read extra mf-ul EV1 blocks
  show EV1 auth PACK (tag/reader trust secret)
  show EV1 storage size
  add EV1 password auth to nfc-mfultralight
2017-03-31 23:00:15 +02:00
Philippe Teuwen f2457d0559 Add pn53x-* to CMakeLists 2017-03-31 22:46:11 +02:00
Philippe Teuwen 32bb627108 Fix typo in drivers blacklist, thanks Godfrey Chung 2017-03-07 10:49:25 +01:00
Philippe Teuwen 86ce8dff52 Test Travis builds 2017-03-03 18:41:13 +01: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
Philippe Teuwen 2d2a664f6c Some systems (e.g. glibc < 2.17) require librt to get clock_gettime 2017-03-02 22:03:22 +01:00
Philippe Teuwen 9ccfba2125 Update changelog & authors 2017-03-02 16:00:51 +01:00
Philippe Teuwen b7ae7cb5fd Merge remote-tracking branch 'adam/master'
* adam/master:
  Tidier fix for incorrect block write/count as per @doegox
  Fix number of blocks written. Fix number of written blocks reported.
2017-03-01 18:51:35 +01:00
Philippe Teuwen c51caf424a nfc-mfultralight: fix failed read reporting and add failed pages count 2017-02-27 17:22:42 +01:00
Philippe Teuwen bf31594410 conf: close file 2017-02-18 22:20:15 +01:00
Philippe Teuwen 04ef5ca902 Reduce variables scopes 2017-02-18 22:20:15 +01:00
Philippe Teuwen 2033519b0c Add asserts to tell static analyzer we know what we're doing...
nfc.c:1244:19: warning: Dereference of undefined pointer value
  for (int i = 0; nmt[i]; i++) {
                  ^~~~~~
nfc.c:1256:23: warning: Dereference of undefined pointer value
      for (int j = 0; nbr[j]; j++) {
                      ^~~~~~
2017-02-18 18:08:27 +01:00
Philippe Teuwen f2c264d4ae pn53x: avoid warning about uninitialized value (false positive)
pn53x.c:1746:15: warning: Function call argument is an uninitialized value
    *cycles = __pn53x_get_timer(pnd, pbtTxRaw[szTx + 1]);
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2017-02-18 17:29:57 +01:00
Philippe Teuwen 05220537ea i2c: fix struct initialization
pn532_i2c.c:125:57: warning: missing field 'tv_nsec' initializer [-Wmissing-field-initializers]
        struct timespec transaction_start, bus_free_time = { 0 };
                                                               ^
pn532_i2c.c:153:57: warning: missing field 'tv_nsec' initializer [-Wmissing-field-initializers]
        struct timespec transaction_start, bus_free_time = { 0 };
2017-02-18 17:23:22 +01:00
Philippe Teuwen c815c7a059 nfc-mfultralight: remove dead assignment
nfc-mfultralight.c:274:7: warning: Value stored to 'bFailure' is never read
      bFailure = false;
      ^          ~~~~~
2017-02-18 17:17:53 +01:00
Philippe Teuwen 9a749e1a66 arygon: remove unused variable
arygon.c:94:22: warning: unused variable 'arygon_error_incomplete_command' [-Wunused-const-variable]
static const uint8_t arygon_error_incomplete_command[] = "FF0C0000\x0d\x0a";
                     ^
2017-02-18 17:17:33 +01:00
Philippe Teuwen e4df2f3334 astyle 2017-02-18 13:05:59 +01:00
Philippe Teuwen f184407cc5 Makefile: fix option for recent astyle 2017-02-18 13:05:45 +01:00
Philippe Teuwen e8d44f1ee8 typo 2017-02-18 13:05:02 +01:00
Philippe Teuwen 4e4438435d Update README about pn533_usb 2017-02-18 01:59:27 +01:00
Philippe Teuwen 02c06c8e28 Update ChangeLog 2017-02-18 01:51:59 +01:00
Philippe Teuwen ff37cdb2be Replace deprecated readdir_r by readdir
This reverts 262555d5, 7fb53873 and a0b859b2
2017-02-17 12:10:33 +01:00
Philippe Teuwen c5e8adc169 mfclassic: avoid hardcoded offsets & sizes 2017-02-17 11:31:13 +01:00
Philippe Teuwen 646ab57ace fix typo 2017-02-17 10:31:25 +01:00
Philippe Teuwen db4433f116 CMake: set policy CMP0045 2017-02-17 10:28:53 +01:00
Philippe Teuwen d808802b16 typos 2017-02-17 10:11:34 +01:00
Philippe Teuwen b86b7efb10 Fix number of blocks written
A strange move changed the way written pages are bound in commit ed62b01a.
As a result the last 3 blocks weren't written anymore.
2017-02-17 09:56:35 +01:00
Philippe Teuwen 11bcf05a75 Fix typo. Fix issue #377 2017-02-16 23:12:38 +01:00
Philippe Teuwen 968f59a988 Remove unneeded test, fix issue #376 2017-02-16 23:05:02 +01:00
Philippe Teuwen e50b18848f Remove spurious mirror_uint8_ts declaration, fix issue #375 2017-02-16 23:00:37 +01:00
Philippe Teuwen 372bf37eec Blacklist pn533_usb to fix issue #391 2017-02-16 22:32:16 +01:00
Philippe Teuwen 295c70911a Restrict MFC Mini detection according to AN10833 2017-02-16 22:31:10 +01:00
Philippe Teuwen 49dde9c28c Merge branch 'nfc_get_supported_baud_rate_proposal'
* nfc_get_supported_baud_rate_proposal:
  nfc_get_supported_baud_rate() proposal to reverse API
2015-06-18 22:07:09 +02:00
Philippe Teuwen 04a51df796 nfc_get_supported_baud_rate() proposal to reverse API
cf issue #298
nfc_get_supported_baud_rate() would be the one for "initiator mode"
and we add nfc_get_supported_baud_rate_target_mode()
2015-06-08 11:34:16 +02:00
Philippe Teuwen bb9babbeda Fix out-of-bounds access in nfc-mfultralight unveiled by coverity scan:
*** CID 1090333:  Out-of-bounds access  (OVERRUN)
2014-04-14 23:29:18 +02:00
Philippe Teuwen bd92f74a58 Update ChangeLog 2014-03-12 00:38:46 +01:00
Philippe Teuwen 9a254712b5 nfc_initiator_select_passive_target(): validate modulation and baud rate 2014-03-12 00:28:39 +01:00
Philippe Teuwen e57dc8a746 Better list of supported modulations & baud rates
* Extend supported baud rates for TypeA
* Extend supported modulations B->BI,B2SR,B2CT
* Use InPSL only on TypeA
* Add mode to nfc_get_supported_baud_rate() (API change!)
* Fix supported baud rates for BI,B2SR,B2CT
* Remove supported modulations as target for ASK LoGO

Before:

$ nfc-scan-device -v
3 NFC device(s) found:
- ACS / ACR122U PICC Interface:
    acr122_usb:002:024
chip: PN532 v1.4
initator mode modulations: ISO/IEC 14443A (106 kbps), FeliCa (424 kbps, 212 kbps), ISO/IEC 14443-4B (106 kbps), Innovision Jewel (106 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps)
target mode modulations: ISO/IEC 14443A (106 kbps), FeliCa (424 kbps, 212 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps)
- SCM Micro / SCL3711-NFC&RW:
    pn53x_usb:002:028
chip: PN533 v2.7
initator mode modulations: ISO/IEC 14443A (106 kbps), FeliCa (424 kbps, 212 kbps), ISO/IEC 14443-4B (847 kbps, 424 kbps, 212 kbps, 106 kbps), Innovision Jewel (106 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps)
target mode modulations: ISO/IEC 14443A (106 kbps), FeliCa (424 kbps, 212 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps)
- ASK / LoGO:
    pn53x_usb:002:023
chip: PN533 v2.7
initator mode modulations: ISO/IEC 14443A (106 kbps), FeliCa (424 kbps, 212 kbps), ISO/IEC 14443-4B (847 kbps, 424 kbps, 212 kbps, 106 kbps), Innovision Jewel (106 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps)
target mode modulations: ISO/IEC 14443A (106 kbps), FeliCa (424 kbps, 212 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps)

After:

$ nfc-scan-device -v
3 NFC device(s) found:
- ACS / ACR122U PICC Interface:
    acr122_usb:002:024
chip: PN532 v1.4
initator mode modulations: ISO/IEC 14443A (424 kbps, 212 kbps, 106 kbps), FeliCa (424 kbps, 212 kbps), ISO/IEC 14443-4B (106 kbps), ISO/IEC 14443-4B' (106 kbps), ISO/IEC 14443-2B ST SRx (106 kbps), ISO/IEC 14443-2B ASK CTx (106 kbps), Innovision Jewel (106 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps)
target mode modulations: ISO/IEC 14443A (424 kbps, 212 kbps, 106 kbps), FeliCa (424 kbps, 212 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps)
- SCM Micro / SCL3711-NFC&RW:
    pn53x_usb:002:025
chip: PN533 v2.7
initator mode modulations: ISO/IEC 14443A (847 kbps, 424 kbps, 212 kbps, 106 kbps), FeliCa (424 kbps, 212 kbps), ISO/IEC 14443-4B (847 kbps, 424 kbps, 212 kbps, 106 kbps), ISO/IEC 14443-4B' (106 kbps), ISO/IEC 14443-2B ST SRx (106 kbps), ISO/IEC 14443-2B ASK CTx (106 kbps), Innovision Jewel (106 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps)
target mode modulations: ISO/IEC 14443A (424 kbps, 212 kbps, 106 kbps), FeliCa (424 kbps, 212 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps)
- ASK / LoGO:
    pn53x_usb:002:023
chip: PN533 v2.7
initator mode modulations: ISO/IEC 14443A (847 kbps, 424 kbps, 212 kbps, 106 kbps), FeliCa (424 kbps, 212 kbps), ISO/IEC 14443-4B (847 kbps, 424 kbps, 212 kbps, 106 kbps), ISO/IEC 14443-4B' (106 kbps), ISO/IEC 14443-2B ST SRx (106 kbps), ISO/IEC 14443-2B ASK CTx (106 kbps), Innovision Jewel (106 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps)
target mode modulations:
2014-03-12 00:00:08 +01:00
Philippe Teuwen 89fc6a723e make style 2014-03-11 00:25:33 +01:00
Philippe Teuwen ddde2dd8f2 initiator_select_passive_target(): now supports all speeds for ISO14443-4A tags 2014-03-11 00:13:26 +01:00
Philippe Teuwen 108de27c1b Fix typo baud<>bauds thanks to Polluks 2014-03-05 17:48:55 +01:00
Philippe Teuwen 6b74323369 target_is_present(): remove unreachable code 2014-03-04 01:47:42 +01:00
Philippe Teuwen 6ab3c368b8 nfc-emulate-uid: remove unreachable code and add proper cleaning when interrupted 2014-03-04 01:41:01 +01:00
Philippe Teuwen db4fae9c2c Remove unreachable statements
As seen with clang -Wunreachable-code
2014-03-04 01:39:12 +01:00
Philippe Teuwen 7adad098c3 Document -Wunreachable-code in HACKING file 2014-03-04 01:38:44 +01:00
Philippe Teuwen c0b9db6860 Update ChangeLog & AUTHORS 2014-02-18 15:40:22 +01:00
Philippe Teuwen a7649da2b0 nfc-read-forum-tag3: add -q and document -o - 2014-02-18 00:22:24 +01:00
Philippe Teuwen 2aa4b99b7b nfc-read-forum-tag3: full parsing of NDEF Attribute Block 2014-02-17 23:57:59 +01:00
Philippe Teuwen 491db20d54 nfc-jewel: remove extraneous parentheses to silence warning 2014-02-11 23:23:42 +01:00
Philippe Teuwen 415ad7cbac nfc_initiator_select_passive_target() accepts NULL pbtInitData and provides default values 2014-02-10 01:09:07 +01:00
Philippe Teuwen fd30e63b80 nfc_initiator_target_is_present(): Fixes issue #267, second attempt 2014-02-10 00:01:34 +01:00
Philippe Teuwen 766ed55c79 nfc-jewel: fix out-of-bounds array access
Defect(s) Reported-by: Coverity Scan
** CID 1169884:  Out-of-bounds read  (OVERRUN)
/utils/nfc-jewel.c: 186 in write_card()
2014-02-07 23:09:40 +01:00
Philippe Teuwen 2d584baa9b Update ChangeLog 2014-02-07 14:39:44 +01:00
Philippe Teuwen 85bef73734 nfc_initiator_target_is_present(): Fixes issue #267
Fixes some -4A cards removal on PN533
but fixes also same -4A cards on PN532
2014-02-07 14:00:57 +01:00
Philippe Teuwen 1f5e14f862 cppcheck on pn53x.c: Array 'apttTargetTypes' is filled incompletely 2014-02-07 01:29:42 +01:00
Philippe Teuwen a38279793a cppcheck on nfc-pool: Variable 'res' is assigned a value that is never used 2014-02-07 01:22:27 +01:00
Philippe Teuwen 1e4fe3bd27 nfc_initiator_target_is_present(): Support B2 ST SRx 2014-02-07 01:11:19 +01:00
Philippe Teuwen 9fd11d331b nfc_initiator_target_is_present(): Support B2 ASK CT 2014-02-07 00:53:35 +01:00
Philippe Teuwen a3a7111210 nfc_initiator_target_is_present(): Support B' 2014-02-07 00:31:31 +01:00
Philippe Teuwen 7254e1b2ea nfc_initiator_target_is_present(): Support Jewel 2014-02-03 00:24:23 +01:00
Philippe Teuwen 827d9792dd Save & restore NP_INFINITE_SELECT status when changing it internally 2014-02-01 02:45:17 +01:00
Philippe Teuwen 69c4d0768a nfc_initiator_select_passive_target(): grant NP_INFINITE_SELECT also for ISO14443B* 2014-02-01 02:45:17 +01:00
Philippe Teuwen 510228b6e0 nfc_initiator_select_passive_target(): save current target info even if pnt=NULL 2014-02-01 02:45:16 +01:00
Philippe Teuwen e11c5254af nfc_initiator_select_passive_target(): save current target info also for ISO14443B* 2014-01-31 23:53:29 +01:00
Philippe Teuwen 81e1dd715d nfc_initiator_target_is_present(): Fix error type in case no target is selected yet 2014-01-31 23:19:04 +01:00
Philippe Teuwen 71eda315c7 nfc_initiator_target_is_present(): Fix MFC support on PN532 2014-01-31 22:33:05 +01:00
Philippe Teuwen 7d41ed34a3 *_is_present(): more robust detection of tag gone 2014-01-30 18:30:45 +01:00
Philippe Teuwen 9a84bb0ba0 Split pn53x_initiator_target_is_present() for readability 2014-01-30 18:10:30 +01:00
Philippe Teuwen 62e78ab582 nfc_initiator_target_is_present(): support -4B on PN532 2014-01-30 12:55:51 +01:00
Philippe Teuwen d6330a55d0 nfc_initiator_target_is_present(): better error handling 2014-01-30 11:37:37 +01:00
Philippe Teuwen 05579fde09 nfc_initiator_target_is_present(): better Felica support 2014-01-30 11:19:02 +01:00
Philippe Teuwen d893e4398c nfc_initiator_target_is_present(): fix ISO14443B-4 support 2014-01-30 00:32:21 +01:00
Philippe Teuwen ade71ee8a6 nfc_initiator_target_is_present(): reuse iso14443_cascade_uid() 2014-01-30 00:24:06 +01:00
Philippe Teuwen 095f945224 nfc_initiator_target_is_present(): improve MFC support for 7-byte UID 2014-01-30 00:09:03 +01:00
Philippe Teuwen 9d63a93dd8 nfc_initiator_target_is_present(): improve MFC support
Increase timeout to support Tikitag & PN533
Fix support for MFC Mini on PN533
2014-01-29 23:30:50 +01:00
Philippe Teuwen 94f4e001f4 nfc_initiator_target_is_present(): support MFUL on PN532 too 2014-01-29 23:02:36 +01:00
Philippe Teuwen 1a3acdadc4 Prepare nfc_initiator_target_is_present() to support more cases
and return NFC_EDEVNOTSUPP for cases not yet supported, depending on the chipset.

Little helper to debug future additions to that function:

// LIBNFC_LOG_LEVEL=193 ./nfc-testing
int
main(void)
{
  nfc_device *pnd;
  nfc_modulation nm = {  .nmt = NMT_ISO14443A,  .nbr = NBR_106,  };
  nfc_context *context;
  nfc_init(&context);
  pnd = nfc_open(context, NULL);
  nfc_initiator_init(pnd);
  nfc_target nt;
  nfc_initiator_select_passive_target(pnd, nm, NULL, 0, &nt);
  while (nfc_initiator_target_is_present(pnd, NULL) == NFC_SUCCESS);
  nfc_close(pnd);
  nfc_exit(context);
}
2014-01-29 01:54:46 +01:00
Philippe Teuwen 744e052fbe update ChangeLog 2014-01-28 13:20:03 +01:00
Philippe Teuwen 65ad186109 make style 2014-01-28 13:09:33 +01:00
Philippe Teuwen 7a30e35496 nfc-mfclassic: update help & man page 2014-01-28 00:22:33 +01:00
Philippe Teuwen d47623319d nfc_initiator_target_is_present() allows pnt==NULL 2014-01-27 16:07:24 +01:00
Philippe Teuwen 7b7f506142 make style 2013-12-08 19:51:01 +01:00
Philippe Teuwen 4817a6e5c9 make style 2013-12-02 22:55:10 +01:00
Philippe Teuwen a1ef329962 Fix use after free
pn532_uart.c:293:5: warning: Use of memory after it is freed
    log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "pn53x_check_communication error on %s", ndd.port);
    ^                                                                                                 ~~~~~~~~
2013-11-12 00:43:43 +01:00
Philippe Teuwen b8e0eec91d nfc-mfclassic: initialize always bFormatCard 2013-11-12 00:43:25 +01:00
Philippe Teuwen 7e5257dd44 Update Changelog 2013-10-01 14:29:51 +02:00