├── libnfc-1.7.1 ├── include │ ├── CMakeLists.txt │ ├── Makefile.am │ └── nfc │ │ ├── CMakeLists.txt │ │ ├── Makefile.am │ │ └── nfc-emulation.h ├── contrib │ ├── devd │ │ ├── Makefile.am │ │ └── pn53x.conf │ ├── udev │ │ ├── Makefile.am │ │ └── 42-pn53x.rules │ ├── win32 │ │ ├── sys │ │ │ ├── Makefile.am │ │ │ └── select.h │ │ ├── libnfc │ │ │ ├── buses │ │ │ │ └── Makefile.am │ │ │ ├── Makefile.am │ │ │ └── log-internal.c │ │ ├── Makefile.am │ │ ├── err.h │ │ ├── version.rc.in │ │ ├── nfc.def │ │ ├── unistd.h │ │ └── stdlib.c │ ├── linux │ │ ├── Makefile.am │ │ └── blacklist-libnfc.conf │ ├── Makefile.am │ ├── libnfc │ │ ├── Makefile.am │ │ ├── arygon.conf.sample │ │ ├── pn532_via_uart2usb.conf.sample │ │ ├── pn532_spi_on_rpi.conf.sample │ │ ├── pn532_uart_on_rpi.conf.sample │ │ └── pn532_i2c_on_rpi.conf.sample │ └── windows.h ├── libnfc │ ├── buses │ │ ├── empty.c │ │ ├── Makefile.am │ │ ├── usbbus.h │ │ ├── i2c.h │ │ ├── uart.h │ │ ├── spi.h │ │ └── usbbus.c │ ├── chips │ │ └── Makefile.am │ ├── conf.h │ ├── drivers │ │ ├── Makefile.am │ │ ├── acr122s.h │ │ ├── pn53x_usb.h │ │ ├── arygon.h │ │ ├── pn532_uart.h │ │ ├── acr122_pcsc.h │ │ ├── acr122_usb.h │ │ ├── pn532_spi.h │ │ └── pn532_i2c.h │ ├── Makefile.am │ ├── drivers.h │ ├── log-internal.c │ ├── mirror-subr.h │ ├── log-internal.h │ ├── iso7816.h │ ├── additional-pages.dox │ ├── target-subr.h │ ├── nfc-device.c │ ├── nfc-emulation.c │ ├── log.c │ ├── mirror-subr.c │ ├── CMakeLists.txt │ └── iso14443-subr.c ├── cmake │ ├── Makefile.am │ ├── modules │ │ ├── Makefile.am │ │ ├── FindPCSC.cmake │ │ ├── FindPCRE.cmake │ │ ├── COPYING-CMAKE-SCRIPTS │ │ ├── FindLIBUSB.cmake │ │ ├── LibnfcDrivers.cmake │ │ └── UseDoxygen.cmake │ ├── config_posix.h.cmake │ ├── config_windows.h.cmake │ └── FixBundle.cmake.in ├── examples │ ├── pn53x-tamashell-scripts │ │ ├── Makefile.am │ │ ├── UltraLightRead.cmd │ │ ├── ASK_LoGO_LEDs.cmd │ │ ├── ReadNavigo.sh │ │ ├── ReadMobib.sh │ │ └── UltraLightReadWrite.cmd │ ├── pn53x-diagnose.1 │ ├── nfc-dep-target.1 │ ├── nfc-dep-initiator.1 │ ├── pn53x-sam.1 │ ├── nfc-mfsetuid.1 │ ├── nfc-relay.1 │ ├── CMakeLists.txt │ ├── nfc-anticol.1 │ ├── nfc-emulate-forum-tag2.1 │ ├── nfc-poll.1 │ ├── nfc-emulate-tag.1 │ ├── pn53x-tamashell.1 │ ├── doc │ │ ├── quick_start_example1.c │ │ └── quick_start_example2.c │ ├── nfc-emulate-uid.1 │ ├── Makefile.am │ └── nfc-dep-initiator.c ├── config.h ├── libnfc.pc.in ├── test │ ├── run-test.sh │ ├── test_register_endianness.c │ ├── Makefile.am │ ├── test_access_storm.c │ └── test_register_access.c ├── AUTHORS ├── libnfc.conf.sample ├── utils │ ├── nfc-read-forum-tag3.1 │ ├── nfc-jewel.1 │ ├── nfc-mfultralight.1 │ ├── nfc-scan-device.1 │ ├── Makefile.am │ ├── nfc-list.1 │ ├── nfc-emulate-forum-tag4.1 │ ├── CMakeLists.txt │ ├── nfc-relay-picc.1 │ ├── crypto1.c │ ├── crapto1.h │ ├── nfc-mfclassic.1 │ ├── nfc-utils.h │ ├── jewel.c │ └── nfc-utils.c ├── m4 │ ├── libnfc_check_pcsc.m4 │ ├── readline.m4 │ └── libnfc_check_libusb.m4 ├── Makefile.am ├── make_release.sh ├── HACKING ├── README-Windows.txt └── mingw-cross-configure.sh ├── win32 ├── libnfc.dll ├── pcre3.dll ├── nfc-super.exe └── README.TXT └── README.md /libnfc-1.7.1/include/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_SUBDIRECTORY(nfc) 2 | 3 | -------------------------------------------------------------------------------- /libnfc-1.7.1/contrib/devd/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = \ 2 | pn53x.conf 3 | -------------------------------------------------------------------------------- /libnfc-1.7.1/contrib/udev/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = \ 2 | 42-pn53x.rules 3 | -------------------------------------------------------------------------------- /libnfc-1.7.1/contrib/win32/sys/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = \ 2 | select.h 3 | -------------------------------------------------------------------------------- /libnfc-1.7.1/contrib/win32/libnfc/buses/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = \ 2 | uart.c 3 | -------------------------------------------------------------------------------- /libnfc-1.7.1/contrib/linux/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = \ 2 | blacklist-libnfc.conf 3 | -------------------------------------------------------------------------------- /libnfc-1.7.1/contrib/linux/blacklist-libnfc.conf: -------------------------------------------------------------------------------- 1 | blacklist nfc 2 | blacklist pn533 3 | -------------------------------------------------------------------------------- /libnfc-1.7.1/include/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = nfc 2 | 3 | EXTRA_DIST = CMakeLists.txt 4 | -------------------------------------------------------------------------------- /win32/libnfc.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netscylla/super-card/HEAD/win32/libnfc.dll -------------------------------------------------------------------------------- /win32/pcre3.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netscylla/super-card/HEAD/win32/pcre3.dll -------------------------------------------------------------------------------- /libnfc-1.7.1/libnfc/buses/empty.c: -------------------------------------------------------------------------------- 1 | /* empty source code file */ 2 | #include 3 | -------------------------------------------------------------------------------- /win32/nfc-super.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netscylla/super-card/HEAD/win32/nfc-super.exe -------------------------------------------------------------------------------- /libnfc-1.7.1/contrib/win32/libnfc/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = buses . 2 | 3 | EXTRA_DIST = \ 4 | log-internal.c 5 | -------------------------------------------------------------------------------- /libnfc-1.7.1/contrib/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = \ 2 | devd \ 3 | libnfc \ 4 | linux \ 5 | udev \ 6 | win32 7 | 8 | EXTRA_DIST = \ 9 | windows.h 10 | -------------------------------------------------------------------------------- /libnfc-1.7.1/cmake/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = modules 2 | 3 | EXTRA_DIST = \ 4 | FixBundle.cmake.in \ 5 | config_posix.h.cmake \ 6 | config_windows.h.cmake 7 | -------------------------------------------------------------------------------- /libnfc-1.7.1/contrib/libnfc/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = \ 2 | pn532_via_uart2usb.conf.sample \ 3 | arygon.conf.sample \ 4 | pn532_uart_on_rpi.conf.sample 5 | -------------------------------------------------------------------------------- /libnfc-1.7.1/contrib/win32/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = libnfc sys . 2 | 3 | EXTRA_DIST = \ 4 | err.h \ 5 | nfc.def \ 6 | stdlib.c \ 7 | unistd.h \ 8 | version.rc.in 9 | -------------------------------------------------------------------------------- /libnfc-1.7.1/examples/pn53x-tamashell-scripts/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = \ 2 | ReadMobib.sh \ 3 | ReadNavigo.sh \ 4 | UltraLightRead.cmd \ 5 | UltraLightReadWrite.cmd 6 | -------------------------------------------------------------------------------- /libnfc-1.7.1/contrib/libnfc/arygon.conf.sample: -------------------------------------------------------------------------------- 1 | ## Typical configuration file for Arygon/IDentive device (with Arygon-MCU on board) 2 | name = "IDentive" 3 | connstring = arygon:/dev/ttyS0 4 | -------------------------------------------------------------------------------- /libnfc-1.7.1/cmake/modules/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = \ 2 | COPYING-CMAKE-SCRIPTS \ 3 | FindLIBUSB.cmake \ 4 | FindPCSC.cmake \ 5 | FindPCRE.cmake \ 6 | UseDoxygen.cmake \ 7 | LibnfcDrivers.cmake 8 | -------------------------------------------------------------------------------- /libnfc-1.7.1/include/nfc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Headers 2 | FILE(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h") 3 | INSTALL(FILES ${headers} DESTINATION ${INCLUDE_INSTALL_DIR}/nfc COMPONENT headers) 4 | 5 | -------------------------------------------------------------------------------- /libnfc-1.7.1/include/nfc/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | nfcinclude_HEADERS = \ 3 | nfc.h \ 4 | nfc-emulation.h \ 5 | nfc-types.h 6 | nfcincludedir = $(includedir)/nfc 7 | 8 | EXTRA_DIST = CMakeLists.txt 9 | -------------------------------------------------------------------------------- /libnfc-1.7.1/contrib/libnfc/pn532_via_uart2usb.conf.sample: -------------------------------------------------------------------------------- 1 | ## Typical configuration file for PN532 board (ie. microbuilder.eu / Adafruit) device 2 | name = "Adafruit PN532 board via UART" 3 | connstring = pn532_uart:/dev/ttyUSB0 4 | -------------------------------------------------------------------------------- /libnfc-1.7.1/config.h: -------------------------------------------------------------------------------- 1 | #include "contrib/windows.h" 2 | 3 | #define PACKAGE_NAME "libnfc" 4 | #define PACKAGE_VERSION "1.7.1" 5 | #define PACKAGE_STRING "libnfc 1.7.1" 6 | #define LIBNFC_SYSCONFDIR "C:/Program Files/libnfc/config" 7 | -------------------------------------------------------------------------------- /libnfc-1.7.1/cmake/config_posix.h.cmake: -------------------------------------------------------------------------------- 1 | #cmakedefine PACKAGE_NAME "@PACKAGE_NAME@" 2 | #cmakedefine PACKAGE_VERSION "@PACKAGE_VERSION@" 3 | #cmakedefine PACKAGE_STRING "@PACKAGE_STRING@" 4 | #cmakedefine _XOPEN_SOURCE @_XOPEN_SOURCE@ 5 | #cmakedefine SYSCONFDIR "@SYSCONFDIR@" 6 | -------------------------------------------------------------------------------- /libnfc-1.7.1/cmake/config_windows.h.cmake: -------------------------------------------------------------------------------- 1 | #include "contrib/windows.h" 2 | 3 | #cmakedefine PACKAGE_NAME "@PACKAGE_NAME@" 4 | #cmakedefine PACKAGE_VERSION "@PACKAGE_VERSION@" 5 | #cmakedefine PACKAGE_STRING "@PACKAGE_STRING@" 6 | #cmakedefine LIBNFC_SYSCONFDIR "@LIBNFC_SYSCONFDIR@" 7 | -------------------------------------------------------------------------------- /libnfc-1.7.1/libnfc/chips/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | # set the include path found by configure 3 | AM_CPPFLAGS = $(all_includes) $(LIBNFC_CFLAGS) 4 | 5 | noinst_LTLIBRARIES = libnfcchips.la 6 | libnfcchips_la_SOURCES = pn53x.c pn53x.h pn53x-internal.h 7 | libnfcchips_la_CFLAGS = -I$(top_srcdir)/libnfc 8 | 9 | -------------------------------------------------------------------------------- /libnfc-1.7.1/libnfc.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: libnfc 7 | Description: Near Field Communication (NFC) library 8 | Version: @VERSION@ 9 | Requires: @PKG_CONFIG_REQUIRES@ 10 | Libs: -L${libdir} -lnfc 11 | Cflags: -I${includedir} 12 | -------------------------------------------------------------------------------- /libnfc-1.7.1/contrib/libnfc/pn532_spi_on_rpi.conf.sample: -------------------------------------------------------------------------------- 1 | ## Typical configuration file for PN532 device on R-Pi connected using SPI 2 | ## Note: to use SPI port on R-Pi, you have to load kernel module spi-bcm2708: 3 | ## Edit /etc/modprobe.d/raspi-blacklist.conf and comment: #blacklist spi-bcm2708 4 | name = "PN532 board via SPI" 5 | connstring = pn532_spi:/dev/spidev0.0:500000 6 | -------------------------------------------------------------------------------- /libnfc-1.7.1/contrib/libnfc/pn532_uart_on_rpi.conf.sample: -------------------------------------------------------------------------------- 1 | ## Typical configuration file for PN532 device on R-Pi connected using UART 2 | ## Note: to use UART port on R-Pi, you have to disable linux serial console: 3 | ## http://learn.adafruit.com/adafruit-nfc-rfid-on-raspberry-pi/freeing-uart-on-the-pi 4 | name = "PN532 board via UART" 5 | connstring = pn532_uart:/dev/ttyAMA0 6 | -------------------------------------------------------------------------------- /libnfc-1.7.1/contrib/win32/err.h: -------------------------------------------------------------------------------- 1 | #ifndef _ERR_H_ 2 | #define _ERR_H_ 3 | 4 | #include 5 | 6 | #define warnx(...) do { \ 7 | fprintf (stderr, __VA_ARGS__); \ 8 | fprintf (stderr, "\n"); \ 9 | } while (0) 10 | 11 | #define errx(code, ...) do { \ 12 | fprintf (stderr, __VA_ARGS__); \ 13 | fprintf (stderr, "\n"); \ 14 | exit (code); \ 15 | } while (0) 16 | 17 | #define err errx 18 | 19 | #endif /* !_ERR_H_ */ 20 | -------------------------------------------------------------------------------- /libnfc-1.7.1/cmake/FixBundle.cmake.in: -------------------------------------------------------------------------------- 1 | INCLUDE(BundleUtilities) 2 | 3 | # set bundle to the full path of the executable already existing in the install tree 4 | SET(bundle "${CMAKE_INSTALL_PREFIX}/bin/nfc-list@CMAKE_EXECUTABLE_SUFFIX@") 5 | 6 | # set other_libs to a list of additional libs that cannot be reached by dependency analysis 7 | SET(other_libs "") 8 | 9 | SET(dirs "@LIBUSB_LIBRARY_DIR@" "@PCRE_BIN_DIRS@") 10 | 11 | fixup_bundle("${bundle}" "${other_libs}" "${dirs}") 12 | -------------------------------------------------------------------------------- /libnfc-1.7.1/examples/pn53x-tamashell-scripts/UltraLightRead.cmd: -------------------------------------------------------------------------------- 1 | 02; // Get firmware version 2 | 3 | // Reads content of a Mifare UltraLight 4 | // PLEASE PUT ULTRALIGHT TAG NOW 5 | 4A 01 00; // 1 target requested 6 | 7 | // Read memory content from address 4 8 | 40 01 30 00; Read 16 bytes from address 0x00 9 | 40 01 30 04; Read 16 bytes from address 0x04 10 | 40 01 30 08; Read 16 bytes from address 0x08 11 | 40 01 30 0C; Read 16 bytes from address 0x0C 12 | 13 | -------------------------------------------------------------------------------- /libnfc-1.7.1/test/run-test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export BASE_DIR="`dirname $0`" 4 | 5 | if test -z "$NO_MAKE"; then 6 | make -C "$BASE_DIR/../" > /dev/null || exit 1 7 | fi 8 | 9 | if test -z "$CUTTER"; then 10 | CUTTER="`make -s -C "$BASE_DIR" echo-cutter`" 11 | fi 12 | 13 | "$CUTTER" --keep-opening-modules -s "$BASE_DIR" "$@" "$BASE_DIR" 14 | # ^^^^^^^^^^^^^^^^^^^^^^ 15 | # FIXME: Remove this workaround once cutter has been fixed upstream. 16 | # Bug report: 17 | # http://sourceforge.net/mailarchive/forum.php?thread_name=20100626123941.GA258%40blogreen.org&forum_name=cutter-users-en 18 | -------------------------------------------------------------------------------- /libnfc-1.7.1/contrib/libnfc/pn532_i2c_on_rpi.conf.sample: -------------------------------------------------------------------------------- 1 | ## Typical configuration file for PN532 device on R-Pi connected using I2C 2 | ## Note: to use SPI port on R-Pi, you have to load kernel modules i2c-bcm2708 and i2c-dev: 3 | ## Edit /etc/modprobe.d/raspi-blacklist.conf and comment: #blacklist i2c-bcm2708 4 | ## Edit /etc/modules and add a new line: i2c-dev 5 | name = "PN532 board via I2C" 6 | connstring = pn532_i2c:/dev/i2c-0 7 | 8 | # Note: If you have an R-Pi revision 2.0, the I2C bus #1 is now routed to connector P1 9 | # (instead of the I2C bus #0 routed on same connector on initial board revision), so 10 | # the configuration to use would probably be: 11 | 12 | # connstring = pn532_i2c:/dev/i2c-1 13 | -------------------------------------------------------------------------------- /libnfc-1.7.1/examples/pn53x-diagnose.1: -------------------------------------------------------------------------------- 1 | .TH pn53x-diagnose 1 "June 15, 2010" "libnfc" "libnfc's examples" 2 | .SH NAME 3 | pn53x-diagnose \- PN53x diagnose tool 4 | .SH SYNOPSIS 5 | .B pn53x-diagnose 6 | .SH DESCRIPTION 7 | .B pn53x-diagnose 8 | is a utility to diagnose PN531, PN532 and PN533 chips. 9 | It runs communication, RAM and ROM tests. 10 | 11 | .SH BUGS 12 | Please report any bugs on the 13 | .B libnfc 14 | issue tracker at: 15 | .br 16 | .BR http://code.google.com/p/libnfc/issues 17 | .SH LICENCE 18 | .B libnfc 19 | is licensed under the GNU Lesser General Public License (LGPL), version 3. 20 | .br 21 | .B libnfc-utils 22 | and 23 | .B libnfc-examples 24 | are covered by the the BSD 2-Clause license. 25 | .SH AUTHORS 26 | Romuald Conty 27 | .PP 28 | This manual page was written by Romuald Conty . 29 | It is licensed under the terms of the GNU GPL (version 2 or later). 30 | -------------------------------------------------------------------------------- /libnfc-1.7.1/AUTHORS: -------------------------------------------------------------------------------- 1 | # Alphabetical cleaned output of "git shortlog -s -e|cut -c 8-" : 2 | Adam Laurie 3 | Ahti Legonkov 4 | Alex Lian 5 | Anugrah Redja Kusuma 6 | Audrey Diacre 7 | Emanuele Bertoldi 8 | Eugeny Boger 9 | Francois Kooman 10 | Jiapeng Li 11 | Julien Schueller 12 | Laurent Latil 13 | Ludovic Rousseau 14 | Marcello Morena 15 | Mike Auty 16 | Nobuhiro Iwamatsu 17 | Peter Meerwald 18 | Philippe Teuwen 19 | Pim 't Hart 20 | Roel Verdult 21 | Romain Tartiere 22 | Romuald Conty 23 | lego 24 | -------------------------------------------------------------------------------- /libnfc-1.7.1/contrib/udev/42-pn53x.rules: -------------------------------------------------------------------------------- 1 | # udev rules file for PN531 and PN533 devices (for udev 0.98 version) 2 | # to be installed in /etc/udev/rules.d 3 | 4 | SUBSYSTEM!="usb|usb_device", GOTO="pn53x_rules_end" 5 | ACTION!="add", GOTO="pn53x_rules_end" 6 | 7 | # PN531 8 | ATTRS{idVendor}=="04cc", ATTRS{idProduct}=="0531", MODE="0664", GROUP="plugdev" 9 | ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0193", MODE="0664", GROUP="plugdev" 10 | 11 | # PN533 12 | ATTRS{idVendor}=="04cc", ATTRS{idProduct}=="2533", MODE="0664", GROUP="plugdev" 13 | ATTRS{idVendor}=="04e6", ATTRS{idProduct}=="5591", MODE="0664", GROUP="plugdev" 14 | ATTRS{idVendor}=="1fd3", ATTRS{idProduct}=="0608", MODE="0664", GROUP="plugdev" 15 | ATTRS{idVendor}=="054c", ATTRS{idProduct}=="02e1", MODE="0664", GROUP="plugdev" 16 | 17 | # ACR122 / Touchatag 18 | ATTRS{idVendor}=="072f", ATTRS{idProduct}=="2200", MODE="0664", GROUP="plugdev" 19 | ATTRS{idVendor}=="072f", ATTRS{idProduct}=="90cc", MODE="0664", GROUP="plugdev" 20 | 21 | LABEL="pn53x_rules_end" 22 | -------------------------------------------------------------------------------- /libnfc-1.7.1/libnfc/buses/Makefile.am: -------------------------------------------------------------------------------- 1 | # set the include path found by configure 2 | AM_CPPFLAGS = $(all_includes) $(LIBNFC_CFLAGS) 3 | 4 | noinst_LTLIBRARIES = libnfcbuses.la 5 | 6 | libnfcbuses_la_SOURCES = empty.c 7 | libnfcbuses_la_CFLAGS = -I$(top_srcdir)/libnfc 8 | libnfcbuses_la_LIBADD = 9 | EXTRA_DIST = 10 | 11 | if SPI_ENABLED 12 | libnfcbuses_la_SOURCES += spi.c spi.h 13 | libnfcbuses_la_CFLAGS += 14 | libnfcbuses_la_LIBADD += 15 | endif 16 | EXTRA_DIST += spi.c spi.h 17 | 18 | if UART_ENABLED 19 | libnfcbuses_la_SOURCES += uart.c uart.h 20 | libnfcbuses_la_CFLAGS += 21 | libnfcbuses_la_LIBADD += 22 | endif 23 | EXTRA_DIST += uart.c uart.h 24 | 25 | if LIBUSB_ENABLED 26 | libnfcbuses_la_SOURCES += usbbus.c usbbus.h 27 | libnfcbuses_la_CFLAGS += @libusb_CFLAGS@ 28 | libnfcbuses_la_LIBADD += @libusb_LIBS@ 29 | endif 30 | EXTRA_DIST += usbbus.c usbbus.h 31 | 32 | if I2C_ENABLED 33 | libnfcbuses_la_SOURCES += i2c.c i2c.h 34 | libnfcbuses_la_CFLAGS += 35 | libnfcbuses_la_LIBADD += 36 | endif 37 | EXTRA_DIST += i2c.c i2c.h 38 | -------------------------------------------------------------------------------- /libnfc-1.7.1/examples/pn53x-tamashell-scripts/ASK_LoGO_LEDs.cmd: -------------------------------------------------------------------------------- 1 | # To be used only on ASK LoGO readers!!! 2 | # As we don't know how GPIO can be wired, it may hurt your hardware!!! 3 | 4 | # P32=0 LED1 5 | # P34=0 progressive field off 6 | # SFR_P3: 0x..101011 7 | 08 ff b0 2b 8 | 9 | p 100 10 | 11 | # P32=0 LED1 12 | # P31=0 LED2 13 | # SFR_P3: 0x..101001 14 | 08 ff b0 29 15 | 16 | p 100 17 | 18 | # P32=0 LED1 19 | # P31=0 LED2 20 | # P30=0 P33=0 LED3 21 | # SFR_P3: 0x..100000 22 | 08 ff b0 20 23 | 24 | p 100 25 | 26 | # P32=0 LED1 27 | # P31=0 LED2 28 | # P30=0 P33=0 LED3 29 | # P35=0 LED4 30 | # SFR_P3: 0x..000000 31 | 08 ff b0 00 32 | 33 | p 100 34 | 35 | # P32=0 LED1 36 | # P31=0 LED2 37 | # P30=0 P33=0 LED3 38 | # SFR_P3: 0x..100000 39 | 08 ff b0 20 40 | 41 | p 100 42 | 43 | # P32=0 LED1 44 | # P31=0 LED2 45 | # SFR_P3: 0x..101001 46 | 08 ff b0 29 47 | 48 | p 100 49 | 50 | # P32=0 LED1 51 | # SFR_P3: 0x..101011 52 | 08 ff b0 2b 53 | 54 | p 100 55 | 56 | # P32=0 LED1 57 | # SFR_P3: 0x..101011 58 | 08 ff b0 2b 59 | -------------------------------------------------------------------------------- /libnfc-1.7.1/contrib/devd/pn53x.conf: -------------------------------------------------------------------------------- 1 | # FreeBSD devd(8) rules for PN531 & PN533 devices. 2 | 3 | attach 110 { 4 | match "vendor" "0x04cc"; 5 | match "product" "(0x0531|0x2533)"; 6 | action "/usr/bin/chgrp nfc /dev/$device-name"; 7 | action "/bin/chmod g+rw /dev/$device-name"; 8 | }; 9 | 10 | attach 110 { 11 | match "vendor" "0x04e6"; 12 | match "product" "0x5591"; 13 | action "/usr/bin/chgrp nfc /dev/$device-name"; 14 | action "/bin/chmod g+rw /dev/$device-name"; 15 | }; 16 | 17 | attach 110 { 18 | match "vendor" "0x054c"; 19 | match "product" "0x0193"; 20 | action "/usr/bin/chgrp nfc /dev/$device-name"; 21 | action "/bin/chmod g+rw /dev/$device-name"; 22 | }; 23 | 24 | attach 110 { 25 | match "vendor" "0x1fd3"; 26 | match "product" "0x0608"; 27 | action "/usr/bin/chgrp nfc /dev/$device-name"; 28 | action "/bin/chmod g+rw /dev/$device-name"; 29 | }; 30 | 31 | attach 110 { 32 | match "vendor" "0x054c"; 33 | match "product" "0x02e1"; 34 | action "/usr/bin/chgrp nfc /dev/$device-name"; 35 | action "/bin/chmod g+rw /dev/$device-name"; 36 | }; 37 | -------------------------------------------------------------------------------- /libnfc-1.7.1/libnfc.conf.sample: -------------------------------------------------------------------------------- 1 | # Allow device auto-detection (default: true) 2 | # Note: if this auto-detection is disabled, user has to set manually a device 3 | # configuration using file or environment variable 4 | #allow_autoscan = true 5 | 6 | # Allow intrusive auto-detection (default: false) 7 | # Warning: intrusive auto-detection can seriously disturb other devices 8 | # This option is not recommended, user should prefer to add manually his device. 9 | #allow_intrusive_scan = false 10 | 11 | # Set log level (default: error) 12 | # Valid log levels are (in order of verbosity): 0 (none), 1 (error), 2 (info), 3 (debug) 13 | # Note: if you compiled with --enable-debug option, the default log level is "debug" 14 | #log_level = 1 15 | 16 | # Manually set default device (no default) 17 | # To set a default device, you must set both name and connstring for your device 18 | # Note: if autoscan is enabled, default device will be the first device available in device list. 19 | #device.name = "microBuilder.eu" 20 | #device.connstring = "pn532_uart:/dev/ttyUSB0" 21 | -------------------------------------------------------------------------------- /libnfc-1.7.1/cmake/modules/FindPCSC.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find the PC/SC smart card library 2 | # Once done this will define 3 | # 4 | # PCSC_FOUND - system has the PC/SC library 5 | # PCSC_INCLUDE_DIRS - the PC/SC include directory 6 | # PCSC_LIBRARIES - The libraries needed to use PC/SC 7 | # 8 | # Author: F. Kooman 9 | # Version: 20101019 10 | # 11 | 12 | FIND_PACKAGE (PkgConfig) 13 | IF(PKG_CONFIG_FOUND) 14 | # Will find PC/SC library on Linux/BSDs using PkgConfig 15 | PKG_CHECK_MODULES(PCSC libpcsclite) 16 | # PKG_CHECK_MODULES(PCSC QUIET libpcsclite) # IF CMake >= 2.8.2? 17 | ENDIF(PKG_CONFIG_FOUND) 18 | 19 | IF(NOT PCSC_FOUND) 20 | # Will find PC/SC headers both on Mac and Windows 21 | FIND_PATH(PCSC_INCLUDE_DIRS WinSCard.h) 22 | # PCSC library is for Mac, WinSCard library is for Windows 23 | FIND_LIBRARY(PCSC_LIBRARIES NAMES PCSC libwinscard) 24 | ENDIF(NOT PCSC_FOUND) 25 | 26 | INCLUDE(FindPackageHandleStandardArgs) 27 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCSC DEFAULT_MSG 28 | PCSC_LIBRARIES 29 | PCSC_INCLUDE_DIRS 30 | ) 31 | MARK_AS_ADVANCED(PCSC_INCLUDE_DIRS PCSC_LIBRARIES) 32 | -------------------------------------------------------------------------------- /libnfc-1.7.1/test/test_register_endianness.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #define MAX_DEVICE_COUNT 1 6 | #define MAX_TARGET_COUNT 1 7 | 8 | void test_register_endianness(void); 9 | 10 | #include "chips/pn53x.h" 11 | 12 | void 13 | test_register_endianness(void) 14 | { 15 | nfc_connstring connstrings[MAX_DEVICE_COUNT]; 16 | int res = 0; 17 | 18 | nfc_context *context; 19 | nfc_init(&context); 20 | 21 | size_t device_count = nfc_list_devices(context, connstrings, MAX_DEVICE_COUNT); 22 | if (!device_count) 23 | cut_omit("No NFC device found"); 24 | 25 | nfc_device *device; 26 | 27 | device = nfc_open(context, connstrings[0]); 28 | cut_assert_not_null(device, cut_message("nfc_open")); 29 | 30 | uint8_t value; 31 | 32 | /* Read valid XRAM memory */ 33 | res = pn53x_read_register(device, 0xF0FF, &value); 34 | cut_assert_equal_int(0, res, cut_message("read register 0xF0FF")); 35 | 36 | /* Read invalid SFR register */ 37 | res = pn53x_read_register(device, 0xFFF0, &value); 38 | cut_assert_equal_int(-1, res, cut_message("read register 0xFFF0")); 39 | 40 | nfc_close(device); 41 | nfc_exit(context); 42 | } 43 | -------------------------------------------------------------------------------- /libnfc-1.7.1/examples/nfc-dep-target.1: -------------------------------------------------------------------------------- 1 | .TH nfc-dep-target 1 "October 8, 2010" "libnfc" "libnfc's examples" 2 | .SH NAME 3 | nfc-dep-target \- Demonstration tool to send/received data as D.E.P. target 4 | .SH SYNOPSIS 5 | .B nfc-dep-target 6 | .SH DESCRIPTION 7 | .B nfc-dep-target 8 | is a demonstration tool for putting NFC device in D.E.P. target mode. 9 | 10 | This example will listen for a D.E.P. initiator and exchange a simple "Hello" 11 | data with initiator. 12 | 13 | Note: this example is designed to work with a D.E.P. initiator driven by 14 | \fBnfc-dep-initiator\fP. 15 | 16 | .SH BUGS 17 | Please report any bugs on the 18 | .B libnfc 19 | issue tracker at: 20 | .br 21 | .BR http://code.google.com/p/libnfc/issues 22 | .SH LICENCE 23 | .B libnfc 24 | is licensed under the GNU Lesser General Public License (LGPL), version 3. 25 | .br 26 | .B libnfc-utils 27 | and 28 | .B libnfc-examples 29 | are covered by the the BSD 2-Clause license. 30 | .SH AUTHORS 31 | Roel Verdult , 32 | .br 33 | Romuald Conty . 34 | .PP 35 | This manual page was written by Romuald Conty . 36 | It is licensed under the terms of the GNU GPL (version 2 or later). 37 | -------------------------------------------------------------------------------- /libnfc-1.7.1/contrib/win32/sys/select.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Free/Libre Near Field Communication (NFC) library 3 | * 4 | * Libnfc historical contributors: 5 | * Copyright (C) 2009 Roel Verdult 6 | * Copyright (C) 2009-2013 Romuald Conty 7 | * Copyright (C) 2010-2012 Romain Tartière 8 | * Copyright (C) 2010-2013 Philippe Teuwen 9 | * Copyright (C) 2012-2013 Ludovic Rousseau 10 | * 11 | * This program is free software: you can redistribute it and/or modify it 12 | * under the terms of the GNU Lesser General Public License as published by the 13 | * Free Software Foundation, either version 3 of the License, or (at your 14 | * option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, but WITHOUT 17 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 18 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 19 | * more details. 20 | * 21 | * You should have received a copy of the GNU Lesser General Public License 22 | * along with this program. If not, see 23 | */ 24 | 25 | /** 26 | * @file select.h 27 | * @brief Dummy file to make the code compile under Windows 28 | */ 29 | 30 | -------------------------------------------------------------------------------- /libnfc-1.7.1/examples/nfc-dep-initiator.1: -------------------------------------------------------------------------------- 1 | .TH nfc-dep-initiator 1 "October 8, 2010" "libnfc" "libnfc's examples" 2 | .SH NAME 3 | nfc-dep-initiator \- Demonstration tool to send/received data as D.E.P. initiator 4 | .SH SYNOPSIS 5 | .B nfc-dep-initiator 6 | .SH DESCRIPTION 7 | .B nfc-dep-initiator 8 | is a demonstration tool for putting NFC device in D.E.P. initiator mode. 9 | 10 | This example will attempt to select a passive D.E.P. target and exchange a 11 | simple "Hello" data with target. 12 | 13 | Note: this example is designed to work with a D.E.P. target driven by 14 | \fBnfc-dep-target\fP 15 | 16 | .SH BUGS 17 | Please report any bugs on the 18 | .B libnfc 19 | issue tracker at: 20 | .br 21 | .BR http://code.google.com/p/libnfc/issues 22 | .SH LICENCE 23 | .B libnfc 24 | is licensed under the GNU Lesser General Public License (LGPL), version 3. 25 | .br 26 | .B libnfc-utils 27 | and 28 | .B libnfc-examples 29 | are covered by the the BSD 2-Clause license. 30 | .SH AUTHORS 31 | Roel Verdult , 32 | .br 33 | Romuald Conty . 34 | .PP 35 | This manual page was written by Romuald Conty . 36 | It is licensed under the terms of the GNU GPL (version 2 or later). 37 | -------------------------------------------------------------------------------- /libnfc-1.7.1/examples/pn53x-sam.1: -------------------------------------------------------------------------------- 1 | .TH pn53x-sam 1 "June 15, 2010" "libnfc" "libnfc's examples" 2 | .SH NAME 3 | pn53x-sam \- PN53x SAM communication demonstration tool 4 | .SH SYNOPSIS 5 | .B pn53x-sam 6 | .SH DESCRIPTION 7 | .B pn53x-sam 8 | is a utility attempt to test a simple connection with a SAM (Secure Access 9 | Module) in several modes. 10 | 11 | To run this utility you must have a SAM (like the NXP's P5CN072 chip) 12 | successfully connected to your PN53x chip. 13 | 14 | Warning: the SAM inside a Touchatag/ACR122U is \fInot\fP hooked to the PN532 15 | but to the intermediate controller so \fBpn53x-sam\fP won't work with a Touchatag/ACR122U. 16 | 17 | .SH BUGS 18 | Please report any bugs on the 19 | .B libnfc 20 | issue tracker at: 21 | .br 22 | .BR http://code.google.com/p/libnfc/issues 23 | .SH LICENCE 24 | .B libnfc 25 | is licensed under the GNU Lesser General Public License (LGPL), version 3. 26 | .br 27 | .B libnfc-utils 28 | and 29 | .B libnfc-examples 30 | are covered by the the BSD 2-Clause license. 31 | .SH AUTHORS 32 | Emanuele Bertoldi 33 | .PP 34 | This manual page was written by Emanuele Bertoldi . 35 | It is licensed under the terms of the GNU GPL (version 2 or later). 36 | -------------------------------------------------------------------------------- /libnfc-1.7.1/contrib/win32/version.rc.in: -------------------------------------------------------------------------------- 1 | #include "windows.h" 2 | 3 | 1 VERSIONINFO 4 | FILEVERSION @VERSION_MAJOR@,@VERSION_MINOR@,@VERSION_PATCH@,0 5 | PRODUCTVERSION @VERSION_MAJOR@,@VERSION_MINOR@,@VERSION_PATCH@,0 6 | FILEFLAGSMASK 0x3fL 7 | #ifdef _DEBUG 8 | FILEFLAGS VS_FF_DEBUG|VS_FF_PRERELEASE 9 | #else 10 | FILEFLAGS 0L 11 | #endif 12 | FILEOS VOS_NT_WINDOWS32 13 | FILETYPE @RC_FILE_TYPE@ 14 | FILESUBTYPE 0x0L 15 | BEGIN 16 | BLOCK "StringFileInfo" 17 | BEGIN 18 | BLOCK "040904e4" 19 | BEGIN 20 | VALUE "Comments", "@RC_COMMENT@\0" 21 | VALUE "CompanyName", "libnfc.org\0" 22 | VALUE "FileDescription", "\0" 23 | VALUE "FileVersion", "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@.0\0" 24 | VALUE "InternalName", "@RC_INTERNAL_NAME@ @WIN32_MODE@\0" 25 | VALUE "LegalCopyright", "Copyright (C) @CURRENT_YEAR@\0" 26 | VALUE "OriginalFilename", "@RC_ORIGINAL_NAME@\0" 27 | VALUE "ProductName", "@PACKAGE_NAME@ @WIN32_MODE@\0" 28 | VALUE "ProductVersion", "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@.0\0" 29 | END 30 | END 31 | BLOCK "VarFileInfo" 32 | BEGIN 33 | VALUE "Translation", 0x0409, 1252 34 | END 35 | END 36 | -------------------------------------------------------------------------------- /libnfc-1.7.1/examples/nfc-mfsetuid.1: -------------------------------------------------------------------------------- 1 | .TH nfc-mfsetuid 1 "Sep 05, 2011" "libnfc" "NFC Utilities" 2 | .SH NAME 3 | nfc-mfsetuid \- MIFARE 1K special card UID setting and recovery tool 4 | .SH SYNOPSIS 5 | .B nfc-mfsetuid 6 | [ 7 | .I UID 8 | ] 9 | 10 | .SH DESCRIPTION 11 | .B nfc-mfsetuid 12 | is a MIFARE tool that allows setting of UID on special versions (Chinese clones) of Mifare 1K cards. It will also recover 13 | damaged cards that have had invalid data written to block 0 (e.g. wrong BCC). Currently only 4 Byte UID is supported. 14 | Specify an eight hex character UID or leave blank for the default '01234567'. 15 | 16 | .SH OPTIONS 17 | .B -f 18 | Format. Wipe all data (set to 0xFF) and reset ACLs to defaults. 19 | 20 | .B -q 21 | Quiet. Suppress output of commands and responses. 22 | .SH BUGS 23 | Please report any bugs on the 24 | .B libnfc 25 | issue tracker at: 26 | .br 27 | .BR http://code.google.com/p/libnfc/issues 28 | .SH LICENCE 29 | .B libnfc 30 | is licensed under the GNU Lesser General Public License (LGPL), version 3. 31 | .br 32 | .B libnfc-utils 33 | and 34 | .B libnfc-examples 35 | are covered by the the BSD 2-Clause license. 36 | .SH AUTHORS 37 | Adam Laurie 38 | .PP 39 | This manual page was written by Adam Laurie . 40 | It is licensed under the terms of the GNU GPL (version 2 or later). 41 | -------------------------------------------------------------------------------- /libnfc-1.7.1/libnfc/conf.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Free/Libre Near Field Communication (NFC) library 3 | * 4 | * Libnfc historical contributors: 5 | * Copyright (C) 2009 Roel Verdult 6 | * Copyright (C) 2009-2013 Romuald Conty 7 | * Copyright (C) 2010-2012 Romain Tartière 8 | * Copyright (C) 2010-2013 Philippe Teuwen 9 | * Copyright (C) 2012-2013 Ludovic Rousseau 10 | * See AUTHORS file for a more comprehensive list of contributors. 11 | * Additional contributors of this file: 12 | * 13 | * This program is free software: you can redistribute it and/or modify it 14 | * under the terms of the GNU Lesser General Public License as published by the 15 | * Free Software Foundation, either version 3 of the License, or (at your 16 | * option) any later version. 17 | * 18 | * This program is distributed in the hope that it will be useful, but WITHOUT 19 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 21 | * more details. 22 | * 23 | * You should have received a copy of the GNU Lesser General Public License 24 | * along with this program. If not, see 25 | */ 26 | #ifndef __NFC_CONF_H__ 27 | #define __NFC_CONF_H__ 28 | 29 | #include 30 | 31 | void conf_load(nfc_context *context); 32 | 33 | #endif // __NFC_CONF_H__ 34 | 35 | -------------------------------------------------------------------------------- /libnfc-1.7.1/utils/nfc-read-forum-tag3.1: -------------------------------------------------------------------------------- 1 | .TH nfc-read-forum-tag3 1 "November 22, 2011" "libnfc" "NFC Utilities" 2 | .SH NAME 3 | nfc-read-forum-tag3 \- Extract NDEF Message from a NFC Forum Tag Type 3 4 | .SH SYNOPSIS 5 | .B nfc-read-forum-tag3 6 | .RI [ 7 | .RI \fR\fB\-q\fR 8 | .RI ] 9 | .RI \fR\fB\-o\fR 10 | .IR FILE 11 | .SH DESCRIPTION 12 | .B nfc-read-forum-tag3 13 | This utility extracts (if available) NDEF Messages contained in a NFC Forum Tag Type 3 to 14 | .IR FILE 15 | . 16 | .SH OPTIONS 17 | \fR\fB\-o\fR 18 | .IR FILE 19 | : output extracted NDEF Message to 20 | .IR FILE 21 | (use 22 | \fR\fB\-o \-\fR 23 | to output to stdout) 24 | 25 | \fR\fB\-q\fR 26 | : be quiet, don't display Attribute Block parsing info 27 | 28 | .SH BUGS 29 | Please report any bugs on the 30 | .B libnfc 31 | issue tracker at: 32 | .br 33 | .BR http://code.google.com/p/libnfc/issues 34 | .SH LICENCE 35 | .B libnfc 36 | is licensed under the GNU Lesser General Public License (LGPL), version 3. 37 | .br 38 | .B libnfc-utils 39 | and 40 | .B libnfc-examples 41 | are covered by the the BSD 2-Clause license. 42 | .SH AUTHORS 43 | Roel Verdult , 44 | .br 45 | Romain Tartière , 46 | .br 47 | Romuald Conty . 48 | .PP 49 | This manual page was written by Audrey Diacre . 50 | It is licensed under the terms of the GNU GPL (version 2 or later). -------------------------------------------------------------------------------- /libnfc-1.7.1/contrib/win32/nfc.def: -------------------------------------------------------------------------------- 1 | LIBRARY libnfc 2 | VERSION 1.7 3 | 4 | EXPORTS 5 | nfc_init 6 | nfc_exit 7 | nfc_open 8 | nfc_close 9 | nfc_abbort_command 10 | nfc_list_devices 11 | nfc_idle 12 | nfc_initiator_init 13 | nfc_initiator_init_secure_element 14 | nfc_initiator_select_passive_target 15 | nfc_initiator_list_passive_targets 16 | nfc_initiator_poll_target 17 | nfc_initiator_select_dep_target 18 | nfc_initiator_poll_dep_target 19 | nfc_initiator_deselect_target 20 | nfc_initiator_poll_targets 21 | nfc_initiator_transceive_bytes 22 | nfc_initiator_transceive_bits 23 | nfc_initiator_transceive_bytes_timed 24 | nfc_initiator_transceive_bits_timed 25 | nfc_initiator_target_is_present 26 | nfc_target_init 27 | nfc_target_send_bytes 28 | nfc_target_receive_bytes 29 | nfc_target_send_bits 30 | nfc_target_receive_bits 31 | nfc_strerror 32 | nfc_strerror_r 33 | nfc_perror 34 | nfc_device_get_last_error 35 | nfc_device_get_name 36 | nfc_device_get_connstring 37 | nfc_device_get_supported_modulation 38 | nfc_device_get_supported_baud_rate 39 | nfc_device_set_property_int 40 | nfc_device_set_property_bool 41 | iso14443a_crc 42 | iso14443a_crc_append 43 | iso14443a_locate_historical_bytes 44 | nfc_version 45 | nfc_device_get_information_about 46 | str_nfc_modulation_type 47 | str_nfc_baud_rate 48 | str_nfc_target 49 | -------------------------------------------------------------------------------- /libnfc-1.7.1/m4/libnfc_check_pcsc.m4: -------------------------------------------------------------------------------- 1 | dnl Check for PCSC presence (if required) 2 | dnl On success, HAVE_PCSC is set to 1 and PKG_CONFIG_REQUIRES is filled when 3 | dnl libpcsclite is found using pkg-config 4 | 5 | AC_DEFUN([LIBNFC_CHECK_PCSC], 6 | [ 7 | if test "x$pcsc_required" = "xyes"; then 8 | PKG_CHECK_MODULES([libpcsclite], [libpcsclite], [HAVE_PCSC=1], [HAVE_PCSC=0]) 9 | if test x"$HAVE_PCSC" = "x1" ; then 10 | if test x"$PKG_CONFIG_REQUIRES" != x""; then 11 | PKG_CONFIG_REQUIRES="$PKG_CONFIG_REQUIRES," 12 | fi 13 | PKG_CONFIG_REQUIRES="$PKG_CONFIG_REQUIRES libpcsclite" 14 | fi 15 | case "$host" in 16 | *darwin*) 17 | if test x"$HAVE_PCSC" = "x0" ; then 18 | AC_MSG_CHECKING(for PC/SC) 19 | libpcsclite_LIBS="-Wl,-framework,PCSC" 20 | libpcsclite_CFLAGS="" 21 | HAVE_PCSC=1 22 | AC_MSG_RESULT(yes: darwin PC/SC framework) 23 | fi 24 | ;; 25 | *mingw*) 26 | dnl FIXME Find a way to cross-compile for Windows 27 | HAVE_PCSC=0 28 | AC_MSG_RESULT(no: Windows PC/SC framework) 29 | ;; 30 | *) 31 | if test x"$HAVE_PCSC" = "x0" ; then 32 | AC_MSG_ERROR([libpcsclite is required for building the acr122_pcsc driver.]) 33 | fi 34 | ;; 35 | esac 36 | AC_SUBST(libpcsclite_LIBS) 37 | AC_SUBST(libpcsclite_CFLAGS) 38 | fi 39 | ]) 40 | -------------------------------------------------------------------------------- /libnfc-1.7.1/cmake/modules/FindPCRE.cmake: -------------------------------------------------------------------------------- 1 | # This CMake script wants to use pcre functionality needed for windows 2 | # compilation. However, since PCRE isn't really a default install location 3 | # there isn't much to search. 4 | # 5 | # Operating Systems Supported: 6 | # - Windows (requires MinGW) 7 | # Tested with Windows XP/Windows 7 8 | # 9 | # This should work for both 32 bit and 64 bit systems. 10 | # 11 | # Author: A. Lian 12 | # 13 | 14 | IF(WIN32) 15 | IF(NOT PCRE_FOUND) 16 | FIND_PATH(PCRE_INCLUDE_DIRS regex.h) 17 | FIND_LIBRARY(PCRE_LIBRARIES NAMES PCRE pcre) 18 | FIND_PATH(PCRE_BIN_DIRS pcre3.dll) 19 | 20 | IF(PCRE_INCLUDE_DIRS AND PCRE_LIBRARIES AND PCRE_BIN_DIRS) 21 | SET(PCRE_FOUND TRUE) 22 | ENDIF(PCRE_INCLUDE_DIRS AND PCRE_LIBRARIES AND PCRE_BIN_DIRS) 23 | ENDIF(NOT PCRE_FOUND) 24 | 25 | IF(PCRE_FOUND) 26 | IF(NOT PCRE_FIND_QUIETLY) 27 | MESSAGE(STATUS "Found PCRE: ${PCRE_LIBRARIES} ${PCRE_INCLUDE_DIRS} ${PCRE_BIN_DIRS}") 28 | ENDIF (NOT PCRE_FIND_QUIETLY) 29 | ELSE(PCRE_FOUND) 30 | IF(PCRE_FIND_REQUIRED) 31 | MESSAGE(FATAL_ERROR "Could not find PCRE") 32 | ENDIF(PCRE_FIND_REQUIRED) 33 | ENDIF(PCRE_FOUND) 34 | 35 | INCLUDE(FindPackageHandleStandardArgs) 36 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE DEFAULT_MSG 37 | PCRE_LIBRARIES 38 | PCRE_INCLUDE_DIRS 39 | PCRE_BIN_DIRS 40 | ) 41 | 42 | ENDIF(WIN32) 43 | -------------------------------------------------------------------------------- /libnfc-1.7.1/cmake/modules/COPYING-CMAKE-SCRIPTS: -------------------------------------------------------------------------------- 1 | Redistribution and use in source and binary forms, with or without 2 | modification, are permitted provided that the following conditions 3 | are met: 4 | 5 | 1. Redistributions of source code must retain the copyright 6 | notice, this list of conditions and the following disclaimer. 7 | 2. Redistributions in binary form must reproduce the copyright 8 | notice, this list of conditions and the following disclaimer in the 9 | documentation and/or other materials provided with the distribution. 10 | 3. The name of the author may not be used to endorse or promote products 11 | derived from this software without specific prior written permission. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 14 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 15 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 16 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 17 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 18 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 19 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 20 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 | -------------------------------------------------------------------------------- /libnfc-1.7.1/examples/nfc-relay.1: -------------------------------------------------------------------------------- 1 | .TH nfc-relay 1 "June 26, 2009" "libnfc" "libnfc'examples" 2 | .SH NAME 3 | nfc-relay \- Relay attack command line tool based on libnfc 4 | .SH SYNOPSIS 5 | .B nfc-relay 6 | .SH DESCRIPTION 7 | .B nfc-relay 8 | is a utility that demonstrates a relay attack. 9 | 10 | This tool requires two NFC devices. One device (configured as target) will 11 | emulate an ISO/IEC 14443 type A tag, while the second device (configured as 12 | initiator) will act as a reader. The genuine tag can be placed on the second 13 | device (initiator) and the tag emulator (target) can be placed close to the 14 | original reader. All communication is now relayed and shown in the screen on 15 | real-time. 16 | 17 | This tool has the same issues regarding timing as \fBnfc-emulate-uid\fP has, 18 | therefore we advise you to try it against e.g. an OmniKey CardMan 5321 reader. 19 | 20 | .SH BUGS 21 | Please report any bugs on the 22 | .B libnfc 23 | issue tracker at: 24 | .br 25 | .BR http://code.google.com/p/libnfc/issues 26 | .SH LICENCE 27 | .B libnfc 28 | is licensed under the GNU Lesser General Public License (LGPL), version 3. 29 | .br 30 | .B libnfc-utils 31 | and 32 | .B libnfc-examples 33 | are covered by the the BSD 2-Clause license. 34 | .SH AUTHORS 35 | Roel Verdult 36 | .PP 37 | This manual page was written by Romuald Conty . 38 | It is licensed under the terms of the GNU GPL (version 2 or later). 39 | -------------------------------------------------------------------------------- /libnfc-1.7.1/libnfc/drivers/Makefile.am: -------------------------------------------------------------------------------- 1 | # set the include path found by configure 2 | AM_CPPFLAGS = $(all_includes) $(LIBNFC_CFLAGS) 3 | 4 | noinst_LTLIBRARIES = libnfcdrivers.la 5 | 6 | libnfcdrivers_la_SOURCES = 7 | libnfcdrivers_la_CFLAGS = @DRIVERS_CFLAGS@ -I$(top_srcdir)/libnfc -I$(top_srcdir)/libnfc/buses 8 | libnfcdrivers_la_LIBADD = 9 | 10 | if DRIVER_ACR122_PCSC_ENABLED 11 | libnfcdrivers_la_SOURCES += acr122_pcsc.c acr122_pcsc.h 12 | endif 13 | 14 | if DRIVER_ACR122_USB_ENABLED 15 | libnfcdrivers_la_SOURCES += acr122_usb.c acr122_usb.h 16 | endif 17 | 18 | if DRIVER_ACR122S_ENABLED 19 | libnfcdrivers_la_SOURCES += acr122s.c acr122s.h 20 | endif 21 | 22 | if DRIVER_ARYGON_ENABLED 23 | libnfcdrivers_la_SOURCES += arygon.c arygon.h 24 | endif 25 | 26 | if DRIVER_PN53X_USB_ENABLED 27 | libnfcdrivers_la_SOURCES += pn53x_usb.c pn53x_usb.h 28 | endif 29 | 30 | if DRIVER_PN532_UART_ENABLED 31 | libnfcdrivers_la_SOURCES += pn532_uart.c pn532_uart.h 32 | endif 33 | 34 | if DRIVER_PN532_SPI_ENABLED 35 | libnfcdrivers_la_SOURCES += pn532_spi.c pn532_spi.h 36 | endif 37 | 38 | if DRIVER_PN532_I2C_ENABLED 39 | libnfcdrivers_la_SOURCES += pn532_i2c.c pn532_i2c.h 40 | endif 41 | 42 | if PCSC_ENABLED 43 | libnfcdrivers_la_CFLAGS += @libpcsclite_CFLAGS@ 44 | libnfcdrivers_la_LIBADD += @libpcsclite_LIBS@ 45 | endif 46 | 47 | if LIBUSB_ENABLED 48 | libnfcdrivers_la_CFLAGS += @libusb_CFLAGS@ 49 | libnfcdrivers_la_LIBADD += @libusb_LIBS@ 50 | endif 51 | 52 | -------------------------------------------------------------------------------- /libnfc-1.7.1/libnfc/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = chips buses drivers . 2 | 3 | # set the include path found by configure 4 | AM_CPPFLAGS = $(all_includes) $(LIBNFC_CFLAGS) -DSYSCONFDIR='"$(sysconfdir)"' 5 | 6 | lib_LTLIBRARIES = libnfc.la 7 | libnfc_la_SOURCES = \ 8 | conf.c \ 9 | iso14443-subr.c \ 10 | mirror-subr.c \ 11 | nfc.c \ 12 | nfc-device.c \ 13 | nfc-emulation.c \ 14 | nfc-internal.c \ 15 | target-subr.c \ 16 | conf.h \ 17 | drivers.h \ 18 | iso7816.h \ 19 | log.h \ 20 | log-internal.h \ 21 | mirror-subr.h \ 22 | nfc-internal.h \ 23 | target-subr.h 24 | 25 | libnfc_la_LDFLAGS = -no-undefined -version-info 5:1:0 -export-symbols-regex '^nfc_|^iso14443a_|^str_nfc_|pn53x_transceive|pn532_SAMConfiguration|pn53x_read_register|pn53x_write_register' 26 | libnfc_la_CFLAGS = @DRIVERS_CFLAGS@ 27 | libnfc_la_LIBADD = \ 28 | $(top_builddir)/libnfc/chips/libnfcchips.la \ 29 | $(top_builddir)/libnfc/buses/libnfcbuses.la \ 30 | $(top_builddir)/libnfc/drivers/libnfcdrivers.la 31 | 32 | if PCSC_ENABLED 33 | libnfc_la_CFLAGS += @libpcsclite_CFLAGS@ -DHAVE_PCSC 34 | libnfc_la_LIBADD += @libpcsclite_LIBS@ 35 | endif 36 | 37 | if LIBUSB_ENABLED 38 | libnfc_la_CFLAGS += @libusb_CFLAGS@ -DHAVE_LIBUSB 39 | libnfc_la_LIBADD += @libusb_LIBS@ 40 | endif 41 | 42 | if WITH_LOG 43 | libnfc_la_SOURCES += log.c log-internal.c 44 | endif 45 | 46 | EXTRA_DIST = \ 47 | CMakeLists.txt 48 | -------------------------------------------------------------------------------- /libnfc-1.7.1/libnfc/drivers.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Free/Libre Near Field Communication (NFC) library 3 | * 4 | * Libnfc historical contributors: 5 | * Copyright (C) 2009 Roel Verdult 6 | * Copyright (C) 2009-2013 Romuald Conty 7 | * Copyright (C) 2010-2012 Romain Tartière 8 | * Copyright (C) 2010-2013 Philippe Teuwen 9 | * Copyright (C) 2012-2013 Ludovic Rousseau 10 | * See AUTHORS file for a more comprehensive list of contributors. 11 | * Additional contributors of this file: 12 | * 13 | * This program is free software: you can redistribute it and/or modify it 14 | * under the terms of the GNU Lesser General Public License as published by the 15 | * Free Software Foundation, either version 3 of the License, or (at your 16 | * option) any later version. 17 | * 18 | * This program is distributed in the hope that it will be useful, but WITHOUT 19 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 21 | * more details. 22 | * 23 | * You should have received a copy of the GNU Lesser General Public License 24 | * along with this program. If not, see 25 | */ 26 | 27 | /** 28 | * @file drivers.h 29 | * @brief Supported drivers header 30 | */ 31 | 32 | #ifndef __NFC_DRIVERS_H__ 33 | #define __NFC_DRIVERS_H__ 34 | 35 | #include 36 | 37 | extern const struct nfc_driver_list *nfc_drivers; 38 | 39 | #endif // __NFC_DRIVERS_H__ 40 | -------------------------------------------------------------------------------- /libnfc-1.7.1/libnfc/drivers/acr122s.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Free/Libre Near Field Communication (NFC) library 3 | * 4 | * Libnfc historical contributors: 5 | * Copyright (C) 2009 Roel Verdult 6 | * Copyright (C) 2009-2013 Romuald Conty 7 | * Copyright (C) 2010-2012 Romain Tartière 8 | * Copyright (C) 2010-2013 Philippe Teuwen 9 | * Copyright (C) 2012-2013 Ludovic Rousseau 10 | * See AUTHORS file for a more comprehensive list of contributors. 11 | * Additional contributors of this file: 12 | * 13 | * This program is free software: you can redistribute it and/or modify it 14 | * under the terms of the GNU Lesser General Public License as published by the 15 | * Free Software Foundation, either version 3 of the License, or (at your 16 | * option) any later version. 17 | * 18 | * This program is distributed in the hope that it will be useful, but WITHOUT 19 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 21 | * more details. 22 | * 23 | * You should have received a copy of the GNU Lesser General Public License 24 | * along with this program. If not, see 25 | */ 26 | 27 | /** 28 | * @file acr122s.h 29 | * @brief Driver for ACS ACR122S devices 30 | */ 31 | 32 | #ifndef __NFC_DRIVER_ACR122S_H__ 33 | #define __NFC_DRIVER_ACR122S_H__ 34 | 35 | #include 36 | 37 | extern const struct nfc_driver acr122s_driver; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /libnfc-1.7.1/utils/nfc-jewel.1: -------------------------------------------------------------------------------- 1 | .TH nfc-jewel 1 "Feb 02, 2014" "libnfc" "NFC Utilities" 2 | .SH NAME 3 | nfc-jewel \- Jewel command line tool 4 | .SH SYNOPSIS 5 | .B nfc-jewel 6 | .RI \fR\fBr\fR|\fBw\fR 7 | .IR DUMP 8 | 9 | .SH DESCRIPTION 10 | .B nfc-jewel 11 | is a Jewel tool that allows one to read or write 12 | a tag data to/from a 13 | .IR DUMP 14 | file. 15 | 16 | Jewel tag by Broadcom, previously Innovision, uses a binary Dump file to store data for all sectors. 17 | 18 | Be cautious that some parts of a Jewel memory can be written only once 19 | and some parts are used as lock bits, so please read the tag documentation 20 | before experimenting too much! 21 | 22 | .SH OPTIONS 23 | .BR r " | " w 24 | Perform read from ( 25 | .B r 26 | ) or write to ( 27 | .B w 28 | ) card. 29 | .TP 30 | .IR DUMP 31 | JeWel Dump (JWD) used to write (card to JWD) or (JWD to card) 32 | 33 | .SH BUGS 34 | Please report any bugs on the 35 | .B libnfc 36 | issue tracker at: 37 | .br 38 | .BR http://code.google.com/p/libnfc/issues 39 | .SH LICENCE 40 | .B libnfc 41 | is licensed under the GNU Lesser General Public License (LGPL), version 3. 42 | .br 43 | .B libnfc-utils 44 | and 45 | .B libnfc-examples 46 | are covered by the the BSD 2-Clause license. 47 | 48 | .SH AUTHORS 49 | Roel Verdult , 50 | .br 51 | Romuald Conty . 52 | .PP 53 | This manual page was written by Romuald Conty . 54 | It is licensed under the terms of the GNU GPL (version 2 or later). 55 | -------------------------------------------------------------------------------- /libnfc-1.7.1/libnfc/drivers/pn53x_usb.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Free/Libre Near Field Communication (NFC) library 3 | * 4 | * Libnfc historical contributors: 5 | * Copyright (C) 2009 Roel Verdult 6 | * Copyright (C) 2009-2013 Romuald Conty 7 | * Copyright (C) 2010-2012 Romain Tartière 8 | * Copyright (C) 2010-2013 Philippe Teuwen 9 | * Copyright (C) 2012-2013 Ludovic Rousseau 10 | * See AUTHORS file for a more comprehensive list of contributors. 11 | * Additional contributors of this file: 12 | * 13 | * This program is free software: you can redistribute it and/or modify it 14 | * under the terms of the GNU Lesser General Public License as published by the 15 | * Free Software Foundation, either version 3 of the License, or (at your 16 | * option) any later version. 17 | * 18 | * This program is distributed in the hope that it will be useful, but WITHOUT 19 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 21 | * more details. 22 | * 23 | * You should have received a copy of the GNU Lesser General Public License 24 | * along with this program. If not, see 25 | */ 26 | 27 | /** 28 | * @file pn53x_usb.h 29 | * @brief Drive for PN53x USB devices 30 | */ 31 | 32 | #ifndef __NFC_DRIVER_PN53X_USB_H__ 33 | #define __NFC_DRIVER_PN53X_USB_H__ 34 | 35 | #include 36 | 37 | extern const struct nfc_driver pn53x_usb_driver; 38 | 39 | #endif // ! __NFC_DRIVER_PN53X_USB_H__ 40 | -------------------------------------------------------------------------------- /libnfc-1.7.1/libnfc/drivers/arygon.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Free/Libre Near Field Communication (NFC) library 3 | * 4 | * Libnfc historical contributors: 5 | * Copyright (C) 2009 Roel Verdult 6 | * Copyright (C) 2009-2013 Romuald Conty 7 | * Copyright (C) 2010-2012 Romain Tartière 8 | * Copyright (C) 2010-2013 Philippe Teuwen 9 | * Copyright (C) 2012-2013 Ludovic Rousseau 10 | * See AUTHORS file for a more comprehensive list of contributors. 11 | * Additional contributors of this file: 12 | * 13 | * This program is free software: you can redistribute it and/or modify it 14 | * under the terms of the GNU Lesser General Public License as published by the 15 | * Free Software Foundation, either version 3 of the License, or (at your 16 | * option) any later version. 17 | * 18 | * This program is distributed in the hope that it will be useful, but WITHOUT 19 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 21 | * more details. 22 | * 23 | * You should have received a copy of the GNU Lesser General Public License 24 | * along with this program. If not, see 25 | */ 26 | 27 | /** 28 | * @file arygon.h 29 | * @brief Driver for PN53x-equipped ARYGON device connected using UART 30 | */ 31 | 32 | #ifndef __NFC_DRIVER_ARYGON_H__ 33 | #define __NFC_DRIVER_ARYGON_H__ 34 | 35 | #include 36 | 37 | extern const struct nfc_driver arygon_driver; 38 | 39 | #endif // ! __NFC_DRIVER_ARYGON_H__ 40 | -------------------------------------------------------------------------------- /libnfc-1.7.1/libnfc/drivers/pn532_uart.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Free/Libre Near Field Communication (NFC) library 3 | * 4 | * Libnfc historical contributors: 5 | * Copyright (C) 2009 Roel Verdult 6 | * Copyright (C) 2009-2013 Romuald Conty 7 | * Copyright (C) 2010-2012 Romain Tartière 8 | * Copyright (C) 2010-2013 Philippe Teuwen 9 | * Copyright (C) 2012-2013 Ludovic Rousseau 10 | * See AUTHORS file for a more comprehensive list of contributors. 11 | * Additional contributors of this file: 12 | * 13 | * This program is free software: you can redistribute it and/or modify it 14 | * under the terms of the GNU Lesser General Public License as published by the 15 | * Free Software Foundation, either version 3 of the License, or (at your 16 | * option) any later version. 17 | * 18 | * This program is distributed in the hope that it will be useful, but WITHOUT 19 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 21 | * more details. 22 | * 23 | * You should have received a copy of the GNU Lesser General Public License 24 | * along with this program. If not, see 25 | */ 26 | 27 | /** 28 | * @file pn532_uart.h 29 | * @brief Driver for PN532 connected in UART (HSU) 30 | */ 31 | 32 | #ifndef __NFC_DRIVER_PN532_UART_H__ 33 | #define __NFC_DRIVER_PN532_UART_H__ 34 | 35 | #include 36 | 37 | extern const struct nfc_driver pn532_uart_driver; 38 | 39 | #endif // ! __NFC_DRIVER_PN532_UART_H__ 40 | -------------------------------------------------------------------------------- /libnfc-1.7.1/libnfc/drivers/acr122_pcsc.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Free/Libre Near Field Communication (NFC) library 3 | * 4 | * Libnfc historical contributors: 5 | * Copyright (C) 2009 Roel Verdult 6 | * Copyright (C) 2009-2013 Romuald Conty 7 | * Copyright (C) 2010-2012 Romain Tartière 8 | * Copyright (C) 2010-2013 Philippe Teuwen 9 | * Copyright (C) 2012-2013 Ludovic Rousseau 10 | * See AUTHORS file for a more comprehensive list of contributors. 11 | * Additional contributors of this file: 12 | * 13 | * This program is free software: you can redistribute it and/or modify it 14 | * under the terms of the GNU Lesser General Public License as published by the 15 | * Free Software Foundation, either version 3 of the License, or (at your 16 | * option) any later version. 17 | * 18 | * This program is distributed in the hope that it will be useful, but WITHOUT 19 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 21 | * more details. 22 | * 23 | * You should have received a copy of the GNU Lesser General Public License 24 | * along with this program. If not, see 25 | */ 26 | 27 | /** 28 | * @file acr122_pcsc.h 29 | * @brief Driver for ACR122 devices (behind PC/SC daemon) 30 | */ 31 | 32 | #ifndef __NFC_DRIVER_ACR122_PCSC_H__ 33 | #define __NFC_DRIVER_ACR122_PCSC_H__ 34 | 35 | #include 36 | 37 | extern const struct nfc_driver acr122_pcsc_driver; 38 | 39 | #endif // ! __NFC_DRIVER_ACR122_PCSC_H__ 40 | -------------------------------------------------------------------------------- /libnfc-1.7.1/libnfc/drivers/acr122_usb.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Free/Libre Near Field Communication (NFC) library 3 | * 4 | * Libnfc historical contributors: 5 | * Copyright (C) 2009 Roel Verdult 6 | * Copyright (C) 2009-2013 Romuald Conty 7 | * Copyright (C) 2010-2012 Romain Tartière 8 | * Copyright (C) 2010-2013 Philippe Teuwen 9 | * Copyright (C) 2012-2013 Ludovic Rousseau 10 | * See AUTHORS file for a more comprehensive list of contributors. 11 | * Additional contributors of this file: 12 | * 13 | * This program is free software: you can redistribute it and/or modify it 14 | * under the terms of the GNU Lesser General Public License as published by the 15 | * Free Software Foundation, either version 3 of the License, or (at your 16 | * option) any later version. 17 | * 18 | * This program is distributed in the hope that it will be useful, but WITHOUT 19 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 21 | * more details. 22 | * 23 | * You should have received a copy of the GNU Lesser General Public License 24 | * along with this program. If not, see 25 | */ 26 | 27 | /** 28 | * @file acr122_usb.h 29 | * @brief Driver for ACR122 devices using direct USB connection (without PCSC) 30 | */ 31 | 32 | #ifndef __NFC_DRIVER_ACR122_USB_H__ 33 | #define __NFC_DRIVER_ACR122_USB_H__ 34 | 35 | #include 36 | 37 | extern const struct nfc_driver acr122_usb_driver; 38 | 39 | #endif // ! __NFC_DRIVER_ACR122_USB_H__ 40 | -------------------------------------------------------------------------------- /libnfc-1.7.1/libnfc/drivers/pn532_spi.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Free/Libre Near Field Communication (NFC) library 3 | * 4 | * Libnfc historical contributors: 5 | * Copyright (C) 2009 Roel Verdult 6 | * Copyright (C) 2009-2013 Romuald Conty 7 | * Copyright (C) 2010-2012 Romain Tartière 8 | * Copyright (C) 2010-2013 Philippe Teuwen 9 | * Copyright (C) 2012-2013 Ludovic Rousseau 10 | * See AUTHORS file for a more comprehensive list of contributors. 11 | * Additional contributors of this file: 12 | * Copyright (C) 2013 Evgeny Boger 13 | * 14 | * This program is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU Lesser General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or (at your 17 | * option) any later version. 18 | * 19 | * This program is distributed in the hope that it will be useful, but WITHOUT 20 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 21 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 22 | * more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public License 25 | * along with this program. If not, see 26 | */ 27 | 28 | /** 29 | * @file pn532_spi.h 30 | * @brief Driver for PN532 connected in SPI 31 | */ 32 | 33 | #ifndef __NFC_DRIVER_PN532_SPI_H__ 34 | #define __NFC_DRIVER_PN532_SPI_H__ 35 | 36 | #include 37 | 38 | extern const struct nfc_driver pn532_spi_driver; 39 | 40 | #endif // ! __NFC_DRIVER_PN532_SPI_H__ 41 | -------------------------------------------------------------------------------- /libnfc-1.7.1/examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | SET(EXAMPLES-SOURCES 2 | nfc-anticol 3 | nfc-dep-initiator 4 | nfc-dep-target 5 | nfc-emulate-forum-tag2 6 | nfc-emulate-tag 7 | nfc-emulate-uid 8 | nfc-mfsetuid 9 | nfc-poll 10 | nfc-relay 11 | ) 12 | 13 | INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../libnfc) 14 | 15 | # Examples 16 | FOREACH(source ${EXAMPLES-SOURCES}) 17 | SET (TARGETS ${source}.c) 18 | 19 | IF(WIN32) 20 | SET(RC_COMMENT "${PACKAGE_NAME} example") 21 | SET(RC_INTERNAL_NAME ${source}) 22 | SET(RC_ORIGINAL_NAME ${source}.exe) 23 | SET(RC_FILE_TYPE VFT_APP) 24 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/../contrib/win32/version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/../windows/${source}.rc @ONLY) 25 | LIST(APPEND TARGETS ${CMAKE_CURRENT_BINARY_DIR}/../windows/${source}.rc) 26 | ENDIF(WIN32) 27 | 28 | ADD_EXECUTABLE(${source} ${TARGETS}) 29 | TARGET_LINK_LIBRARIES(${source} nfc) 30 | TARGET_LINK_LIBRARIES(${source} nfcutils) 31 | INSTALL(TARGETS ${source} RUNTIME DESTINATION bin COMPONENT examples) 32 | ENDFOREACH(source) 33 | 34 | #install required libraries 35 | IF(WIN32) 36 | INCLUDE(InstallRequiredSystemLibraries) 37 | CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/FixBundle.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FixBundle.cmake @ONLY) 38 | INSTALL(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/FixBundle.cmake) 39 | ENDIF(WIN32) 40 | 41 | IF(NOT WIN32) 42 | # Manuals for the examples 43 | FILE(GLOB manuals "${CMAKE_CURRENT_SOURCE_DIR}/*.1") 44 | INSTALL(FILES ${manuals} DESTINATION ${SHARE_INSTALL_PREFIX}/man/man1 COMPONENT manuals) 45 | ENDIF(NOT WIN32) 46 | -------------------------------------------------------------------------------- /libnfc-1.7.1/libnfc/drivers/pn532_i2c.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Free/Libre Near Field Communication (NFC) library 3 | * 4 | * Libnfc historical contributors: 5 | * Copyright (C) 2009 Roel Verdult 6 | * Copyright (C) 2009-2013 Romuald Conty 7 | * Copyright (C) 2010-2012 Romain Tarti?re 8 | * Copyright (C) 2010-2013 Philippe Teuwen 9 | * Copyright (C) 2012-2013 Ludovic Rousseau 10 | * See AUTHORS file for a more comprehensive list of contributors. 11 | * Additional contributors of this file: 12 | * Copyright (C) 2013 Laurent Latil 13 | * 14 | * This program is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU Lesser General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or (at your 17 | * option) any later version. 18 | * 19 | * This program is distributed in the hope that it will be useful, but WITHOUT 20 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 21 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 22 | * more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public License 25 | * along with this program. If not, see 26 | */ 27 | 28 | /** 29 | * @file pn532_i2c.h 30 | * @brief Driver for PN532 connected through I2C bus 31 | */ 32 | 33 | #ifndef __NFC_DRIVER_PN532_I2C_H__ 34 | #define __NFC_DRIVER_PN532_I2C_H__ 35 | 36 | #include 37 | 38 | /* Reference to the I2C driver structure */ 39 | extern const struct nfc_driver pn532_i2c_driver; 40 | 41 | #endif // ! __NFC_DRIVER_I2C_H__ 42 | -------------------------------------------------------------------------------- /libnfc-1.7.1/libnfc/log-internal.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Free/Libre Near Field Communication (NFC) library 3 | * 4 | * Libnfc historical contributors: 5 | * Copyright (C) 2009 Roel Verdult 6 | * Copyright (C) 2009-2013 Romuald Conty 7 | * Copyright (C) 2010-2012 Romain Tartière 8 | * Copyright (C) 2010-2013 Philippe Teuwen 9 | * Copyright (C) 2012-2013 Ludovic Rousseau 10 | * See AUTHORS file for a more comprehensive list of contributors. 11 | * Additional contributors of this file: 12 | * Copyright (C) 2013 Alex Lian 13 | * 14 | * This program is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU Lesser General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or (at your 17 | * option) any later version. 18 | * 19 | * This program is distributed in the hope that it will be useful, but WITHOUT 20 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 21 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 22 | * more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public License 25 | * along with this program. If not, see 26 | */ 27 | 28 | #include "log-internal.h" 29 | 30 | #include 31 | #include 32 | 33 | void 34 | log_vput_internal(const char *format, va_list args) 35 | { 36 | vfprintf(stderr, format, args); 37 | } 38 | 39 | void 40 | log_put_internal(const char *format, ...) 41 | { 42 | va_list va; 43 | va_start(va, format); 44 | vfprintf(stderr, format, va); 45 | va_end(va); 46 | } 47 | -------------------------------------------------------------------------------- /libnfc-1.7.1/test/Makefile.am: -------------------------------------------------------------------------------- 1 | # $Id$ 2 | 3 | AM_CPPFLAGS = $(CUTTER_CFLAGS) $(LIBNFC_CFLAGS) 4 | LIBS = $(CUTTER_LIBS) 5 | 6 | if WITH_CUTTER 7 | TESTS = run-test.sh 8 | TESTS_ENVIRONMENT = NO_MAKE=yes CUTTER="$(CUTTER)" 9 | 10 | cutter_unit_test_libs = \ 11 | test_access_storm.la \ 12 | test_dep_active.la \ 13 | test_device_modes_as_dep.la \ 14 | test_dep_passive.la \ 15 | test_register_access.la \ 16 | test_register_endianness.la 17 | 18 | if WITH_DEBUG 19 | noinst_LTLIBRARIES = $(cutter_unit_test_libs) 20 | else 21 | check_LTLIBRARIES = $(cutter_unit_test_libs) 22 | endif 23 | 24 | AM_LDFLAGS = -module -rpath $(libdir) -avoid-version -no-undefined 25 | 26 | test_access_storm_la_SOURCES = test_access_storm.c 27 | test_access_storm_la_LIBADD = $(top_builddir)/libnfc/libnfc.la 28 | 29 | test_dep_active_la_SOURCES = test_dep_active.c 30 | test_dep_active_la_LIBADD = $(top_builddir)/libnfc/libnfc.la \ 31 | $(top_builddir)/utils/libnfcutils.la 32 | 33 | test_device_modes_as_dep_la_SOURCES = test_device_modes_as_dep.c 34 | test_device_modes_as_dep_la_LIBADD = $(top_builddir)/libnfc/libnfc.la 35 | 36 | test_dep_passive_la_SOURCES = test_dep_passive.c 37 | test_dep_passive_la_LIBADD = $(top_builddir)/libnfc/libnfc.la 38 | 39 | test_register_access_la_SOURCES = test_register_access.c 40 | test_register_access_la_LIBADD = $(top_builddir)/libnfc/libnfc.la 41 | 42 | test_register_endianness_la_SOURCES = test_register_endianness.c 43 | test_register_endianness_la_LIBADD = $(top_builddir)/libnfc/libnfc.la 44 | 45 | echo-cutter: 46 | @echo $(CUTTER) 47 | 48 | EXTRA_DIST = run-test.sh 49 | CLEANFILES = *.gcno 50 | 51 | endif 52 | -------------------------------------------------------------------------------- /libnfc-1.7.1/libnfc/mirror-subr.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Free/Libre Near Field Communication (NFC) library 3 | * 4 | * Libnfc historical contributors: 5 | * Copyright (C) 2009 Roel Verdult 6 | * Copyright (C) 2009-2013 Romuald Conty 7 | * Copyright (C) 2010-2012 Romain Tartière 8 | * Copyright (C) 2010-2013 Philippe Teuwen 9 | * Copyright (C) 2012-2013 Ludovic Rousseau 10 | * See AUTHORS file for a more comprehensive list of contributors. 11 | * Additional contributors of this file: 12 | * 13 | * This program is free software: you can redistribute it and/or modify it 14 | * under the terms of the GNU Lesser General Public License as published by the 15 | * Free Software Foundation, either version 3 of the License, or (at your 16 | * option) any later version. 17 | * 18 | * This program is distributed in the hope that it will be useful, but WITHOUT 19 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 21 | * more details. 22 | * 23 | * You should have received a copy of the GNU Lesser General Public License 24 | * along with this program. If not, see 25 | * 26 | * 27 | * @file mirror-subr.h 28 | * @brief Mirror bytes 29 | */ 30 | 31 | #ifndef _LIBNFC_MIRROR_SUBR_H_ 32 | # define _LIBNFC_MIRROR_SUBR_H_ 33 | 34 | # include 35 | 36 | # include 37 | 38 | 39 | uint8_t mirror(uint8_t bt); 40 | uint32_t mirror32(uint32_t ui32Bits); 41 | uint64_t mirror64(uint64_t ui64Bits); 42 | void mirror_uint8_ts(uint8_t *pbts, size_t szLen); 43 | 44 | #endif // _LIBNFC_MIRROR_SUBR_H_ 45 | -------------------------------------------------------------------------------- /libnfc-1.7.1/examples/nfc-anticol.1: -------------------------------------------------------------------------------- 1 | .TH nfc-anticol 1 "June 26, 2009" "libnfc" "libnfc's examples" 2 | .SH NAME 3 | nfc-anticol \- Demonstration of NFC anti-collision command line tool based on libnfc 4 | .SH SYNOPSIS 5 | .B nfc-anticol 6 | .SH DESCRIPTION 7 | .B nfc-anticol 8 | is an anti-collision demonstration tool for ISO/IEC 14443-A tags, performed by 9 | custom constructed frames. The first frame must be a short frame which is only 10 | 7 bits long. Commercial SDK's often don't support a feature to send frames that 11 | are not a multiple of 8 bits (1 byte) long. This makes it impossible to do the 12 | anti-collision yourself. The developer has to rely on closed proprietary 13 | software and should hope it does not contain vulnerabilities during the 14 | anti-collision phase. Performing the anti-collision using custom frames could 15 | protect against a malicious tag that, for example, violates the standard by 16 | sending frames with unsupported lengths. 17 | Note that this is only a demonstration tool, which can not handle multiple tags 18 | as real life anti-collisions with multiple tags generate "messy" bits which 19 | are neither 0 nor 1. 20 | 21 | .SH BUGS 22 | Please report any bugs on the 23 | .B libnfc 24 | issue tracker at: 25 | .br 26 | .BR http://code.google.com/p/libnfc/issues 27 | .SH LICENCE 28 | .B libnfc 29 | is licensed under the GNU Lesser General Public License (LGPL), version 3. 30 | .br 31 | .B libnfc-utils 32 | and 33 | .B libnfc-examples 34 | are covered by the the BSD 2-Clause license. 35 | .SH AUTHORS 36 | Roel Verdult 37 | .PP 38 | This manual page was written by Romuald Conty . 39 | It is licensed under the terms of the GNU GPL (version 2 or later). 40 | -------------------------------------------------------------------------------- /libnfc-1.7.1/test/test_access_storm.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #define NTESTS 10 6 | #define MAX_DEVICE_COUNT 8 7 | #define MAX_TARGET_COUNT 8 8 | 9 | /* 10 | * This is basically a stress-test to ensure we don't left a device in an 11 | * inconsistent state after use. 12 | */ 13 | void test_access_storm(void); 14 | 15 | void 16 | test_access_storm(void) 17 | { 18 | int n = NTESTS; 19 | nfc_connstring connstrings[MAX_DEVICE_COUNT]; 20 | int res = 0; 21 | 22 | nfc_context *context; 23 | nfc_init(&context); 24 | 25 | size_t ref_device_count = nfc_list_devices(context, connstrings, MAX_DEVICE_COUNT); 26 | if (!ref_device_count) 27 | cut_omit("No NFC device found"); 28 | 29 | while (n) { 30 | size_t device_count = nfc_list_devices(context, connstrings, MAX_DEVICE_COUNT); 31 | cut_assert_equal_int(ref_device_count, device_count, cut_message("device count")); 32 | 33 | for (volatile size_t i = 0; i < device_count; i++) { 34 | nfc_device *device; 35 | nfc_target ant[MAX_TARGET_COUNT]; 36 | 37 | device = nfc_open(context, connstrings[i]); 38 | cut_assert_not_null(device, cut_message("nfc_open")); 39 | 40 | res = nfc_initiator_init(device); 41 | cut_assert_equal_int(0, res, cut_message("nfc_initiator_init")); 42 | 43 | const nfc_modulation nm = { 44 | .nmt = NMT_ISO14443A, 45 | .nbr = NBR_106, 46 | }; 47 | res = nfc_initiator_list_passive_targets(device, nm, ant, MAX_TARGET_COUNT); 48 | cut_assert_operator_int(res, >= , 0, cut_message("nfc_initiator_list_passive_targets")); 49 | 50 | nfc_close(device); 51 | } 52 | 53 | n--; 54 | } 55 | nfc_exit(context); 56 | } 57 | -------------------------------------------------------------------------------- /libnfc-1.7.1/libnfc/log-internal.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Free/Libre Near Field Communication (NFC) library 3 | * 4 | * Libnfc historical contributors: 5 | * Copyright (C) 2009 Roel Verdult 6 | * Copyright (C) 2009-2013 Romuald Conty 7 | * Copyright (C) 2010-2012 Romain Tartière 8 | * Copyright (C) 2010-2013 Philippe Teuwen 9 | * Copyright (C) 2012-2013 Ludovic Rousseau 10 | * See AUTHORS file for a more comprehensive list of contributors. 11 | * Additional contributors of this file: 12 | * 13 | * This program is free software: you can redistribute it and/or modify it 14 | * under the terms of the GNU Lesser General Public License as published by the 15 | * Free Software Foundation, either version 3 of the License, or (at your 16 | * option) any later version. 17 | * 18 | * This program is distributed in the hope that it will be useful, but WITHOUT 19 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 21 | * more details. 22 | * 23 | * You should have received a copy of the GNU Lesser General Public License 24 | * along with this program. If not, see 25 | */ 26 | 27 | #ifndef __LOG_INTERNAL_H__ 28 | #define __LOG_INTERNAL_H__ 29 | 30 | #ifdef HAVE_CONFIG_H 31 | # include "config.h" 32 | #endif // HAVE_CONFIG_H 33 | 34 | #include 35 | 36 | // Internal methods so different platforms can route the logging 37 | // Offering both forms of the variadic function 38 | // These are implemented in the log_ specific file 39 | void log_put_internal(const char *format, ...); 40 | void log_vput_internal(const char *format, va_list args); 41 | 42 | #endif // __LOG_INTERNAL_H__ 43 | -------------------------------------------------------------------------------- /libnfc-1.7.1/Makefile.am: -------------------------------------------------------------------------------- 1 | ACLOCAL_AMFLAGS = -I m4 2 | 3 | AM_CFLAGS = $(LIBNFC_CFLAGS) 4 | 5 | SUBDIRS = libnfc utils examples include contrib cmake test 6 | 7 | pkgconfigdir = $(libdir)/pkgconfig 8 | pkgconfig_DATA = libnfc.pc 9 | 10 | EXTRA_DIST = \ 11 | CMakeLists.txt \ 12 | Doxyfile \ 13 | README-Windows.txt \ 14 | libnfc.conf.sample 15 | 16 | CLEANFILES = Doxygen.log coverage.info libnfc.pc 17 | 18 | clean-local: clean-local-doc clean-local-coverage 19 | 20 | .PHONY: clean-local-coverage clean-local-doc doc style 21 | clean-local-coverage: 22 | -rm -rf coverage 23 | 24 | clean-local-doc: 25 | rm -rf doc 26 | 27 | doc : Doxyfile 28 | @DOXYGEN@ $(builddir)/Doxyfile 29 | 30 | DISTCHECK_CONFIGURE_FLAGS="--with-drivers=all" 31 | 32 | style: 33 | find . -name "*.[ch]" -exec perl -pi -e 's/[ \t]+$$//' {} \; 34 | find . -name "*.[ch]" -exec astyle --formatted --mode=c --suffix=none \ 35 | --indent=spaces=2 --indent-switches --indent-preprocessor \ 36 | --keep-one-line-blocks --max-instatement-indent=60 \ 37 | --brackets=linux --pad-oper --unpad-paren --pad-header \ 38 | --align-pointer=name {} \; 39 | 40 | cppcheck: 41 | cppcheck --quiet \ 42 | -I include -I libnfc -I libnfc/buses -I libnfc/chips -I libnfc/drivers \ 43 | --check-config . 44 | cppcheck --quiet --enable=all --std=posix --std=c99 \ 45 | -I include -I libnfc -I libnfc/buses -I libnfc/chips -I libnfc/drivers \ 46 | -DLOG -D__linux__ \ 47 | -DDRIVER_PN53X_USB_ENABLED -DDRIVER_ACR122_PCSC_ENABLED \ 48 | -DDRIVER_ACR122_USB_ENABLED -DDRIVER_ACR122S_ENABLED \ 49 | -DDRIVER_PN532_UART_ENABLED -DDRIVER_ARYGON_ENABLED \ 50 | -DDRIVER_PN532_SPI_ENABLED -DDRIVER_PN532_I2C_ENABLED \ 51 | --force --inconclusive . 52 | -------------------------------------------------------------------------------- /libnfc-1.7.1/contrib/win32/unistd.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Free/Libre Near Field Communication (NFC) library 3 | * 4 | * Libnfc historical contributors: 5 | * Copyright (C) 2009 Roel Verdult 6 | * Copyright (C) 2009-2013 Romuald Conty 7 | * Copyright (C) 2010-2012 Romain Tartière 8 | * Copyright (C) 2010-2013 Philippe Teuwen 9 | * Copyright (C) 2012-2013 Ludovic Rousseau 10 | * See AUTHORS file for a more comprehensive list of contributors. 11 | * Additional contributors of this file: 12 | * 13 | * This program is free software: you can redistribute it and/or modify it 14 | * under the terms of the GNU Lesser General Public License as published by the 15 | * Free Software Foundation, either version 3 of the License, or (at your 16 | * option) any later version. 17 | * 18 | * This program is distributed in the hope that it will be useful, but WITHOUT 19 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 21 | * more details. 22 | * 23 | * You should have received a copy of the GNU Lesser General Public License 24 | * along with this program. If not, see 25 | */ 26 | 27 | /** 28 | * @file unistd.h 29 | * @brief This file intended to serve as a drop-in replacement for unistd.h on Windows 30 | */ 31 | 32 | #ifndef _UNISTD_H_ 33 | #define _UNISTD_H_ 34 | 35 | #include "contrib/windows.h" 36 | 37 | // Needed by Sleep() under Windows 38 | # include 39 | # define sleep(X) Sleep( X * 1000) 40 | 41 | // With MinGW, getopt(3) is provided as separate header 42 | #if defined(WIN32) && defined(__GNUC__) /* mingw compiler */ 43 | #include 44 | #endif 45 | 46 | 47 | #endif /* _UNISTD_H_ */ 48 | 49 | -------------------------------------------------------------------------------- /libnfc-1.7.1/utils/nfc-mfultralight.1: -------------------------------------------------------------------------------- 1 | .TH nfc-mfultralight 1 "Nov 02, 2009" "libnfc" "NFC Utilities" 2 | .SH NAME 3 | nfc-mfultralight \- MIFARE Ultralight command line tool 4 | .SH SYNOPSIS 5 | .B nfc-mfultralight 6 | .RI \fR\fBr\fR|\fBw\fR 7 | .IR DUMP 8 | 9 | .SH DESCRIPTION 10 | .B nfc-mfultralight 11 | is a MIFARE Ultralight tool that allows one to read or write 12 | a tag data to/from a 13 | .IR DUMP 14 | file. 15 | 16 | MIFARE Ultralight tag is one of the most widely used RFID tags for ticketing application. 17 | It uses a binary Mifare Dump file (MFD) to store data for all sectors. 18 | 19 | Be cautious that some parts of a Ultralight memory can be written only once 20 | and some parts are used as lock bits, so please read the tag documentation 21 | before experimenting too much! 22 | 23 | To set the UID of a special writeable UID card, edit the first 7 bytes of a dump file and 24 | then write it back, answering 'Y' to the question 'Write UID bytes?'. 25 | 26 | .SH OPTIONS 27 | .BR r " | " w 28 | Perform read from ( 29 | .B r 30 | ) or write to ( 31 | .B w 32 | ) card. 33 | .TP 34 | .IR DUMP 35 | MiFare Dump (MFD) used to write (card to MFD) or (MFD to card) 36 | 37 | .SH BUGS 38 | Please report any bugs on the 39 | .B libnfc 40 | issue tracker at: 41 | .br 42 | .BR http://code.google.com/p/libnfc/issues 43 | .SH LICENCE 44 | .B libnfc 45 | is licensed under the GNU Lesser General Public License (LGPL), version 3. 46 | .br 47 | .B libnfc-utils 48 | and 49 | .B libnfc-examples 50 | are covered by the the BSD 2-Clause license. 51 | 52 | .SH AUTHORS 53 | Roel Verdult , 54 | .br 55 | Romuald Conty . 56 | .PP 57 | This manual page was written by Romuald Conty . 58 | It is licensed under the terms of the GNU GPL (version 2 or later). 59 | -------------------------------------------------------------------------------- /libnfc-1.7.1/libnfc/buses/usbbus.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Free/Libre Near Field Communication (NFC) library 3 | * 4 | * Libnfc historical contributors: 5 | * Copyright (C) 2009 Roel Verdult 6 | * Copyright (C) 2009-2013 Romuald Conty 7 | * Copyright (C) 2010-2012 Romain Tartière 8 | * Copyright (C) 2010-2013 Philippe Teuwen 9 | * Copyright (C) 2012-2013 Ludovic Rousseau 10 | * See AUTHORS file for a more comprehensive list of contributors. 11 | * Additional contributors of this file: 12 | * 13 | * This program is free software: you can redistribute it and/or modify it 14 | * under the terms of the GNU Lesser General Public License as published by the 15 | * Free Software Foundation, either version 3 of the License, or (at your 16 | * option) any later version. 17 | * 18 | * This program is distributed in the hope that it will be useful, but WITHOUT 19 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 21 | * more details. 22 | * 23 | * You should have received a copy of the GNU Lesser General Public License 24 | * along with this program. If not, see 25 | * 26 | */ 27 | 28 | /** 29 | * @file usbbus.h 30 | * @brief libusb 0.1 driver header 31 | */ 32 | 33 | #ifndef __NFC_BUS_USB_H__ 34 | # define __NFC_BUS_USB_H__ 35 | 36 | #ifndef _WIN32 37 | // Under POSIX system, we use libusb (>= 0.1.12) 38 | #include 39 | #define USB_TIMEDOUT ETIMEDOUT 40 | #define _usb_strerror( X ) strerror(-X) 41 | #else 42 | // Under Windows we use libusb-win32 (>= 1.2.5) 43 | #include 44 | #define USB_TIMEDOUT 116 45 | #define _usb_strerror( X ) usb_strerror() 46 | #endif 47 | 48 | #include 49 | #include 50 | 51 | int usb_prepare(void); 52 | 53 | #endif // __NFC_BUS_USB_H__ 54 | -------------------------------------------------------------------------------- /libnfc-1.7.1/test/test_register_access.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include "chips/pn53x.h" 5 | 6 | #define MAX_DEVICE_COUNT 1 7 | #define MAX_TARGET_COUNT 1 8 | 9 | void test_register_access(void); 10 | 11 | void 12 | test_register_access(void) 13 | { 14 | nfc_connstring connstrings[MAX_DEVICE_COUNT]; 15 | int res = 0; 16 | 17 | nfc_context *context; 18 | nfc_init(&context); 19 | 20 | size_t device_count = nfc_list_devices(context, connstrings, MAX_DEVICE_COUNT); 21 | if (!device_count) 22 | cut_omit("No NFC device found"); 23 | 24 | nfc_device *device; 25 | 26 | device = nfc_open(context, connstrings[0]); 27 | cut_assert_not_null(device, cut_message("nfc_open")); 28 | 29 | uint8_t value; 30 | 31 | /* Set a 0xAA test value in writable register memory to test register access */ 32 | res = pn53x_write_register(device, PN53X_REG_CIU_TxMode, 0xFF, 0xAA); 33 | cut_assert_equal_int(0, res, cut_message("write register value to 0xAA")); 34 | 35 | /* Get test value from register memory */ 36 | res = pn53x_read_register(device, PN53X_REG_CIU_TxMode, &value); 37 | cut_assert_equal_int(0, res, cut_message("read register value")); 38 | cut_assert_equal_uint(0xAA, value, cut_message("check register value")); 39 | 40 | /* Set a 0x55 test value in writable register memory to test register access */ 41 | res = pn53x_write_register(device, PN53X_REG_CIU_TxMode, 0xFF, 0x55); 42 | cut_assert_equal_int(0, res, cut_message("write register value to 0x55")); 43 | 44 | /* Get test value from register memory */ 45 | res = pn53x_read_register(device, PN53X_REG_CIU_TxMode, &value); 46 | cut_assert_equal_int(0, res, cut_message("read register value")); 47 | cut_assert_equal_uint(0x55, value, cut_message("check register value")); 48 | 49 | nfc_close(device); 50 | nfc_exit(context); 51 | } 52 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Super-exe 2 | An interface to the Mifare Super (Suppa/Supper) Card utilising the libnfc 1.7.1 library. 3 | Many super-card card programs are either broken / wrong type / or written in Chinese. 4 | This is a simple English (American) Language program to faciliate non-Chinese users. 5 | 6 | This program has been tested successfully on the USB ACR-122U reader on the following operating systems: 7 | * WinXP (32bit) SP0/1/2/3 8 | * Vista (32bit) SP0/1/2 9 | 10 | **Note**: From Windows 7+ Microsoft changed the way smartcard drivers operate, and I havnt figured out how to support the later versions of Windows. 11 | 12 | The program has two modes read & write, these operations are detailed below... 13 | 14 | # Usage 15 | ## Set a UID 16 | Using the '-w' flag set a 4-byte (8 hex chars) UID 17 | ``` 18 | $ nfc-super.exe -w 22334455 19 | Mifare Super Card v0.1 (C)2014 Andy 20 | ISO/IEC 14443A (106 kbps) target: 21 | ATQA (SENS_RES): 00 04 22 | UID (NFCID1): 11 22 33 44 23 | SAK (SEL_RES): 08 24 | ``` 25 | ## Operation 26 | Place the card upto a Mifare reader, and ensure you obtain two or more (2+) failed authentication attempts. 27 | 28 | ## Obtain data and crack key 29 | Place the super-card on the reader, launch the program with the '-r' flag, the program should automatically 30 | obtain the necessary values and crack the reader key. 31 | ``` 32 | $ nfc-super.exe -r 33 | Mifare Super Card v0.1 (C)2014 Andy 34 | ISO/IEC 14443A (106 kbps) target: 35 | ATQA (SENS_RES): 00 04 36 | UID (NFCID1): 22 33 44 55 37 | SAK (SEL_RES): 08 38 | UID: 22 33 44 55 39 | 1:NR: c9 6f 2e a5 40 | 1:AR: 71 67 3d 4d 41 | 2:NR: 38 aa fa ba 42 | 2:AR: 5d 32 cd f4 43 | Cracking... 44 | Found Key: [e5b20aeeffff] 45 | ``` 46 | 47 | # Further cracking 48 | Use the Mifare nested attack (or mfoc.exe) to crack any remaining keys on a genuine card. -------------------------------------------------------------------------------- /libnfc-1.7.1/make_release.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # Stop script on first error. 4 | set -e 5 | 6 | # Retrieve libnfc version from configure.ac 7 | LIBNFC_VERSION=$(grep AC_INIT configure.ac | sed 's/^.*\[libnfc\],\[\(.*\)\],\[.*/\1/g') 8 | 9 | echo "=== Building release archive for libnfc $LIBNFC_VERSION ===" 10 | # Easiest part: GNU/linux, BSD and other POSIX systems. 11 | LIBNFC_AUTOTOOLS_ARCHIVE=libnfc-$LIBNFC_VERSION.tar.gz 12 | 13 | echo ">>> Cleaning sources..." 14 | # First, clean what we can 15 | rm -f configure config.h config.h.in 16 | autoreconf -is --force && ./configure && make distclean 17 | git clean -dfX 18 | echo "<<< Sources cleaned." 19 | 20 | if [ ! -f $LIBNFC_AUTOTOOLS_ARCHIVE ]; then 21 | echo ">>> Autotooled archive generation..." 22 | 23 | # Second, generate dist archive (and test it) 24 | autoreconf -is --force && ./configure && make distcheck 25 | 26 | # Finally, clean up 27 | make distclean 28 | echo "<<< Autotooled archive generated." 29 | else 30 | echo "--- Autotooled archive (GNU/Linux, BSD, etc.) is already done: skipped." 31 | fi 32 | 33 | # Documentation part 34 | echo "=== Building documentation archive for libnfc $LIBNFC_VERSION ===" 35 | LIBNFC_DOC_DIR=libnfc-doc-$LIBNFC_VERSION 36 | LIBNFC_DOC_ARCHIVE=$LIBNFC_DOC_DIR.zip 37 | 38 | if [ ! -f $LIBNFC_DOC_ARCHIVE ]; then 39 | echo ">>> Documentation archive generation..." 40 | if [ -d $LIBNFC_DOC_DIR ]; then 41 | rm -rf $LIBNFC_DOC_DIR 42 | fi 43 | 44 | # Build documentation 45 | autoreconf -is --force && ./configure --enable-doc && make doc || false 46 | 47 | # Create archive 48 | cp -r doc/html $LIBNFC_DOC_DIR 49 | zip -r $LIBNFC_DOC_ARCHIVE $LIBNFC_DOC_DIR 50 | 51 | # Clean up 52 | rm -rf $LIBNFC_DOC_DIR 53 | make distclean 54 | echo "<<< Documentation archive generated." 55 | else 56 | echo "--- Documentation archive is already done: skipped." 57 | fi 58 | 59 | -------------------------------------------------------------------------------- /libnfc-1.7.1/libnfc/iso7816.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Free/Libre Near Field Communication (NFC) library 3 | * 4 | * Libnfc historical contributors: 5 | * Copyright (C) 2009 Roel Verdult 6 | * Copyright (C) 2009-2013 Romuald Conty 7 | * Copyright (C) 2010-2012 Romain Tartière 8 | * Copyright (C) 2010-2013 Philippe Teuwen 9 | * Copyright (C) 2012-2013 Ludovic Rousseau 10 | * See AUTHORS file for a more comprehensive list of contributors. 11 | * Additional contributors of this file: 12 | * 13 | * This program is free software: you can redistribute it and/or modify it 14 | * under the terms of the GNU Lesser General Public License as published by the 15 | * Free Software Foundation, either version 3 of the License, or (at your 16 | * option) any later version. 17 | * 18 | * This program is distributed in the hope that it will be useful, but WITHOUT 19 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 21 | * more details. 22 | * 23 | * You should have received a copy of the GNU Lesser General Public License 24 | * along with this program. If not, see 25 | */ 26 | 27 | /** 28 | * @file iso7816.h 29 | * @brief Defines some macros extracted for ISO/IEC 7816-4 30 | */ 31 | 32 | #ifndef __LIBNFC_ISO7816_H__ 33 | #define __LIBNFC_ISO7816_H__ 34 | 35 | #define ISO7816_C_APDU_COMMAND_HEADER_LEN 4 36 | #define ISO7816_SHORT_APDU_MAX_DATA_LEN 256 37 | #define ISO7816_SHORT_C_APDU_MAX_OVERHEAD 2 38 | #define ISO7816_SHORT_R_APDU_RESPONSE_TRAILER_LEN 2 39 | 40 | #define ISO7816_SHORT_C_APDU_MAX_LEN (ISO7816_C_APDU_COMMAND_HEADER_LEN + ISO7816_SHORT_APDU_MAX_DATA_LEN + ISO7816_SHORT_C_APDU_MAX_OVERHEAD) 41 | #define ISO7816_SHORT_R_APDU_MAX_LEN (ISO7816_SHORT_APDU_MAX_DATA_LEN + ISO7816_SHORT_R_APDU_RESPONSE_TRAILER_LEN) 42 | 43 | #endif /* !__LIBNFC_ISO7816_H__ */ 44 | -------------------------------------------------------------------------------- /libnfc-1.7.1/utils/nfc-scan-device.1: -------------------------------------------------------------------------------- 1 | .TH nfc-scan-device 1 "October 21, 2012" "libnfc" "NFC Utilities" 2 | .SH NAME 3 | nfc-scan-device \- Scan NFC devices 4 | .SH SYNOPSIS 5 | .B nfc-scan-device 6 | [ 7 | .I options 8 | ] 9 | .SH DESCRIPTION 10 | .B nfc-scan-device 11 | is a utility for listing any available device compliant with libnfc. 12 | It can optionnally display device's capabilities. 13 | 14 | .SH OPTIONS 15 | .TP 16 | .B \-v 17 | Tells 18 | .I 19 | nfc-scan-device 20 | to be verbose and display detailed information about the devices found. 21 | .TP 22 | .B \-i 23 | Tells 24 | .I 25 | nfc-scan-device 26 | to allow intrusive scan (eg. serial ports scan). This is equivalent to set environment variable LIBNFC_INTRUSIVE_SCAN to "yes". 27 | 28 | .SH EXAMPLE 29 | For a SCL3711 device (in verbose mode): 30 | 31 | - SCM Micro / SCL3711-NFC&RW: 32 | pn53x_usb:002:017 33 | chip: PN533 v2.7 34 | 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) 35 | target mode modulations: ISO/IEC 14443A (106 kbps), FeliCa (424 kbps, 212 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps) 36 | 37 | .SH BUGS 38 | Please report any bugs on the 39 | .B libnfc 40 | issue tracker at: 41 | .br 42 | .BR http://code.google.com/p/libnfc/issues 43 | .SH LICENCE 44 | .B libnfc 45 | is licensed under the GNU Lesser General Public License (LGPL), version 3. 46 | .br 47 | .B libnfc-utils 48 | and 49 | .B libnfc-examples 50 | are covered by the the BSD 2-Clause license. 51 | .SH AUTHORS 52 | Roel Verdult , 53 | .br 54 | Romain Tartière , 55 | .br 56 | Romuald Conty . 57 | .PP 58 | This manual page was written by Romuald Conty . 59 | It is licensed under the terms of the GNU GPL (version 2 or later). 60 | -------------------------------------------------------------------------------- /libnfc-1.7.1/m4/readline.m4: -------------------------------------------------------------------------------- 1 | dnl Based on wojtekka's m4 from http://wloc.wsinf.edu.pl/~kklos/ekg-20080219/m4/readline.m4 2 | 3 | AC_DEFUN([AC_CHECK_READLINE],[ 4 | AC_SUBST(READLINE_LIBS) 5 | AC_SUBST(READLINE_INCLUDES) 6 | 7 | AC_ARG_WITH(readline, 8 | [[ --with-readline[=dir] Compile with readline/locate base dir]], 9 | if test "x$withval" = "xno" ; then 10 | without_readline=yes 11 | elif test "x$withval" != "xyes" ; then 12 | with_arg="$withval/include:-L$withval/lib $withval/include/readline:-L$withval/lib" 13 | fi) 14 | 15 | AC_MSG_CHECKING(for readline.h) 16 | 17 | if test "x$cross_compiling" == "xyes"; then 18 | without_readline=yes 19 | fi 20 | 21 | if test "x$without_readline" != "xyes"; then 22 | for i in $with_arg \ 23 | /usr/include: \ 24 | /usr/local/include:-L/usr/local/lib \ 25 | /usr/pkg/include:-L/usr/pkg/lib; do 26 | 27 | incl=`echo "$i" | sed 's/:.*//'` 28 | lib=`echo "$i" | sed 's/.*://'` 29 | 30 | if test -f $incl/readline/readline.h ; then 31 | AC_MSG_RESULT($incl/readline/readline.h) 32 | READLINE_LIBS="$lib -lreadline" 33 | if test "$incl" != "/usr/include"; then 34 | READLINE_INCLUDES="-I$incl/readline -I$incl" 35 | else 36 | READLINE_INCLUDES="-I$incl/readline" 37 | fi 38 | AC_DEFINE(HAVE_READLINE, 1, [define if you have readline]) 39 | have_readline=yes 40 | break 41 | elif test -f $incl/readline.h -a "x$incl" != "x/usr/include"; then 42 | AC_MSG_RESULT($incl/readline.h) 43 | READLINE_LIBS="$lib -lreadline" 44 | READLINE_INCLUDES="-I$incl" 45 | AC_DEFINE(HAVE_READLINE, 1, [define if you have readline]) 46 | have_readline=yes 47 | break 48 | fi 49 | done 50 | fi 51 | 52 | if test "x$have_readline" != "xyes"; then 53 | AC_MSG_RESULT(not found) 54 | fi 55 | ]) 56 | 57 | -------------------------------------------------------------------------------- /libnfc-1.7.1/contrib/win32/stdlib.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Free/Libre Near Field Communication (NFC) library 3 | * 4 | * Libnfc historical contributors: 5 | * Copyright (C) 2009 Roel Verdult 6 | * Copyright (C) 2009-2013 Romuald Conty 7 | * Copyright (C) 2010-2012 Romain Tartière 8 | * Copyright (C) 2010-2013 Philippe Teuwen 9 | * Copyright (C) 2012-2013 Ludovic Rousseau 10 | * See AUTHORS file for a more comprehensive list of contributors. 11 | * Additional contributors of this file: 12 | * Copyright (C) 2013 Alex Lian 13 | * 14 | * This program is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU Lesser General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or (at your 17 | * option) any later version. 18 | * 19 | * This program is distributed in the hope that it will be useful, but WITHOUT 20 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 21 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 22 | * more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public License 25 | * along with this program. If not, see 26 | * 27 | */ 28 | 29 | /** 30 | * @file stdlib.c 31 | * @brief Windows System compatibility 32 | */ 33 | 34 | // Handle platform specific includes 35 | #include "contrib/windows.h" 36 | 37 | int setenv(const char *name, const char *value, int overwrite) 38 | { 39 | int exists = GetEnvironmentVariableA(name, NULL, 0); 40 | if ((exists && overwrite) || (!exists)) { 41 | if (!SetEnvironmentVariableA(name, value)) { 42 | // Set errno here correctly 43 | return -1; 44 | } 45 | return 0; 46 | } 47 | // Exists and overwrite is 0. 48 | return -1; 49 | } 50 | 51 | void unsetenv(const char *name) 52 | { 53 | SetEnvironmentVariableA(name, NULL); 54 | } 55 | -------------------------------------------------------------------------------- /libnfc-1.7.1/utils/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = \ 2 | nfc-emulate-forum-tag4 \ 3 | nfc-jewel \ 4 | nfc-list \ 5 | nfc-mfclassic \ 6 | nfc-mfultralight \ 7 | nfc-read-forum-tag3 \ 8 | nfc-relay-picc \ 9 | nfc-scan-device 10 | 11 | # set the include path found by configure 12 | AM_CPPFLAGS = $(all_includes) $(LIBNFC_CFLAGS) 13 | 14 | noinst_LTLIBRARIES = libnfcutils.la 15 | 16 | libnfcutils_la_SOURCES = nfc-utils.c 17 | 18 | nfc_emulate_forum_tag4_SOURCES = nfc-emulate-forum-tag4.c nfc-utils.h 19 | nfc_emulate_forum_tag4_LDADD = $(top_builddir)/libnfc/libnfc.la \ 20 | libnfcutils.la 21 | 22 | nfc_jewel_SOURCES = nfc-jewel.c jewel.c jewel.h nfc-utils.h 23 | nfc_jewel_LDADD = $(top_builddir)/libnfc/libnfc.la 24 | 25 | nfc_list_SOURCES = nfc-list.c nfc-utils.h 26 | nfc_list_LDADD = $(top_builddir)/libnfc/libnfc.la \ 27 | libnfcutils.la 28 | 29 | nfc_mfclassic_SOURCES = nfc-mfclassic.c mifare.c mifare.h nfc-utils.h 30 | nfc_mfclassic_LDADD = $(top_builddir)/libnfc/libnfc.la \ 31 | libnfcutils.la 32 | 33 | nfc_mfultralight_SOURCES = nfc-mfultralight.c mifare.c mifare.h nfc-utils.h 34 | nfc_mfultralight_LDADD = $(top_builddir)/libnfc/libnfc.la 35 | 36 | nfc_read_forum_tag3_SOURCES = nfc-read-forum-tag3.c nfc-utils.h 37 | nfc_read_forum_tag3_LDADD = $(top_builddir)/libnfc/libnfc.la \ 38 | libnfcutils.la 39 | 40 | nfc_relay_picc_SOURCES = nfc-relay-picc.c nfc-utils.h 41 | nfc_relay_picc_LDADD = $(top_builddir)/libnfc/libnfc.la \ 42 | libnfcutils.la 43 | 44 | nfc_scan_device_SOURCES = nfc-scan-device.c nfc-utils.h 45 | nfc_scan_device_LDADD = $(top_builddir)/libnfc/libnfc.la \ 46 | libnfcutils.la 47 | 48 | dist_man_MANS = \ 49 | nfc-emulate-forum-tag4.1 \ 50 | nfc-jewel.1 \ 51 | nfc-list.1 \ 52 | nfc-mfclassic.1 \ 53 | nfc-mfultralight.1 \ 54 | nfc-read-forum-tag3.1 \ 55 | nfc-relay-picc.1 \ 56 | nfc-scan-device.1 57 | 58 | EXTRA_DIST = CMakeLists.txt 59 | -------------------------------------------------------------------------------- /libnfc-1.7.1/libnfc/buses/i2c.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Free/Libre Near Field Communication (NFC) library 3 | * 4 | * Libnfc historical contributors: 5 | * Copyright (C) 2009 Roel Verdult 6 | * Copyright (C) 2009-2013 Romuald Conty 7 | * Copyright (C) 2010-2012 Romain Tarti?re 8 | * Copyright (C) 2010-2013 Philippe Teuwen 9 | * Copyright (C) 2012-2013 Ludovic Rousseau 10 | * See AUTHORS file for a more comprehensive list of contributors. 11 | * Additional contributors of this file: 12 | * Copyright (C) 2013 Laurent Latil 13 | * 14 | * This program is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU Lesser General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or (at your 17 | * option) any later version. 18 | * 19 | * This program is distributed in the hope that it will be useful, but WITHOUT 20 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 21 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 22 | * more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public License 25 | * along with this program. If not, see 26 | * 27 | */ 28 | 29 | /** 30 | * @file i2c.h 31 | * @brief I2C driver header 32 | */ 33 | 34 | #ifndef __NFC_BUS_I2C_H__ 35 | # define __NFC_BUS_I2C_H__ 36 | 37 | # include 38 | 39 | # include 40 | # include 41 | # include 42 | 43 | # include 44 | # include 45 | 46 | typedef void *i2c_device; 47 | # define INVALID_I2C_BUS (void*)(~1) 48 | # define INVALID_I2C_ADDRESS (void*)(~2) 49 | 50 | i2c_device i2c_open(const char *pcI2C_busName, uint32_t devAddr); 51 | 52 | void i2c_close(const i2c_device id); 53 | 54 | ssize_t i2c_read(i2c_device id, uint8_t *pbtRx, const size_t szRx); 55 | 56 | int i2c_write(i2c_device id, const uint8_t *pbtTx, const size_t szTx); 57 | 58 | char **i2c_list_ports(void); 59 | 60 | #endif // __NFC_BUS_I2C_H__ 61 | -------------------------------------------------------------------------------- /libnfc-1.7.1/examples/nfc-emulate-forum-tag2.1: -------------------------------------------------------------------------------- 1 | .Dd September 19, 2012 2 | .Dt NFC-EMULATE-FORUM-TAG2 1 URM 3 | .Sh NAME 4 | .Nm nfc-emulate-forum-tag2 5 | .Nd NFC Forum tag type 2 emulation command line demonstration tool 6 | .Sh SYNOPSIS 7 | .Nm 8 | .Sh DESCRIPTION 9 | .Nm 10 | is a demonstration tool that emulates a NFC-Forum Tag Type 2 with NDEF content. 11 | .Pp 12 | Some devices compliant with NFC-Forum Tag Type 2 can be used with this example, 13 | in read mode only. 14 | .Sh IMPORTANT 15 | This example has been developed using PN533 USB hardware as target and Google 16 | Nexus S phone as initiator. 17 | .Pp 18 | This is know to NOT work with Nokia 6212 Classic and could fail with several 19 | NFC Forum compliant devices due to the following reasons: 20 | .Pp 21 | - The emulated target has only a 4-byte UID while most devices assume a 22 | Tag Type 2 has always a 7-byte UID (as a real Mifare Ultralight tag); 23 | .Pp 24 | - The chip is emulating an ISO/IEC 14443-3 tag, without any hardware helper. 25 | If the initiator have too strict timeouts for software-based emulation 26 | (which is usually the case), this example will fail. 27 | This is not a bug and we can't do anything using this hardware (PN531/PN533). 28 | .Pp 29 | ACR122 devices (like touchatag, etc.) can be used by this example, but if 30 | something goes wrong, you will have to unplug/replug your device. 31 | This is not a 32 | .Em libnfc's 33 | bug, this problem is due to ACR122's internal MCU in front of NFC chip (PN532). 34 | .Sh BUGS 35 | Please report any bugs on the 36 | .Em libnfc 37 | issue tracker at: 38 | .Em http://code.google.com/p/libnfc/issues 39 | .Sh LICENCE 40 | .Em libnfc 41 | is licensed under the GNU Lesser General Public License (LGPL), version 3. 42 | .Em libnfc-utils 43 | and 44 | .Em libnfc-examples 45 | are covered by the BSD 2-Clause license. 46 | .Sh AUTHORS 47 | .An Roel Verdult Aq roel@libnfc.org 48 | .An Romain Tartière Aq romain@libnfc.org 49 | .An Romuald Conty Aq romuald@libnfc.org 50 | .Pp 51 | This manual page was written by Romuald Conty. 52 | It is licensed under the terms of the GNU GPL (version 2 or later). 53 | -------------------------------------------------------------------------------- /libnfc-1.7.1/libnfc/additional-pages.dox: -------------------------------------------------------------------------------- 1 | /** 2 | * @mainpage libnfc reference manual 3 | * 4 | * @section intro_sec Introduction 5 | * This is the developer manual for \b libnfc. 6 | * libnfc is an open source library that allows you to communicate with NFC devices. For more info, see the 7 | * libnfc homepage. 8 | * 9 | * @section quick_start_sec Quick start 10 | * If you are looking for libnfc's public API, you should start with the Modules page which links to the different categories of libnfc's functionality. 11 | * Some commented examples that present how to use \b libnfc can be found here: 12 | * @subpage examples_page 13 | * 14 | * Others example programs can be found in the libnfc source distribution under the "examples" subdirectory \ref examples. 15 | * 16 | * You can also find utils in the libnfc source distribution under the "utils" subdirectory \ref utils. 17 | * 18 | * \section errorhandling Error handling 19 | * 20 | * \b libnfc functions typically return 0 or more on success or a negative error code 21 | * on failure. These negative error codes relate to LIBNFC_ERROR constants 22 | * which are listed on the \ref error "Error reporting" documentation page. 23 | * 24 | * @section upgrading_sec Upgrading from previous version 25 | * If you are upgrading from a previous \b libnfc version, please take care about changes, specially API changes. 26 | * All important changes should be listed in @subpage changelog_page. 27 | */ 28 | 29 | /** 30 | * @page examples_page Examples 31 | * @section intro_sec Introduction 32 | * This page presents some examples to help developers which use \b libnfc. 33 | * 34 | * @section example_1_sec Simple tag UID reader. 35 | * This short commented code example should be helpful to quick start development with \b libnfc, it grab the first available NFC device and print the first found ISO14443-A tag (e.g. MIFARE Classic, MIFARE Ultralight). 36 | * @include examples/doc/quick_start_example1.c 37 | */ 38 | 39 | /** 40 | * @page changelog_page ChangeLog 41 | * @verbinclude ChangeLog 42 | */ 43 | 44 | -------------------------------------------------------------------------------- /libnfc-1.7.1/examples/nfc-poll.1: -------------------------------------------------------------------------------- 1 | .TH nfc-poll 1 "June 26, 2009" "libnfc" "libnfc's examples" 2 | .SH NAME 3 | nfc-poll \- poll first available NFC target 4 | .SH SYNOPSIS 5 | .B nfc-poll 6 | .SH DESCRIPTION 7 | .B nfc-poll 8 | is a utility for polling any available target (tags but also NFCIP targets) 9 | using ISO14443-A, FeliCa, Jewel and ISO14443-B modulations. 10 | 11 | This tool uses hardware polling feature if available (ie. PN532) or switch back 12 | to software polling, it will display available information retrieved from the 13 | tag. 14 | 15 | .SH OPTIONS 16 | .TP 17 | .B \-v 18 | Tells 19 | .I 20 | nfc-poll 21 | to be verbose and display detailed information about the targets shown. 22 | This includes SAK decoding and fingerprinting is available. 23 | 24 | .SH IMPORTANT 25 | There are some well-know limits with this example: 26 | - Even with NDO_AUTO_14443_4A enabled (default), 27 | .B nfc-poll 28 | can miss ATS. That due to the way the PN532 use to poll for ISO14443 type A, it 29 | will attempt to find ISO14443-4-only targets, then ISO14443-3. If your 30 | ISO14443-4 target is present when PN532 looks for ISO14443-4-only, ATS will be 31 | retrieved. But if your target enter the field during ISO14443-3, RATS will not 32 | be sent and ATS not retrieved. 33 | - 34 | .B nfc-poll 35 | can show up only one card while two are in field. That's due, again, to the way 36 | the PN532 poll for targets. It will stop polling when one modulation got a 37 | result, so if you have, for example, one ISO14443-3 (eg. Mifare Ultralight) and 38 | one ISO14443-4 (eg. Mifare DESFire), it will probably return only the 39 | ISO14443-4. 40 | .SH BUGS 41 | Please report any bugs on the 42 | .B libnfc 43 | issue tracker at: 44 | .br 45 | .BR http://code.google.com/p/libnfc/issues 46 | .SH LICENCE 47 | .B libnfc 48 | is licensed under the GNU Lesser General Public License (LGPL), version 3. 49 | .br 50 | .B libnfc-utils 51 | and 52 | .B libnfc-examples 53 | are covered by the the BSD 2-Clause license. 54 | .SH AUTHORS 55 | Romuald Conty 56 | .PP 57 | This manual page was written by Romuald Conty . 58 | It is licensed under the terms of the GNU GPL (version 2 or later). 59 | -------------------------------------------------------------------------------- /libnfc-1.7.1/utils/nfc-list.1: -------------------------------------------------------------------------------- 1 | .TH nfc-list 1 "June 26, 2009" "libnfc" "NFC Utilities" 2 | .SH NAME 3 | nfc-list \- list NFC targets 4 | .SH SYNOPSIS 5 | .B nfc-list 6 | [ 7 | .I options 8 | ] 9 | .SH DESCRIPTION 10 | .B nfc-list 11 | is a utility for listing any available tags like ISO14443-A, FeliCa, Jewel 12 | or ISO14443-B (according to the device capabilities). 13 | It may detect several tags at once thanks to a mechanism called anti-collision 14 | but all types of tags don't support anti-collision and there is some physical 15 | limitation of the number of tags the reader can discover. 16 | 17 | This tool displays all available information at selection time. 18 | 19 | .SH OPTIONS 20 | .TP 21 | .B \-v 22 | Tells 23 | .I 24 | nfc-list 25 | to be verbose and display detailed information about the targets shown. 26 | This includes SAK decoding and fingerprinting is available. 27 | .TP 28 | \fB-t\fP \fIX\fP 29 | Polls only for types according to bitfield value of \fIX\fP: 30 | 1: ISO14443A 31 | 2: Felica (212 kbps) 32 | 4: Felica (424 kbps) 33 | 8: ISO14443B 34 | 16: ISO14443B' 35 | 32: ISO14443B-2 ST SRx 36 | 64: ISO14443B-2 ASK CTx 37 | 128: Jewel 38 | 39 | So 255 (default) polls for all types. 40 | 41 | Note that if 16, 32 or 64 then 8 is selected too. 42 | 43 | .SH EXAMPLE 44 | For an ISO/IEC 14443-A tag (i.e.Mifare DESFire): 45 | 46 | ATQA (SENS_RES): 03 44 47 | UID (NFCID1): 04 45 35 01 db 24 80 48 | SAK (SEL_RES): 20 49 | ATS (ATR): 75 77 81 02 80 50 | 51 | .SH BUGS 52 | Please report any bugs on the 53 | .B libnfc 54 | issue tracker at: 55 | .br 56 | .BR http://code.google.com/p/libnfc/issues 57 | .SH LICENCE 58 | .B libnfc 59 | is licensed under the GNU Lesser General Public License (LGPL), version 3. 60 | .br 61 | .B libnfc-utils 62 | and 63 | .B libnfc-examples 64 | are covered by the the BSD 2-Clause license. 65 | .SH AUTHORS 66 | Roel Verdult , 67 | .br 68 | Romain Tartière , 69 | .br 70 | Romuald Conty . 71 | .PP 72 | This manual page was written by Romuald Conty . 73 | It is licensed under the terms of the GNU GPL (version 2 or later). 74 | -------------------------------------------------------------------------------- /libnfc-1.7.1/contrib/win32/libnfc/log-internal.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Free/Libre Near Field Communication (NFC) library 3 | * 4 | * Libnfc historical contributors: 5 | * Copyright (C) 2009 Roel Verdult 6 | * Copyright (C) 2009-2013 Romuald Conty 7 | * Copyright (C) 2010-2012 Romain Tartière 8 | * Copyright (C) 2010-2013 Philippe Teuwen 9 | * Copyright (C) 2012-2013 Ludovic Rousseau 10 | * See AUTHORS file for a more comprehensive list of contributors. 11 | * Additional contributors of this file: 12 | * Copyright (C) 2013 Alex Lian 13 | * 14 | * This program is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU Lesser General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or (at your 17 | * option) any later version. 18 | * 19 | * This program is distributed in the hope that it will be useful, but WITHOUT 20 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 21 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 22 | * more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public License 25 | * along with this program. If not, see 26 | */ 27 | 28 | #include "log-internal.h" 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | static void 35 | log_output_debug(const char *format, va_list args) 36 | { 37 | char buffer[1024]; 38 | HRESULT hr = StringCbVPrintf(buffer, sizeof(buffer), format, args); 39 | // Spew what we got, even if the buffer is not sized large enough 40 | if ((STRSAFE_E_INSUFFICIENT_BUFFER == hr) || (S_OK == hr)) 41 | OutputDebugString(buffer); 42 | } 43 | 44 | void 45 | log_vput_internal(const char *format, va_list args) 46 | { 47 | vfprintf(stderr, format, args); 48 | // Additional windows output to the debug window for debugging purposes 49 | log_output_debug(format, args); 50 | } 51 | 52 | void 53 | log_put_internal(const char *format, ...) 54 | { 55 | va_list va; 56 | va_start(va, format); 57 | vfprintf(stderr, format, va); 58 | // Additional windows output to the debug window for debugging purposes 59 | log_output_debug(format, va); 60 | va_end(va); 61 | } 62 | -------------------------------------------------------------------------------- /libnfc-1.7.1/utils/nfc-emulate-forum-tag4.1: -------------------------------------------------------------------------------- 1 | .Dd March 12, 2011 2 | .Dt NFC-EMULATE-FORUM-TAG4 1 URM 3 | .Sh NAME 4 | .Nm nfc-emulate-forum-tag4 5 | .Nd NFC Forum tag type 4 emulation command line demonstration tool 6 | .Sh SYNOPSIS 7 | .Nm 8 | .Op -1 9 | .Op infile Op outfile 10 | .Sh DESCRIPTION 11 | .Nm 12 | is a demonstration tool that emulates a NFC Forum tag type 4 v2.0 (or v1.0) with NDEF content. 13 | .Pp 14 | .Ar -1 15 | can be provided to force old Tag Type 4 version 1.0 behavior. 16 | .Pp 17 | .Ar infile 18 | is the file which contains NDEF message you want to share with the NFC-Forum 19 | compliant initiator device (e.g. Nokia 6212 Classic for a v1.0 tag) 20 | .Pp 21 | If you want to save a shared content by the initiator device, we have to give 22 | .Ar outfile 23 | argument to point where the NDEF message will be saved. 24 | .Pp 25 | This example uses the hardware capability of PN532 to handle ISO/IEC 14443-4 26 | low-level frames like RATS/ATS, WTX, etc. 27 | .Pp 28 | All devices compliant with NFC-Forum Tag Type 4 (Version 2.0 or 1.0) can be used with 29 | this example in read-write mode. 30 | .Pp 31 | If no argument is given, a default NDEF file is available. 32 | .Sh IMPLEMENTATION NOTES 33 | You can specify the same 34 | .Ar infile 35 | and 36 | .Ar outfile 37 | .Sh IMPORTANT 38 | Only PN532 equipped devices can use this example. (e.g. PN532 breakout board) 39 | .Pp 40 | ACR122 devices (like touchatag, etc.) can be used by this example, but if 41 | something goes wrong, you will have to unplug/replug your device. 42 | This is not a 43 | .Em libnfc's 44 | bug, this problem is due to ACR122's internal MCU in front of NFC chip (PN532). 45 | .Sh BUGS 46 | Please report any bugs on the 47 | .Em libnfc 48 | issue tracker at: 49 | .Em http://code.google.com/p/libnfc/issues 50 | .Sh LICENCE 51 | .Em libnfc 52 | is licensed under the GNU Lesser General Public License (LGPL), version 3. 53 | .Em libnfc-utils 54 | and 55 | .Em libnfc-examples 56 | are covered by the BSD 2-Clause license. 57 | .Sh AUTHORS 58 | .An Roel Verdult Aq roel@libnfc.org 59 | .An Romain Tartière Aq romain@libnfc.org 60 | .An Romuald Conty Aq romuald@libnfc.org 61 | .Pp 62 | This manual page was written by Romuald Conty. 63 | It is licensed under the terms of the GNU GPL (version 2 or later). 64 | -------------------------------------------------------------------------------- /libnfc-1.7.1/libnfc/buses/uart.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Free/Libre Near Field Communication (NFC) library 3 | * 4 | * Libnfc historical contributors: 5 | * Copyright (C) 2009 Roel Verdult 6 | * Copyright (C) 2009-2013 Romuald Conty 7 | * Copyright (C) 2010-2012 Romain Tartière 8 | * Copyright (C) 2010-2013 Philippe Teuwen 9 | * Copyright (C) 2012-2013 Ludovic Rousseau 10 | * See AUTHORS file for a more comprehensive list of contributors. 11 | * Additional contributors of this file: 12 | * 13 | * This program is free software: you can redistribute it and/or modify it 14 | * under the terms of the GNU Lesser General Public License as published by the 15 | * Free Software Foundation, either version 3 of the License, or (at your 16 | * option) any later version. 17 | * 18 | * This program is distributed in the hope that it will be useful, but WITHOUT 19 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 21 | * more details. 22 | * 23 | * You should have received a copy of the GNU Lesser General Public License 24 | * along with this program. If not, see 25 | * 26 | */ 27 | 28 | /** 29 | * @file uart.h 30 | * @brief UART driver header 31 | */ 32 | 33 | #ifndef __NFC_BUS_UART_H__ 34 | # define __NFC_BUS_UART_H__ 35 | 36 | # include 37 | 38 | # include 39 | # include 40 | # include 41 | 42 | 43 | # include 44 | 45 | // Define shortcut to types to make code more readable 46 | typedef void *serial_port; 47 | # define INVALID_SERIAL_PORT (void*)(~1) 48 | # define CLAIMED_SERIAL_PORT (void*)(~2) 49 | 50 | serial_port uart_open(const char *pcPortName); 51 | void uart_close(const serial_port sp); 52 | void uart_flush_input(const serial_port sp, bool wait); 53 | 54 | void uart_set_speed(serial_port sp, const uint32_t uiPortSpeed); 55 | uint32_t uart_get_speed(const serial_port sp); 56 | 57 | int uart_receive(serial_port sp, uint8_t *pbtRx, const size_t szRx, void *abort_p, int timeout); 58 | int uart_send(serial_port sp, const uint8_t *pbtTx, const size_t szTx, int timeout); 59 | 60 | char **uart_list_ports(void); 61 | 62 | #endif // __NFC_BUS_UART_H__ 63 | -------------------------------------------------------------------------------- /libnfc-1.7.1/examples/pn53x-tamashell-scripts/ReadNavigo.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ID=$(cat << EOF | \ 4 | pn53x-tamashell |\ 5 | grep -A1 "^Tx: 42 01 0b 3f 80" |\ 6 | sed -e '1d' -e "s/^Rx: 00 .. .. \(.. .. .. ..\).*/\1/" -e 's/ //g' 7 | # Timeouts 8 | 3205000002 9 | # ListTarget ModeB 10 | 4a010300 11 | # TypeB' APGEN 12 | 42010b3f80 13 | EOF 14 | ) 15 | 16 | if [ -z "$ID" ]; then 17 | echo "Error: I was not abble to read Navigo ID" >&2 18 | exit 1 19 | fi 20 | 21 | cat << EOF | \ 22 | pn53x-tamashell |\ 23 | awk '\ 24 | /^> #.*:/{ 25 | sub(/^> #/,"") 26 | n=$0 27 | for (i=0;i<8-length();i++) { 28 | n= n " " 29 | } 30 | getline 31 | getline 32 | getline 33 | sub(/Rx: 00/,"") 34 | gsub(/ +/," ") 35 | sub(/ 90 00 $/,"") 36 | print n toupper($0)}' 37 | 38 | # Timeouts 39 | 3205000002 40 | 41 | # ListTarget ModeB 42 | 4a010300 43 | 44 | # TypeB' 45 | 42010b3f80 46 | 47 | # timings... 48 | 3202010b0c 49 | 50 | # TypeB' ATTRIB 51 | 42 01 0f $ID 52 | 53 | # Select ICC file 54 | 42 01 04 0a 00a4 0800 04 3f00 0002 55 | #ICC: 56 | 42 01 06 06 00b2 0104 1d 57 | 58 | # Select EnvHol file 59 | 42 01 08 0a 00a4 0800 04 2000 2001 60 | #EnvHol1: 61 | 42 01 0a 06 00b2 0104 1d 62 | 63 | # Select EvLog file 64 | 42 01 0c 0a 00a4 0800 04 2000 2010 65 | #EvLog1: 66 | 42 01 0e 06 00b2 0104 1d 67 | #EvLog2: 68 | 42 01 00 06 00b2 0204 1d 69 | #EvLog3: 70 | 42 01 02 06 00b2 0304 1d 71 | 72 | # Select ConList file 73 | 42 01 04 0a 00a4 0800 04 2000 2050 74 | #ConList: 75 | 42 01 06 06 00b2 0104 1d 76 | 77 | # Select Contra file 78 | 42 01 08 0a 00a4 0800 04 2000 2020 79 | #Contra1: 80 | 42 01 0a 06 00b2 0104 1d 81 | #Contra2: 82 | 42 01 0c 06 00b2 0204 1d 83 | #Contra3: 84 | 42 01 0e 06 00b2 0304 1d 85 | #Contra4: 86 | 42 01 00 06 00b2 0404 1d 87 | 88 | # Select Counter file 89 | 42 01 02 0a 00a4 0800 04 2000 2069 90 | #Counter: 91 | 42 01 04 06 00b2 0104 1d 92 | 93 | # Select SpecEv file 94 | 42 01 06 0a 00a4 08 0004 2000 2040 95 | #SpecEv1: 96 | 42 01 08 06 00b2 0104 1d 97 | 98 | # TypeB' Disconnect 99 | 42 01 03 100 | 101 | EOF 102 | -------------------------------------------------------------------------------- /win32/README.TXT: -------------------------------------------------------------------------------- 1 | Table of Contents 2 | ================== 3 | 0. About 4 | 1. Set a UID 5 | 2. Operation 6 | 3. Obtain Data and Crack key 7 | 4. Further cracking 8 | 9 | //////////////////////////////////// 10 | 11 | 0. About 12 | 13 | /////////////////////////////////// 14 | 15 | An interface to the Mifare Super (Suppa/Supper) Card utilising the libnfc 1.7.1 library. 16 | Many super-card card programs are either broken / wrong type / or written in Chinese. 17 | This is a simple English (American) Language program to faciliate non-Chinese users. 18 | 19 | This program has been tested successfully on: 20 | * WinXP (32bit) SP0/1/2/3 21 | * Vista (32bit) SP0/1/2 22 | 23 | The program has two modes read & write, these operations are detailed below... 24 | 25 | 26 | //////////////////////////////////// 27 | 28 | 1. Set a UID 29 | 30 | /////////////////////////////////// 31 | 32 | Using the '-w' flag set a 4-byte (8 hex chars) UID 33 | 34 | $ nfc-super.exe -w 22334455 35 | Mifare Super Card v0.1 (C)2014 Andy 36 | 37 | ISO/IEC 14443A (106 kbps) target: 38 | ATQA (SENS_RES): 00 04 39 | UID (NFCID1): 11 22 33 44 40 | SAK (SEL_RES): 08 41 | 42 | //////////////////////////////////// 43 | 44 | 2. Operation 45 | 46 | /////////////////////////////////// 47 | 48 | 49 | Place the card upto a Mifare reader, and ensure you obtain two or more (2+) failed authentication attempts. 50 | 51 | 52 | //////////////////////////////////// 53 | 54 | 3. Obtain data and crack key 55 | 56 | /////////////////////////////////// 57 | 58 | Place the super-card on the reader, launch the program with the '-r' flag, the program should automatically 59 | obtain the necessary values and crack the reader key. 60 | 61 | $ nfc-super.exe -r 62 | Mifare Super Card v0.1 (C)2014 Andy 63 | 64 | ISO/IEC 14443A (106 kbps) target: 65 | ATQA (SENS_RES): 00 04 66 | UID (NFCID1): 22 33 44 55 67 | SAK (SEL_RES): 08 68 | UID: 22 33 44 55 69 | 1:NR: c9 6f 2e a5 70 | 1:AR: 71 67 3d 4d 71 | 2:NR: 38 aa fa ba 72 | 2:AR: 5d 32 cd f4 73 | Cracking... 74 | Found Key: [e5b20aeeffff] 75 | 76 | 77 | //////////////////////////////////// 78 | 79 | 4. Further cracking 80 | 81 | /////////////////////////////////// 82 | 83 | Use the Mifare nested attack (or mfoc.exe) to crack any remaining keys on the card. -------------------------------------------------------------------------------- /libnfc-1.7.1/examples/nfc-emulate-tag.1: -------------------------------------------------------------------------------- 1 | .TH nfc-emulate-tag 1 "October 8, 2010" "libnfc" "libnfc's examples" 2 | .SH NAME 3 | nfc-emulate-tag \- Simple tag emulation command line demonstration tool 4 | .SH SYNOPSIS 5 | .B nfc-emulate-tag 6 | .SH DESCRIPTION 7 | .B nfc-emulate-tag 8 | is a simple tag emulation tool that demonstrates how emulation can be done 9 | using libnfc. 10 | 11 | Currently, this tool partially emulates a Mifare Mini: it is detected as 12 | Mifare Mini but internal MIFARE proprietary commands are not yet implemented. 13 | 14 | To be able to emulate a target, there are two main parts: 15 | - communication: handle modulation, anticollision, etc. 16 | - computation: process commands (input) and produce results (output). 17 | 18 | This demonstration tool proposes a logical structure to handle communication and 19 | a simple function to deal with computation. 20 | 21 | To improve the target capabilities, we can now implement more allowed commands 22 | in a single function: target_io() 23 | 24 | Please note that, due to timing issues, it is very difficult to implement an 25 | ISO14443-4 tag this way: RATS request expects a quick ATS answer. By the way, 26 | even if you implement another kind of tag, timing issues are often the source of 27 | problems like CRC or parity errors. 28 | The OmniKey CardMan 5321 is known to be very large on timings and is a good 29 | choice if you want to experiment with this emulator with a tolerant reader. 30 | 31 | .SH IMPORTANT 32 | ACR122 devices (like touchatag, etc.) can be used by this example (with 33 | probably timing issue), but if something goes wrong, you will have to 34 | unplug/replug your device. This is not a 35 | .B libnfc's 36 | bug, this problem is due to ACR122's internal MCU in front of NFC chip (PN532). 37 | .SH BUGS 38 | Please report any bugs on the 39 | .B libnfc 40 | issue tracker at: 41 | .br 42 | .BR http://code.google.com/p/libnfc/issues 43 | .SH LICENCE 44 | .B libnfc 45 | is licensed under the GNU Lesser General Public License (LGPL), version 3. 46 | .br 47 | .B libnfc-utils 48 | and 49 | .B libnfc-examples 50 | are covered by the the BSD 2-Clause license. 51 | .SH AUTHORS 52 | Romuald Conty 53 | .PP 54 | This manual page was written by Romuald Conty . 55 | It is licensed under the terms of the GNU GPL (version 2 or later). 56 | -------------------------------------------------------------------------------- /libnfc-1.7.1/cmake/modules/FindLIBUSB.cmake: -------------------------------------------------------------------------------- 1 | # This CMake script wants to use libusb functionality, therefore it looks 2 | # for libusb include files and libraries. 3 | # 4 | # Operating Systems Supported: 5 | # - Unix (requires pkg-config) 6 | # Tested with Ubuntu 9.04 and Fedora 11 7 | # - Windows (requires MinGW) 8 | # Tested with Windows XP/Windows 7 9 | # 10 | # This should work for both 32 bit and 64 bit systems. 11 | # 12 | # Author: F. Kooman 13 | # 14 | 15 | # FreeBSD has built-in libusb since 800069 16 | IF(CMAKE_SYSTEM_NAME MATCHES FreeBSD) 17 | EXEC_PROGRAM(sysctl ARGS -n kern.osreldate OUTPUT_VARIABLE FREEBSD_VERSION) 18 | SET(MIN_FREEBSD_VERSION 800068) 19 | IF(FREEBSD_VERSION GREATER ${MIN_FREEBSD_VERSION}) 20 | SET(LIBUSB_FOUND TRUE) 21 | SET(LIBUSB_INCLUDE_DIRS "/usr/include") 22 | SET(LIBUSB_LIBRARIES "usb") 23 | SET(LIBUSB_LIBRARY_DIRS "/usr/lib/") 24 | ENDIF(FREEBSD_VERSION GREATER ${MIN_FREEBSD_VERSION}) 25 | ENDIF(CMAKE_SYSTEM_NAME MATCHES FreeBSD) 26 | 27 | IF(NOT LIBUSB_FOUND) 28 | IF(WIN32) 29 | FIND_PATH(LIBUSB_INCLUDE_DIRS lusb0_usb.h "$ENV{ProgramFiles}/LibUSB-Win32/include" NO_SYSTEM_ENVIRONMENT_PATH) 30 | FIND_LIBRARY(LIBUSB_LIBRARIES NAMES libusb PATHS "$ENV{ProgramFiles}/LibUSB-Win32/lib/gcc") 31 | SET(LIBUSB_LIBRARY_DIR "$ENV{ProgramFiles}/LibUSB-Win32/bin/x86/") 32 | # Must fix up variable to avoid backslashes during packaging 33 | STRING(REGEX REPLACE "\\\\" "/" LIBUSB_LIBRARY_DIR ${LIBUSB_LIBRARY_DIR}) 34 | ELSE(WIN32) 35 | # If not under Windows we use PkgConfig 36 | FIND_PACKAGE (PkgConfig) 37 | IF(PKG_CONFIG_FOUND) 38 | PKG_CHECK_MODULES(LIBUSB REQUIRED libusb) 39 | ELSE(PKG_CONFIG_FOUND) 40 | MESSAGE(FATAL_ERROR "Could not find PkgConfig") 41 | ENDIF(PKG_CONFIG_FOUND) 42 | ENDIF(WIN32) 43 | 44 | IF(LIBUSB_INCLUDE_DIRS AND LIBUSB_LIBRARIES) 45 | SET(LIBUSB_FOUND TRUE) 46 | ENDIF(LIBUSB_INCLUDE_DIRS AND LIBUSB_LIBRARIES) 47 | ENDIF(NOT LIBUSB_FOUND) 48 | 49 | IF(LIBUSB_FOUND) 50 | IF(NOT LIBUSB_FIND_QUIETLY) 51 | MESSAGE(STATUS "Found LIBUSB: ${LIBUSB_LIBRARIES} ${LIBUSB_INCLUDE_DIRS}") 52 | ENDIF (NOT LIBUSB_FIND_QUIETLY) 53 | ELSE(LIBUSB_FOUND) 54 | IF(LIBUSB_FIND_REQUIRED) 55 | MESSAGE(FATAL_ERROR "Could not find LIBUSB") 56 | ENDIF(LIBUSB_FIND_REQUIRED) 57 | ENDIF(LIBUSB_FOUND) 58 | -------------------------------------------------------------------------------- /libnfc-1.7.1/HACKING: -------------------------------------------------------------------------------- 1 | Hello hackers! 2 | 3 | General remarks about contributing 4 | ---------------------------------- 5 | 6 | Contributions to the libnfc are welcome! 7 | Here are some directions to get you started: 8 | 9 | 1. Follow style conventions 10 | The source code of the library trend to follow some conventions so that it 11 | is consistent in style and thus easier to read. 12 | Look around and respect the same style. 13 | Don't use tabs. Increment unit is two spaces. 14 | Don't leave dandling spaces or tabs at EOL. 15 | Helper script to get some uniformity in the style: 16 | $ make style 17 | 18 | If you use vim see the "Vim: How to prevent trailing whitespaces" 19 | http://www.carbon-project.org/Vim__How_to_prevent_trailing_whitespaces.html 20 | 21 | 2. Chase warnings: no warning should be introduced by your changes 22 | Depending what you touch, you can check with: 23 | 2.1 When using autotools 24 | $ autoreconf -Wall -vis 25 | 2.2 When compiling 26 | 2.2.1 Using extra flags: 27 | $ export CFLAGS="-Wall -g -O2 -Wextra -pipe -funsigned-char -fstrict-aliasing \ 28 | -Wchar-subscripts -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wunused \ 29 | -Wuninitialized -Wpointer-arith -Wredundant-decls -Winline -Wformat \ 30 | -Wformat-security -Wswitch-enum -Winit-self -Wmissing-include-dirs \ 31 | -Wmissing-prototypes -Wstrict-prototypes -Wold-style-definition \ 32 | -Wbad-function-cast -Wnested-externs -Wmissing-declarations" 33 | $ ./configure 34 | $ make clean 35 | $ make 36 | 2.2.2 Using clang: 37 | You can use same CFLAGS but also "-Wunreachable-code" 38 | $ scan-build ./configure 39 | $ make clean 40 | $ scan-build make 41 | 2.2.3 Using cppcheck (v1.58 or higher): 42 | $ make cppcheck 43 | 2.3 When Debianizing 44 | $ lintian --info --display-info --display-experimental *deb 45 | or (shorter version) 46 | $ lintian -iIE *deb 47 | 48 | 3. Preserve cross-platform compatility 49 | The source code should remain compilable across various platforms, 50 | including some you probably cannot test alone so keep it in mind. 51 | Supported platforms: 52 | - Linux 53 | - FreeBSD 54 | - Mac OS X 55 | - Windows with Mingw 56 | -------------------------------------------------------------------------------- /libnfc-1.7.1/include/nfc/nfc-emulation.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Free/Libre Near Field Communication (NFC) library 3 | * 4 | * Libnfc historical contributors: 5 | * Copyright (C) 2009 Roel Verdult 6 | * Copyright (C) 2009-2013 Romuald Conty 7 | * Copyright (C) 2010-2012 Romain Tartière 8 | * Copyright (C) 2010-2013 Philippe Teuwen 9 | * Copyright (C) 2012-2013 Ludovic Rousseau 10 | * See AUTHORS file for a more comprehensive list of contributors. 11 | * Additional contributors of this file: 12 | * 13 | * This program is free software: you can redistribute it and/or modify it 14 | * under the terms of the GNU Lesser General Public License as published by the 15 | * Free Software Foundation, either version 3 of the License, or (at your 16 | * option) any later version. 17 | * 18 | * This program is distributed in the hope that it will be useful, but WITHOUT 19 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 21 | * more details. 22 | * 23 | * You should have received a copy of the GNU Lesser General Public License 24 | * along with this program. If not, see 25 | */ 26 | 27 | /** 28 | * @file nfc-emulation.h 29 | * @brief Provide a small API to ease emulation in libnfc 30 | */ 31 | 32 | #ifndef __NFC_EMULATION_H__ 33 | #define __NFC_EMULATION_H__ 34 | 35 | #include 36 | #include 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif /* __cplusplus */ 41 | 42 | struct nfc_emulator; 43 | struct nfc_emulation_state_machine; 44 | 45 | /** 46 | * @struct nfc_emulator 47 | * @brief NFC emulator structure 48 | */ 49 | struct nfc_emulator { 50 | nfc_target *target; 51 | struct nfc_emulation_state_machine *state_machine; 52 | void *user_data; 53 | }; 54 | 55 | /** 56 | * @struct nfc_emulation_state_machine 57 | * @brief NFC emulation state machine structure 58 | */ 59 | struct nfc_emulation_state_machine { 60 | int (*io)(struct nfc_emulator *emulator, const uint8_t *data_in, const size_t data_in_len, uint8_t *data_out, const size_t data_out_len); 61 | void *data; 62 | }; 63 | 64 | NFC_EXPORT int nfc_emulate_target(nfc_device *pnd, struct nfc_emulator *emulator, const int timeout); 65 | 66 | #ifdef __cplusplus 67 | } 68 | #endif /* __cplusplus */ 69 | 70 | 71 | #endif /* __NFC_EMULATION_H__ */ 72 | -------------------------------------------------------------------------------- /libnfc-1.7.1/utils/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | SET(UTILS-SOURCES 2 | nfc-emulate-forum-tag4 3 | nfc-jewel 4 | nfc-list 5 | nfc-mfclassic 6 | nfc-mfultralight 7 | nfc-read-forum-tag3 8 | nfc-relay-picc 9 | nfc-scan-device 10 | nfc-super 11 | ) 12 | 13 | ADD_LIBRARY(nfcutils STATIC 14 | nfc-utils.c 15 | ) 16 | TARGET_LINK_LIBRARIES(nfcutils nfc) 17 | 18 | # Examples 19 | FOREACH(source ${UTILS-SOURCES}) 20 | SET (TARGETS ${source}.c) 21 | 22 | IF(WIN32) 23 | SET(RC_COMMENT "${PACKAGE_NAME} utility") 24 | SET(RC_INTERNAL_NAME ${source}) 25 | SET(RC_ORIGINAL_NAME ${source}.exe) 26 | SET(RC_FILE_TYPE VFT_APP) 27 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/../contrib/win32/version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/../windows/${source}.rc @ONLY) 28 | LIST(APPEND TARGETS ${CMAKE_CURRENT_BINARY_DIR}/../windows/${source}.rc) 29 | ENDIF(WIN32) 30 | 31 | IF(${source} MATCHES "nfc-super") 32 | LIST(APPEND TARGETS crapto1 crypto1) 33 | ENDIF(${source} MATCHES "nfc-super") 34 | 35 | IF(${source} MATCHES "nfc-jewel") 36 | LIST(APPEND TARGETS jewel) 37 | ENDIF(${source} MATCHES "nfc-jewel") 38 | 39 | IF((${source} MATCHES "nfc-mfultralight") OR (${source} MATCHES "nfc-mfclassic")) 40 | LIST(APPEND TARGETS mifare) 41 | ENDIF((${source} MATCHES "nfc-mfultralight") OR (${source} MATCHES "nfc-mfclassic")) 42 | 43 | IF(WIN32) 44 | IF(${source} MATCHES "nfc-scan-device") 45 | LIST(APPEND TARGETS ../contrib/win32/stdlib) 46 | INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../contrib/win32) 47 | ENDIF(${source} MATCHES "nfc-scan-device") 48 | ENDIF(WIN32) 49 | 50 | ADD_EXECUTABLE(${source} ${TARGETS}) 51 | 52 | TARGET_LINK_LIBRARIES(${source} nfc) 53 | TARGET_LINK_LIBRARIES(${source} nfcutils) 54 | 55 | INSTALL(TARGETS ${source} RUNTIME DESTINATION bin COMPONENT utils) 56 | ENDFOREACH(source) 57 | 58 | #install required libraries 59 | IF(WIN32) 60 | INCLUDE(InstallRequiredSystemLibraries) 61 | CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/FixBundle.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FixBundle.cmake @ONLY) 62 | INSTALL(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/FixBundle.cmake) 63 | ENDIF(WIN32) 64 | 65 | IF(NOT WIN32) 66 | # Manuals for the examples 67 | FILE(GLOB manuals "${CMAKE_CURRENT_SOURCE_DIR}/*.1") 68 | INSTALL(FILES ${manuals} DESTINATION ${SHARE_INSTALL_PREFIX}/man/man1 COMPONENT manuals) 69 | ENDIF(NOT WIN32) 70 | -------------------------------------------------------------------------------- /libnfc-1.7.1/contrib/windows.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Free/Libre Near Field Communication (NFC) library 3 | * 4 | * Libnfc historical contributors: 5 | * Copyright (C) 2009 Roel Verdult 6 | * Copyright (C) 2009-2013 Romuald Conty 7 | * Copyright (C) 2010-2012 Romain Tartière 8 | * Copyright (C) 2010-2013 Philippe Teuwen 9 | * Copyright (C) 2012-2013 Ludovic Rousseau 10 | * See AUTHORS file for a more comprehensive list of contributors. 11 | * Additional contributors of this file: 12 | * Copyright (C) 2011 Glenn Ergeerts 13 | * 14 | * This program is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU Lesser General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or (at your 17 | * option) any later version. 18 | * 19 | * This program is distributed in the hope that it will be useful, but WITHOUT 20 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 21 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 22 | * more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public License 25 | * along with this program. If not, see 26 | */ 27 | 28 | /** 29 | * @file windows.h 30 | * @brief Provide some windows related hacks due to lack of POSIX compat 31 | */ 32 | 33 | #ifndef __WINDOWS_H__ 34 | #define __WINDOWS_H__ 35 | 36 | # include 37 | # include 38 | # include "win32/err.h" 39 | # if defined (__MINGW32__) 40 | /* 41 | * Cheating here on the snprintf to incorporate the format argument 42 | * into the VA_ARGS. Else we get MinGW errors regarding number of arguments 43 | * if doing a fixed string with no arguments. 44 | */ 45 | # define snprintf(S, n, ...) sprintf(S, __VA_ARGS__) 46 | # define pipe(fds) _pipe(fds, 5000, _O_BINARY) 47 | # define ETIMEDOUT WSAETIMEDOUT 48 | # define ENOTSUP WSAEOPNOTSUPP 49 | # define ECONNABORTED WSAECONNABORTED 50 | # else 51 | # define snprintf sprintf_s 52 | # define strdup _strdup 53 | # endif 54 | 55 | /* 56 | * setenv and unsetenv are not Windows compliant nor implemented in MinGW. 57 | * These declarations get rid of the "implicit declaration warning." 58 | */ 59 | int setenv(const char *name, const char *value, int overwrite); 60 | void unsetenv(const char *name); 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /libnfc-1.7.1/examples/pn53x-tamashell.1: -------------------------------------------------------------------------------- 1 | .TH pn53x-tamashell 1 "September 15, 2010" 2 | .SH NAME 3 | pn53x-tamashell \- PN53x TAMA communication demonstration shell 4 | .SH SYNOPSIS 5 | .B pn53x-tamashell 6 | .IR [script] 7 | .SH DESCRIPTION 8 | .B pn53x-tamashell 9 | is a simple interactive tool to send so called TAMA commands 10 | and receive the answers. 11 | TAMA refers to the command set supported by the PN53x family. 12 | Messages are binary and the shell expects hexadecimal notation. 13 | TAMA commands and responses prefixes (0xD4/0xD5), CRC and any framing above are handled transparently. 14 | 15 | You can use the shell interactively (with readline support) or you 16 | can write your own script file consisting in commands and 17 | comments (anything that starts with ";", "#" or "//"). 18 | Spaces are ignored and can be used for readability. 19 | 20 | Shebang is supported, simply start your script with: 21 | #!/usr/bin/env \fBpn53x-tamashell\fP 22 | 23 | .SH COMMANDS 24 | 25 | \fIp N\fP to introduce a pause of N milliseconds. 26 | 27 | \fIq\fP or \fICtrl-d\fP to quit. 28 | 29 | .SH EXAMPLES 30 | 31 | GetFirmware command is D4 02, so one has just to send the command "02": 32 | 33 | $ \fBpn53x-tamashell\fP 34 | Connected to NFC reader: SCM Micro/SCL3711-NFC&RW - PN533 v2.7 (0x07) 35 | > 02 36 | Tx: 02 37 | Rx: 33 02 07 07 38 | > 40 39 | Tx: 40 40 | Rx: Command Not Acceptable 41 | > q 42 | Bye! 43 | 44 | Same thing, with a script: 45 | 46 | $ \fBpn53x-tamashell\fP << EOF 47 | // This is a comment 48 | 02 // GetFirmware 49 | 40 // Command with missing arguments 50 | EOF 51 | 52 | Connected to NFC reader: SCM Micro/SCL3711-NFC&RW - PN533 v2.7 (0x07) 53 | > // This is a comment 54 | > 02 // GetFirmware 55 | Tx: 02 56 | Rx: 33 02 07 07 57 | > 40 // Command with missing arguments 58 | Tx: 40 59 | Rx: Command Not Acceptable 60 | > Bye! 61 | 62 | .SH OPTIONS 63 | .IR script 64 | Script file with tama commands 65 | 66 | .SH BUGS 67 | Please report any bugs on the 68 | .B libnfc 69 | issue tracker at: 70 | .br 71 | .BR http://code.google.com/p/libnfc/issues 72 | .SH LICENCE 73 | .B libnfc 74 | is licensed under the GNU Lesser General Public License (LGPL), version 3. 75 | .br 76 | .B libnfc-utils 77 | and 78 | .B libnfc-examples 79 | are covered by the the BSD 2-Clause license. 80 | .PP 81 | This manual page is licensed under the terms of the GNU GPL (version 2 or later). 82 | -------------------------------------------------------------------------------- /libnfc-1.7.1/libnfc/buses/spi.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Free/Libre Near Field Communication (NFC) library 3 | * 4 | * Libnfc historical contributors: 5 | * Copyright (C) 2009 Roel Verdult 6 | * Copyright (C) 2009-2013 Romuald Conty 7 | * Copyright (C) 2010-2012 Romain Tartière 8 | * Copyright (C) 2010-2013 Philippe Teuwen 9 | * Copyright (C) 2012-2013 Ludovic Rousseau 10 | * See AUTHORS file for a more comprehensive list of contributors. 11 | * Additional contributors of this file: 12 | * Copyright (C) 2013 Evgeny Boger 13 | * 14 | * This program is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU Lesser General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or (at your 17 | * option) any later version. 18 | * 19 | * This program is distributed in the hope that it will be useful, but WITHOUT 20 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 21 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 22 | * more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public License 25 | * along with this program. If not, see 26 | * 27 | */ 28 | 29 | /** 30 | * @file spi.h 31 | * @brief SPI driver header 32 | */ 33 | 34 | #ifndef __NFC_BUS_SPI_H__ 35 | # define __NFC_BUS_SPI_H__ 36 | 37 | # include 38 | 39 | # include 40 | # include 41 | # include 42 | 43 | # include 44 | 45 | # include 46 | 47 | // Define shortcut to types to make code more readable 48 | typedef void *spi_port; 49 | # define INVALID_SPI_PORT (void*)(~1) 50 | # define CLAIMED_SPI_PORT (void*)(~2) 51 | 52 | spi_port spi_open(const char *pcPortName); 53 | void spi_close(const spi_port sp); 54 | 55 | void spi_set_speed(spi_port sp, const uint32_t uiPortSpeed); 56 | void spi_set_mode(spi_port sp, const uint32_t uiPortMode); 57 | uint32_t spi_get_speed(const spi_port sp); 58 | 59 | int spi_receive(spi_port sp, uint8_t *pbtRx, const size_t szRx, bool lsb_first); 60 | int spi_send(spi_port sp, const uint8_t *pbtTx, const size_t szTx, bool lsb_first); 61 | int spi_send_receive(spi_port sp, const uint8_t *pbtTx, const size_t szTx, uint8_t *pbtRx, const size_t szRx, bool lsb_first); 62 | 63 | char **spi_list_ports(void); 64 | 65 | #endif // __NFC_BUS_SPI_H__ 66 | -------------------------------------------------------------------------------- /libnfc-1.7.1/examples/pn53x-tamashell-scripts/ReadMobib.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cat << EOF | \ 4 | pn53x-tamashell |\ 5 | awk '\ 6 | /^> #.*:/{ 7 | sub(/^> #/,"") 8 | n=$0 9 | for (i=0;i<8-length();i++) { 10 | n= n " " 11 | } 12 | getline 13 | getline 14 | getline 15 | sub(/Rx: 00/,"") 16 | gsub(/ +/," ") 17 | sub(/ 90 00 $/,"") 18 | print n toupper($0)}' |\ 19 | grep -v ": 6A 83" 20 | 21 | # Select one typeB target 22 | 4A010300 23 | 24 | # Select ICC file 25 | 4001 80a4 0800 04 3f00 0002 26 | #ICC: 27 | 4001 80b2 0104 1d 28 | 29 | # Select Holder file 30 | 4001 80a4 0800 04 3f00 3f1c 31 | #Holder1: 32 | 4001 80b2 0104 1d 33 | #Holder2: 34 | 4001 80b2 0204 1d 35 | 36 | # Select EnvHol file 37 | 4001 00a4 0800 04 2000 2001 38 | #EnvHol1: 39 | 4001 00b2 0104 1d 40 | #EnvHol2: 41 | 4001 00b2 0204 1d 42 | 43 | # Select EvLog file 44 | 4001 00a4 0800 04 2000 2010 45 | #EvLog1: 46 | 4001 00b2 0104 1d 47 | #EvLog2: 48 | 4001 00b2 0204 1d 49 | #EvLog3: 50 | 4001 00b2 0304 1d 51 | 52 | # Select ConList file 53 | 4001 00a4 0800 04 2000 2050 54 | #ConList: 55 | 4001 00b2 0104 1d 56 | 57 | # Select Contra file 58 | 4001 00a4 0800 04 2000 2020 59 | #Contra1: 60 | 4001 00b2 0104 1d 61 | #Contra2: 62 | 4001 00b2 0204 1d 63 | #Contra3: 64 | 4001 00b2 0304 1d 65 | #Contra4: 66 | 4001 00b2 0404 1d 67 | #Contra5: 68 | 4001 00b2 0504 1d 69 | #Contra6: 70 | 4001 00b2 0604 1d 71 | #Contra7: 72 | 4001 00b2 0704 1d 73 | #Contra8: 74 | 4001 00b2 0804 1d 75 | #Contra9: 76 | 4001 00b2 0904 1d 77 | #ContraA: 78 | 4001 00b2 0a04 1d 79 | #ContraB: 80 | 4001 00b2 0b04 1d 81 | #ContraC: 82 | 4001 00b2 0c04 1d 83 | 84 | # Select Counter file 85 | 4001 00a4 0800 04 2000 2069 86 | #Counter: 87 | 4001 00b2 0104 1d 88 | 89 | # Select LoadLog file 90 | 4001 00a4 0800 04 1000 1014 91 | #LoadLog: 92 | 4001 00b2 0104 1d 93 | 94 | # Select Purcha file 95 | 4001 00a4 08 0004 1000 1015 96 | #Purcha1: 97 | 4001 00b2 0104 1d 98 | #Purcha2: 99 | 4001 00b2 0204 1d 100 | #Purcha3: 101 | 4001 00b2 0304 1d 102 | 103 | # Select SpecEv file 104 | 4001 00a4 08 0004 2000 2040 105 | #SpecEv1: 106 | 4001 00b2 0104 1d 107 | #SpecEv2: 108 | 4001 00b2 0204 1d 109 | #SpecEv3: 110 | 4001 00b2 0304 1d 111 | #SpecEv4: 112 | 4001 00b2 0404 1d 113 | EOF 114 | 115 | 116 | -------------------------------------------------------------------------------- /libnfc-1.7.1/utils/nfc-relay-picc.1: -------------------------------------------------------------------------------- 1 | .TH nfc-relay-picc 1 "October 12, 2010" "libnfc" "NFC Utilities" 2 | .SH NAME 3 | nfc-relay-picc \- Relay demonstration tool for ISO14443-4 4 | .SH SYNOPSIS 5 | .B nfc-relay-picc 6 | .SH DESCRIPTION 7 | .B nfc-relay-picc 8 | 9 | This tool requires two NFC devices. One device (configured as target) will 10 | emulate an ISO/IEC 14443-4 type A tag, while the second device (configured as 11 | initiator) will act as a reader. The genuine tag can be placed on the second 12 | device (initiator) and the tag emulator (target) can be placed close to the 13 | original reader. All communication is now relayed and shown in the screen on 14 | real-time. 15 | 16 | tag <---> initiator (relay) <---> target (relay) <---> original reader 17 | 18 | .SH OPTIONS 19 | \fB-h\fP 20 | Help 21 | List options 22 | 23 | \fB-q\fP 24 | Quiet mode 25 | Suppress printing of relayed data (improves timing) 26 | 27 | \fB-t\fP 28 | Target mode only (to be used on reader side) 29 | Commands are sent to file descriptor 4 30 | Responses are read from file descriptor 3 31 | 32 | \fB-i\fP 33 | Initiator mode only (to be used on tag side) 34 | Commands are read from file descriptor 3 35 | Responses are sent to file descriptor 4 36 | 37 | \fB-n\fP \fIN\fP 38 | Adds a waiting time of \fIN\fP seconds (integer) in the loop 39 | 40 | .SH EXAMPLES 41 | Basic usage: 42 | 43 | \fBnfc-relay-picc\fP 44 | 45 | Remote relay over TCP/IP: 46 | 47 | \fBsocat\fP 48 | TCP-LISTEN:port,reuseaddr 49 | "EXEC:\fBnfc-relay-picc \-i\fP,fdin=3,fdout=4" 50 | \fBsocat\fP 51 | TCP:remotehost:port 52 | "EXEC:\fBnfc-relay-picc \-t\fP,fdin=3,fdout=4" 53 | 54 | .SH NOTES 55 | There are some differences with \fBnfc-relay\fP: 56 | 57 | This example only works with PN532 because it relies on 58 | its internal handling of ISO14443-4 specificities. 59 | 60 | Thanks to this internal handling & injection of WTX frames, 61 | this example works on readers very strict on timing. 62 | 63 | .SH BUGS 64 | Please report any bugs on the 65 | .B libnfc 66 | issue tracker at: 67 | .br 68 | .BR http://code.google.com/p/libnfc/issues 69 | .SH LICENCE 70 | .B libnfc 71 | is licensed under the GNU Lesser General Public License (LGPL), version 3. 72 | .br 73 | .B libnfc-utils 74 | and 75 | .B libnfc-examples 76 | are covered by the the BSD 2-Clause license. 77 | .PP 78 | This manual page is licensed under the terms of the GNU GPL (version 2 or later). 79 | -------------------------------------------------------------------------------- /libnfc-1.7.1/libnfc/target-subr.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Free/Libre Near Field Communication (NFC) library 3 | * 4 | * Libnfc historical contributors: 5 | * Copyright (C) 2009 Roel Verdult 6 | * Copyright (C) 2009-2013 Romuald Conty 7 | * Copyright (C) 2010-2012 Romain Tartière 8 | * Copyright (C) 2010-2013 Philippe Teuwen 9 | * Copyright (C) 2012-2013 Ludovic Rousseau 10 | * See AUTHORS file for a more comprehensive list of contributors. 11 | * Additional contributors of this file: 12 | * 13 | * This program is free software: you can redistribute it and/or modify it 14 | * under the terms of the GNU Lesser General Public License as published by the 15 | * Free Software Foundation, either version 3 of the License, or (at your 16 | * option) any later version. 17 | * 18 | * This program is distributed in the hope that it will be useful, but WITHOUT 19 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 21 | * more details. 22 | * 23 | * You should have received a copy of the GNU Lesser General Public License 24 | * along with this program. If not, see 25 | */ 26 | 27 | /** 28 | * @file target-subr.c 29 | * @brief Target-related subroutines. (ie. determine target type, print target, etc.) 30 | */ 31 | 32 | #ifndef _TARGET_SUBR_H_ 33 | #define _TARGET_SUBR_H_ 34 | 35 | int snprint_hex(char *dst, size_t size, const uint8_t *pbtData, const size_t szLen); 36 | void snprint_nfc_iso14443a_info(char *dst, size_t size, const nfc_iso14443a_info *pnai, bool verbose); 37 | void snprint_nfc_iso14443b_info(char *dst, size_t size, const nfc_iso14443b_info *pnbi, bool verbose); 38 | void snprint_nfc_iso14443bi_info(char *dst, size_t size, const nfc_iso14443bi_info *pnii, bool verbose); 39 | void snprint_nfc_iso14443b2sr_info(char *dst, size_t size, const nfc_iso14443b2sr_info *pnsi, bool verbose); 40 | void snprint_nfc_iso14443b2ct_info(char *dst, size_t size, const nfc_iso14443b2ct_info *pnci, bool verbose); 41 | void snprint_nfc_felica_info(char *dst, size_t size, const nfc_felica_info *pnfi, bool verbose); 42 | void snprint_nfc_jewel_info(char *dst, size_t size, const nfc_jewel_info *pnji, bool verbose); 43 | void snprint_nfc_dep_info(char *dst, size_t size, const nfc_dep_info *pndi, bool verbose); 44 | void snprint_nfc_target(char *dst, size_t size, const nfc_target *pnt, bool verbose); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /libnfc-1.7.1/examples/pn53x-tamashell-scripts/UltraLightReadWrite.cmd: -------------------------------------------------------------------------------- 1 | 02; Get firmware version 2 | 3 | // Create NFC-Forum tag type2 with URL 4 | // WARNING It burns the OTP bits of sector 3!! 5 | // PLEASE PUT ULTRALIGHT TAG NOW 6 | 4A 01 00; 1 target requested 7 | 8 | // Clear memory from address 0x04 9 | 40 01 A2 04 00 00 00 00; Write 4 bytes from address 0x04 10 | 40 01 A2 05 00 00 00 00; Write 4 bytes from address 0x05 11 | 40 01 A2 06 00 00 00 00; Write 4 bytes from address 0x06 12 | 40 01 A2 07 00 00 00 00; Write 4 bytes from address 0x07 13 | 40 01 A2 08 00 00 00 00; Write 4 bytes from address 0x08 14 | 40 01 A2 09 00 00 00 00; Write 4 bytes from address 0x09 15 | 40 01 A2 0A 00 00 00 00; Write 4 bytes from address 0x0A 16 | 40 01 A2 0B 00 00 00 00; Write 4 bytes from address 0x0B 17 | 40 01 A2 0C 00 00 00 00; Write 4 bytes from address 0x0C 18 | 19 | // Read memory content from address 4 20 | 40 01 30 04; Read 16 bytes from address 0x04 21 | 40 01 30 08; Read 16 bytes from address 0x08 22 | 40 01 30 0C; Read 16 bytes from address 0x0C 23 | 24 | // cf NFC-Forum Type 1 Tag Operation Specification TS 25 | // Write @ address 0x03 (OTP): NDEF, v1.0, 48 bytes, RW 26 | 40 01 A2 03 E1 10 06 00; 27 | // Write @ address 0x04: NDEF TLV, 15 bytes,... 28 | // cf NFC-Forum NFC Data Exchange Format (NDEF) TS 29 | // ...,MB,ME,SR,TNF=1 (wkt), typeL=1 byte 30 | 40 01 A2 04 03 0F D1 01; 31 | // Write @ address 0x05: payloadL=11 bytes,... 32 | // cf NFC-Forum NFC Record Type Definition (RTD) TS 33 | // ...,type=urn:nfc:wkt:U = URI 34 | // cf NFC-Forum URI Record Type Definition TS 35 | // ...,01=>URI id code=http://www. 36 | // ...,"l" 37 | 40 01 A2 05 0B 55 01 6C; 38 | // Write @ address 0x06: "ibnf" 39 | 40 01 A2 06 69 62 6E 66; 40 | // Write @ address 0x07: "c.or" 41 | 40 01 A2 07 63 2E 6F 72; 42 | // Write @ address 0x08: "g",TLV:FE 43 | 40 01 A2 08 67 FE 00 00; 44 | 45 | // Read memory content from address 4 46 | 40 01 30 04; Read 16 bytes from address 0x04 47 | 40 01 30 08; Read 16 bytes from address 0x08 48 | 40 01 30 0C; Read 16 bytes from address 0x0C 49 | 50 | -------------------------------------------------------------------------------- /libnfc-1.7.1/libnfc/nfc-device.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Free/Libre Near Field Communication (NFC) library 3 | * 4 | * Libnfc historical contributors: 5 | * Copyright (C) 2009 Roel Verdult 6 | * Copyright (C) 2009-2013 Romuald Conty 7 | * Copyright (C) 2010-2012 Romain Tartière 8 | * Copyright (C) 2010-2013 Philippe Teuwen 9 | * Copyright (C) 2012-2013 Ludovic Rousseau 10 | * See AUTHORS file for a more comprehensive list of contributors. 11 | * Additional contributors of this file: 12 | * 13 | * This program is free software: you can redistribute it and/or modify it 14 | * under the terms of the GNU Lesser General Public License as published by the 15 | * Free Software Foundation, either version 3 of the License, or (at your 16 | * option) any later version. 17 | * 18 | * This program is distributed in the hope that it will be useful, but WITHOUT 19 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 21 | * more details. 22 | * 23 | * You should have received a copy of the GNU Lesser General Public License 24 | * along with this program. If not, see 25 | */ 26 | 27 | /** 28 | * @file nfc-device.c 29 | * @brief Provide internal function to manipulate nfc_device type 30 | */ 31 | 32 | #include 33 | #include 34 | 35 | #ifdef HAVE_CONFIG_H 36 | # include "config.h" 37 | #endif // HAVE_CONFIG_H 38 | 39 | #include "nfc-internal.h" 40 | 41 | nfc_device * 42 | nfc_device_new(const nfc_context *context, const nfc_connstring connstring) 43 | { 44 | nfc_device *res = malloc(sizeof(*res)); 45 | 46 | if (!res) { 47 | return NULL; 48 | } 49 | 50 | // Store associated context 51 | res->context = context; 52 | 53 | // Variables initiatialization 54 | // Note: Actually, these initialization will be overwritten while the device 55 | // will be setup. Putting them to _false_ while the default is _true_ ensure we 56 | // send the command to the chip 57 | res->bCrc = false; 58 | res->bPar = false; 59 | res->bEasyFraming = false; 60 | res->bInfiniteSelect = false; 61 | res->bAutoIso14443_4 = false; 62 | res->last_error = 0; 63 | memcpy(res->connstring, connstring, sizeof(res->connstring)); 64 | res->driver_data = NULL; 65 | res->chip_data = NULL; 66 | 67 | return res; 68 | } 69 | 70 | void 71 | nfc_device_free(nfc_device *dev) 72 | { 73 | if (dev) { 74 | free(dev->driver_data); 75 | free(dev); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /libnfc-1.7.1/m4/libnfc_check_libusb.m4: -------------------------------------------------------------------------------- 1 | dnl Check for LIBUSB 2 | dnl On success, HAVE_LIBUSB is set to 1 and PKG_CONFIG_REQUIRES is filled when 3 | dnl libusb is found using pkg-config 4 | 5 | AC_DEFUN([LIBNFC_CHECK_LIBUSB], 6 | [ 7 | if test x"$libusb_required" = "xyes"; then 8 | HAVE_LIBUSB=0 9 | 10 | AC_ARG_WITH([libusb-win32], 11 | [AS_HELP_STRING([--with-libusb-win32], [use libusb-win32 from the following location])], 12 | [LIBUSB_WIN32_DIR=$withval], 13 | [LIBUSB_WIN32_DIR=""]) 14 | 15 | # --with-libusb-win32 directory have been set 16 | if test "x$LIBUSB_WIN32_DIR" != "x"; then 17 | AC_MSG_NOTICE(["use libusb-win32 from $LIBUSB_WIN32_DIR"]) 18 | libusb_CFLAGS="-I$LIBUSB_WIN32_DIR/include" 19 | libusb_LIBS="-L$LIBUSB_WIN32_DIR/lib/gcc -lusb" 20 | HAVE_LIBUSB=1 21 | fi 22 | 23 | # Search using libusb module using pkg-config 24 | if test x"$HAVE_LIBUSB" = "x0"; then 25 | if test x"$PKG_CONFIG" != "x"; then 26 | PKG_CHECK_MODULES([libusb], [libusb], [HAVE_LIBUSB=1], [HAVE_LIBUSB=0]) 27 | if test x"$HAVE_LIBUSB" = "x1"; then 28 | if test x"$PKG_CONFIG_REQUIRES" != x""; then 29 | PKG_CONFIG_REQUIRES="$PKG_CONFIG_REQUIRES," 30 | fi 31 | PKG_CONFIG_REQUIRES="$PKG_CONFIG_REQUIRES libusb" 32 | fi 33 | fi 34 | fi 35 | 36 | # Search using libusb-legacy module using pkg-config 37 | if test x"$HAVE_LIBUSB" = "x0"; then 38 | if test x"$PKG_CONFIG" != "x"; then 39 | PKG_CHECK_MODULES([libusb], [libusb-legacy], [HAVE_LIBUSB=1], [HAVE_LIBUSB=0]) 40 | if test x"$HAVE_LIBUSB" = "x1"; then 41 | if test x"$PKG_CONFIG_REQUIRES" != x""; then 42 | PKG_CONFIG_REQUIRES="$PKG_CONFIG_REQUIRES," 43 | fi 44 | PKG_CONFIG_REQUIRES="$PKG_CONFIG_REQUIRES libusb" 45 | fi 46 | fi 47 | fi 48 | 49 | # Search using libusb-config 50 | if test x"$HAVE_LIBUSB" = "x0"; then 51 | AC_PATH_PROG(libusb_CONFIG,libusb-config) 52 | if test x"$libusb_CONFIG" != "x" ; then 53 | libusb_CFLAGS=`$libusb_CONFIG --cflags` 54 | libusb_LIBS=`$libusb_CONFIG --libs` 55 | HAVE_LIBUSB=1 56 | fi 57 | fi 58 | 59 | # Search the library and headers directly (last chance) 60 | if test x"$HAVE_LIBUSB" = "x0"; then 61 | AC_CHECK_HEADER(usb.h, [], [AC_MSG_ERROR([The libusb headers are missing])]) 62 | AC_CHECK_LIB(usb, libusb_init, [], [AC_MSG_ERROR([The libusb library is missing])]) 63 | 64 | libusb_LIBS="-lusb" 65 | HAVE_LIBUSB=1 66 | fi 67 | 68 | if test x"$HAVE_LIBUSB" = "x0"; then 69 | AC_MSG_ERROR([libusb is mandatory.]) 70 | fi 71 | 72 | AC_SUBST(libusb_LIBS) 73 | AC_SUBST(libusb_CFLAGS) 74 | fi 75 | ]) 76 | -------------------------------------------------------------------------------- /libnfc-1.7.1/README-Windows.txt: -------------------------------------------------------------------------------- 1 | *- 2 | * Free/Libre Near Field Communication (NFC) library 3 | * 4 | * Libnfc historical contributors: 5 | * Copyright (C) 2009 Roel Verdult 6 | * Copyright (C) 2009-2013 Romuald Conty 7 | * Copyright (C) 2010-2012 Romain Tartière 8 | * Copyright (C) 2010-2013 Philippe Teuwen 9 | * Copyright (C) 2012-2013 Ludovic Rousseau 10 | * Additional contributors of Windows-specific parts: 11 | * Copyright (C) 2010 Glenn Ergeerts 12 | * Copyright (C) 2013 Alex Lian 13 | -* 14 | 15 | Requirements 16 | ============ 17 | 18 | - MinGW-w64 compiler toolchain [1] 19 | - LibUsb-Win32 1.2.5.0 (or greater) [2] 20 | - CMake 2.8 [3] 21 | - PCRE for Windows [4] 22 | 23 | This was tested on Windows 7 64 bit, but should work on Windows Vista and 24 | Windows XP and 32 bit as well. 25 | Only the ACS ACR122 and the ASK Logo readers are tested at the moment, so any feedback about other devices is very welcome. 26 | 27 | Community forum: http://www.libnfc.org/community/ 28 | 29 | Building 30 | ======== 31 | 32 | To build the distribution the MinGW Makefiles generator of CMake was used. Here 33 | is an example of how to generate a distribution with the above mentioned 34 | requirements fulfilled (it is assumed the CMake binaries are in the system 35 | path, this is optional during installation of CMake): 36 | 37 | - Add the following directories to your PATH : c:\MinGW64\bin;c:\MinGW64\x86_64-w64-mingw32\lib32;c:\MinGW64\x86_64-w64-mingw32\include 38 | 39 | - Now it is possible to run CMake and mingw32-make: 40 | 41 | C:\dev\libnfc-read-only> mkdir ..\libnfc-build 42 | C:\dev\libnfc-read-only> cd ..\libnfc-build 43 | C:\dev\libnfc-build> cmake-gui . 44 | 45 | Now you can configure the build. Press "Configure", specify "MinGW32 Makefiles" 46 | and then you have the opportunity to set some configuration variables. If you 47 | don't want a Debug build change the variable CMAKE_BUILD_TYPE to "Release". 48 | 49 | If a non-GUI solution is preferred one can use: 50 | 51 | C:\dev\libnfc-build> cmake -G "MinGW Makefiles" 52 | -DCMAKE_BUILD_TYPE=Release ..\libnfc-read-only 53 | 54 | Now run mingw32-make to build: 55 | 56 | C:\dev\libnfc-read-only\bin> mingw32-make 57 | 58 | The build will create a shared library for Windows (nfc.dll) to link your applications against. It will compile 59 | the tools against this shared library. 60 | 61 | References 62 | ========== 63 | [1] the easiest way is to use the TDM-GCC installer. 64 | Make sure to select MinGW-w64 in the installer, the regular MinGW does not contain headers for PCSC. 65 | http://sourceforge.net/projects/tdm-gcc/files/TDM-GCC%20Installer/tdm64-gcc-4.5.1.exe/download 66 | [2] http://sourceforge.net/projects/libusb-win32/files/ 67 | [3] http://www.cmake.org 68 | [4] http://gnuwin32.sourceforge.net/packages/pcre.htm -------------------------------------------------------------------------------- /libnfc-1.7.1/examples/doc/quick_start_example1.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file quick_start_example1.c 3 | * @brief Quick start example that presents how to use libnfc 4 | */ 5 | 6 | // To compile this simple example: 7 | // $ gcc -o quick_start_example1 quick_start_example1.c -lnfc 8 | 9 | #include 10 | #include 11 | 12 | static void 13 | print_hex(const uint8_t *pbtData, const size_t szBytes) 14 | { 15 | size_t szPos; 16 | 17 | for (szPos = 0; szPos < szBytes; szPos++) { 18 | printf("%02x ", pbtData[szPos]); 19 | } 20 | printf("\n"); 21 | } 22 | 23 | int 24 | main(int argc, const char *argv[]) 25 | { 26 | nfc_device *pnd; 27 | nfc_target nt; 28 | 29 | // Allocate only a pointer to nfc_context 30 | nfc_context *context; 31 | 32 | // Initialize libnfc and set the nfc_context 33 | nfc_init(&context); 34 | if (context == NULL) { 35 | printf("Unable to init libnfc (malloc)\n"); 36 | exit(EXIT_FAILURE); 37 | } 38 | 39 | // Display libnfc version 40 | const char *acLibnfcVersion = nfc_version(); 41 | (void)argc; 42 | printf("%s uses libnfc %s\n", argv[0], acLibnfcVersion); 43 | 44 | // Open, using the first available NFC device which can be in order of selection: 45 | // - default device specified using environment variable or 46 | // - first specified device in libnfc.conf (/etc/nfc) or 47 | // - first specified device in device-configuration directory (/etc/nfc/devices.d) or 48 | // - first auto-detected (if feature is not disabled in libnfc.conf) device 49 | pnd = nfc_open(context, NULL); 50 | 51 | if (pnd == NULL) { 52 | printf("ERROR: %s\n", "Unable to open NFC device."); 53 | exit(EXIT_FAILURE); 54 | } 55 | // Set opened NFC device to initiator mode 56 | if (nfc_initiator_init(pnd) < 0) { 57 | nfc_perror(pnd, "nfc_initiator_init"); 58 | exit(EXIT_FAILURE); 59 | } 60 | 61 | printf("NFC reader: %s opened\n", nfc_device_get_name(pnd)); 62 | 63 | // Poll for a ISO14443A (MIFARE) tag 64 | const nfc_modulation nmMifare = { 65 | .nmt = NMT_ISO14443A, 66 | .nbr = NBR_106, 67 | }; 68 | if (nfc_initiator_select_passive_target(pnd, nmMifare, NULL, 0, &nt) > 0) { 69 | printf("The following (NFC) ISO14443A tag was found:\n"); 70 | printf(" ATQA (SENS_RES): "); 71 | print_hex(nt.nti.nai.abtAtqa, 2); 72 | printf(" UID (NFCID%c): ", (nt.nti.nai.abtUid[0] == 0x08 ? '3' : '1')); 73 | print_hex(nt.nti.nai.abtUid, nt.nti.nai.szUidLen); 74 | printf(" SAK (SEL_RES): "); 75 | print_hex(&nt.nti.nai.btSak, 1); 76 | if (nt.nti.nai.szAtsLen) { 77 | printf(" ATS (ATR): "); 78 | print_hex(nt.nti.nai.abtAts, nt.nti.nai.szAtsLen); 79 | } 80 | } 81 | // Close NFC device 82 | nfc_close(pnd); 83 | // Release the context 84 | nfc_exit(context); 85 | exit(EXIT_SUCCESS); 86 | } 87 | -------------------------------------------------------------------------------- /libnfc-1.7.1/libnfc/nfc-emulation.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Free/Libre Near Field Communication (NFC) library 3 | * 4 | * Libnfc historical contributors: 5 | * Copyright (C) 2009 Roel Verdult 6 | * Copyright (C) 2009-2013 Romuald Conty 7 | * Copyright (C) 2010-2012 Romain Tartière 8 | * Copyright (C) 2010-2013 Philippe Teuwen 9 | * Copyright (C) 2012-2013 Ludovic Rousseau 10 | * See AUTHORS file for a more comprehensive list of contributors. 11 | * Additional contributors of this file: 12 | * 13 | * This program is free software: you can redistribute it and/or modify it 14 | * under the terms of the GNU Lesser General Public License as published by the 15 | * Free Software Foundation, either version 3 of the License, or (at your 16 | * option) any later version. 17 | * 18 | * This program is distributed in the hope that it will be useful, but WITHOUT 19 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 21 | * more details. 22 | * 23 | * You should have received a copy of the GNU Lesser General Public License 24 | * along with this program. If not, see 25 | */ 26 | 27 | /** 28 | * @file nfc-emulation.c 29 | * @brief Provide a small API to ease emulation in libnfc 30 | */ 31 | 32 | #include 33 | #include 34 | 35 | #include "iso7816.h" 36 | 37 | /** @ingroup emulation 38 | * @brief Emulate a target 39 | * @return Returns 0 on success, otherwise returns libnfc's error code (negative value). 40 | * 41 | * @param pnd \a nfc_device struct pointer that represents currently used device 42 | * @param emulator \nfc_emulator struct point that handles input/output functions 43 | * 44 | * If timeout equals to 0, the function blocks indefinitely (until an error is raised or function is completed) 45 | * If timeout equals to -1, the default timeout will be used 46 | */ 47 | int 48 | nfc_emulate_target(nfc_device *pnd, struct nfc_emulator *emulator, const int timeout) 49 | { 50 | uint8_t abtRx[ISO7816_SHORT_R_APDU_MAX_LEN]; 51 | uint8_t abtTx[ISO7816_SHORT_C_APDU_MAX_LEN]; 52 | 53 | int res; 54 | if ((res = nfc_target_init(pnd, emulator->target, abtRx, sizeof(abtRx), timeout)) < 0) { 55 | return res; 56 | } 57 | 58 | size_t szRx = res; 59 | int io_res = res; 60 | while (io_res >= 0) { 61 | io_res = emulator->state_machine->io(emulator, abtRx, szRx, abtTx, sizeof(abtTx)); 62 | if (io_res > 0) { 63 | if ((res = nfc_target_send_bytes(pnd, abtTx, io_res, timeout)) < 0) { 64 | return res; 65 | } 66 | } 67 | if (io_res >= 0) { 68 | if ((res = nfc_target_receive_bytes(pnd, abtRx, sizeof(abtRx), timeout)) < 0) { 69 | return res; 70 | } 71 | szRx = res; 72 | } 73 | } 74 | return io_res; 75 | } 76 | 77 | -------------------------------------------------------------------------------- /libnfc-1.7.1/cmake/modules/LibnfcDrivers.cmake: -------------------------------------------------------------------------------- 1 | SET(LIBNFC_DRIVER_ACR122_PCSC OFF CACHE BOOL "Enable ACR122 support (Depends on PC/SC)") 2 | SET(LIBNFC_DRIVER_ACR122_USB ON CACHE BOOL "Enable ACR122 support (Direct USB connection)") 3 | SET(LIBNFC_DRIVER_ACR122S ON CACHE BOOL "Enable ACR122S support (Use serial port)") 4 | SET(LIBNFC_DRIVER_ARYGON ON CACHE BOOL "Enable ARYGON support (Use serial port)") 5 | IF(WIN32) 6 | SET(LIBNFC_DRIVER_PN532_I2C OFF CACHE BOOL "Enable PN532 I2C support (Use I2C bus)") 7 | SET(LIBNFC_DRIVER_PN532_SPI OFF CACHE BOOL "Enable PN532 SPI support (Use SPI bus)") 8 | ELSE(WIN32) 9 | SET(LIBNFC_DRIVER_PN532_I2C ON CACHE BOOL "Enable PN532 I2C support (Use I2C bus)") 10 | SET(LIBNFC_DRIVER_PN532_SPI ON CACHE BOOL "Enable PN532 SPI support (Use SPI bus)") 11 | ENDIF(WIN32) 12 | SET(LIBNFC_DRIVER_PN532_UART ON CACHE BOOL "Enable PN532 UART support (Use serial port)") 13 | SET(LIBNFC_DRIVER_PN53X_USB ON CACHE BOOL "Enable PN531 and PN531 USB support (Depends on libusb)") 14 | 15 | IF(LIBNFC_DRIVER_ACR122_PCSC) 16 | FIND_PACKAGE(PCSC REQUIRED) 17 | ADD_DEFINITIONS("-DDRIVER_ACR122_PCSC_ENABLED") 18 | SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/acr122_pcsc") 19 | ENDIF(LIBNFC_DRIVER_ACR122_PCSC) 20 | 21 | IF(LIBNFC_DRIVER_ACR122_USB) 22 | FIND_PACKAGE(LIBUSB REQUIRED) 23 | ADD_DEFINITIONS("-DDRIVER_ACR122_USB_ENABLED") 24 | SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/acr122_usb") 25 | ENDIF(LIBNFC_DRIVER_ACR122_USB) 26 | 27 | IF(LIBNFC_DRIVER_ACR122S) 28 | ADD_DEFINITIONS("-DDRIVER_ACR122S_ENABLED") 29 | SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/acr122s") 30 | SET(UART_REQUIRED TRUE) 31 | ENDIF(LIBNFC_DRIVER_ACR122S) 32 | 33 | IF(LIBNFC_DRIVER_ARYGON) 34 | ADD_DEFINITIONS("-DDRIVER_ARYGON_ENABLED") 35 | SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/arygon") 36 | SET(UART_REQUIRED TRUE) 37 | ENDIF(LIBNFC_DRIVER_ARYGON) 38 | 39 | IF(LIBNFC_DRIVER_PN532_I2C) 40 | ADD_DEFINITIONS("-DDRIVER_PN532_I2C_ENABLED") 41 | SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/pn532_i2c") 42 | SET(I2C_REQUIRED TRUE) 43 | ENDIF(LIBNFC_DRIVER_PN532_I2C) 44 | 45 | IF(LIBNFC_DRIVER_PN532_SPI) 46 | ADD_DEFINITIONS("-DDRIVER_PN532_SPI_ENABLED") 47 | SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/pn532_spi") 48 | SET(SPI_REQUIRED TRUE) 49 | ENDIF(LIBNFC_DRIVER_PN532_SPI) 50 | 51 | IF(LIBNFC_DRIVER_PN532_UART) 52 | ADD_DEFINITIONS("-DDRIVER_PN532_UART_ENABLED") 53 | SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/pn532_uart") 54 | SET(UART_REQUIRED TRUE) 55 | ENDIF(LIBNFC_DRIVER_PN532_UART) 56 | 57 | IF(LIBNFC_DRIVER_PN53X_USB) 58 | FIND_PACKAGE(LIBUSB REQUIRED) 59 | ADD_DEFINITIONS("-DDRIVER_PN53X_USB_ENABLED") 60 | SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/pn53x_usb") 61 | SET(USB_REQUIRED TRUE) 62 | ENDIF(LIBNFC_DRIVER_PN53X_USB) 63 | 64 | INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/drivers) 65 | -------------------------------------------------------------------------------- /libnfc-1.7.1/utils/crypto1.c: -------------------------------------------------------------------------------- 1 | /* crypto1.c 2 | 3 | This program is free software; you can redistribute it and/or 4 | modify it under the terms of the GNU General Public License 5 | as published by the Free Software Foundation; either version 2 6 | of the License, or (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 16 | MA 02110-1301, US 17 | 18 | Copyright (C) 2008-2008 bla 19 | */ 20 | #include "crapto1.h" 21 | #include 22 | 23 | #define SWAPENDIAN(x)\ 24 | (x = (x >> 8 & 0xff00ff) | (x & 0xff00ff) << 8, x = x >> 16 | x << 16) 25 | 26 | struct Crypto1State * crypto1_create(uint64_t key) 27 | { 28 | struct Crypto1State *s = malloc(sizeof(*s)); 29 | int i; 30 | 31 | for(i = 47;s && i > 0; i -= 2) { 32 | s->odd = s->odd << 1 | BIT(key, (i - 1) ^ 7); 33 | s->even = s->even << 1 | BIT(key, i ^ 7); 34 | } 35 | return s; 36 | } 37 | void crypto1_destroy(struct Crypto1State *state) 38 | { 39 | free(state); 40 | } 41 | void crypto1_get_lfsr(struct Crypto1State *state, uint64_t *lfsr) 42 | { 43 | int i; 44 | for(*lfsr = 0, i = 23; i >= 0; --i) { 45 | *lfsr = *lfsr << 1 | BIT(state->odd, i ^ 3); 46 | *lfsr = *lfsr << 1 | BIT(state->even, i ^ 3); 47 | } 48 | } 49 | uint8_t crypto1_bit(struct Crypto1State *s, uint8_t in, int is_encrypted) 50 | { 51 | uint32_t feedin; 52 | uint8_t ret = filter(s->odd); 53 | 54 | feedin = ret & !!is_encrypted; 55 | feedin ^= !!in; 56 | feedin ^= LF_POLY_ODD & s->odd; 57 | feedin ^= LF_POLY_EVEN & s->even; 58 | s->even = s->even << 1 | parity(feedin); 59 | 60 | s->odd ^= (s->odd ^= s->even, s->even ^= s->odd); 61 | 62 | return ret; 63 | } 64 | uint8_t crypto1_byte(struct Crypto1State *s, uint8_t in, int is_encrypted) 65 | { 66 | uint8_t i, ret = 0; 67 | 68 | for (i = 0; i < 8; ++i) 69 | ret |= crypto1_bit(s, BIT(in, i), is_encrypted) << i; 70 | 71 | return ret; 72 | } 73 | uint32_t crypto1_word(struct Crypto1State *s, uint32_t in, int is_encrypted) 74 | { 75 | uint32_t i, ret = 0; 76 | 77 | for (i = 0; i < 32; ++i) 78 | ret |= crypto1_bit(s, BEBIT(in, i), is_encrypted) << (i ^ 24); 79 | 80 | return ret; 81 | } 82 | 83 | /* prng_successor 84 | * helper used to obscure the keystream during authentication 85 | */ 86 | uint32_t prng_successor(uint32_t x, uint32_t n) 87 | { 88 | SWAPENDIAN(x); 89 | while(n--) 90 | x = x >> 1 | (x >> 16 ^ x >> 18 ^ x >> 19 ^ x >> 21) << 31; 91 | 92 | return SWAPENDIAN(x); 93 | } 94 | -------------------------------------------------------------------------------- /libnfc-1.7.1/examples/doc/quick_start_example2.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file quick_start_example2.c 3 | * @brief Quick start example that presents how to use libnfc 4 | */ 5 | 6 | // This is same example as quick_start_example1.c but using 7 | // some helper functions existing in libnfc. 8 | // Those functions are not available yet in a library 9 | // so binary object must be linked statically: 10 | // $ gcc -o quick_start_example2 -lnfc -I../.. quick_start_example2.c ../../utils/nfc-utils.o 11 | 12 | #ifdef HAVE_CONFIG_H 13 | # include "config.h" 14 | #endif // HAVE_CONFIG_H 15 | 16 | #include 17 | #include 18 | #include "utils/nfc-utils.h" 19 | 20 | int 21 | main(int argc, const char *argv[]) 22 | { 23 | nfc_device *pnd; 24 | nfc_target nt; 25 | 26 | // Allocate only a pointer to nfc_context 27 | nfc_context *context; 28 | 29 | // Initialize libnfc and set the nfc_context 30 | nfc_init(&context); 31 | if (context == NULL) { 32 | ERR("Unable to init libnfc (malloc)"); 33 | exit(EXIT_FAILURE); 34 | } 35 | 36 | // Display libnfc version 37 | const char *acLibnfcVersion = nfc_version(); 38 | (void)argc; 39 | printf("%s uses libnfc %s\n", argv[0], acLibnfcVersion); 40 | 41 | // Open, using the first available NFC device which can be in order of selection: 42 | // - default device specified using environment variable or 43 | // - first specified device in libnfc.conf (/etc/nfc) or 44 | // - first specified device in device-configuration directory (/etc/nfc/devices.d) or 45 | // - first auto-detected (if feature is not disabled in libnfc.conf) device 46 | pnd = nfc_open(context, NULL); 47 | 48 | if (pnd == NULL) { 49 | ERR("%s", "Unable to open NFC device."); 50 | exit(EXIT_FAILURE); 51 | } 52 | // Set opened NFC device to initiator mode 53 | if (nfc_initiator_init(pnd) < 0) { 54 | nfc_perror(pnd, "nfc_initiator_init"); 55 | exit(EXIT_FAILURE); 56 | } 57 | 58 | printf("NFC reader: %s opened\n", nfc_device_get_name(pnd)); 59 | 60 | // Poll for a ISO14443A (MIFARE) tag 61 | const nfc_modulation nmMifare = { 62 | .nmt = NMT_ISO14443A, 63 | .nbr = NBR_106, 64 | }; 65 | if (nfc_initiator_select_passive_target(pnd, nmMifare, NULL, 0, &nt) > 0) { 66 | printf("The following (NFC) ISO14443A tag was found:\n"); 67 | printf(" ATQA (SENS_RES): "); 68 | print_hex(nt.nti.nai.abtAtqa, 2); 69 | printf(" UID (NFCID%c): ", (nt.nti.nai.abtUid[0] == 0x08 ? '3' : '1')); 70 | print_hex(nt.nti.nai.abtUid, nt.nti.nai.szUidLen); 71 | printf(" SAK (SEL_RES): "); 72 | print_hex(&nt.nti.nai.btSak, 1); 73 | if (nt.nti.nai.szAtsLen) { 74 | printf(" ATS (ATR): "); 75 | print_hex(nt.nti.nai.abtAts, nt.nti.nai.szAtsLen); 76 | } 77 | } 78 | // Close NFC device 79 | nfc_close(pnd); 80 | // Release the context 81 | nfc_exit(context); 82 | exit(EXIT_SUCCESS); 83 | } 84 | -------------------------------------------------------------------------------- /libnfc-1.7.1/libnfc/buses/usbbus.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Free/Libre Near Field Communication (NFC) library 3 | * 4 | * Libnfc historical contributors: 5 | * Copyright (C) 2009 Roel Verdult 6 | * Copyright (C) 2009-2013 Romuald Conty 7 | * Copyright (C) 2010-2012 Romain Tartière 8 | * Copyright (C) 2010-2013 Philippe Teuwen 9 | * Copyright (C) 2012-2013 Ludovic Rousseau 10 | * See AUTHORS file for a more comprehensive list of contributors. 11 | * Additional contributors of this file: 12 | * 13 | * This program is free software: you can redistribute it and/or modify it 14 | * under the terms of the GNU Lesser General Public License as published by the 15 | * Free Software Foundation, either version 3 of the License, or (at your 16 | * option) any later version. 17 | * 18 | * This program is distributed in the hope that it will be useful, but WITHOUT 19 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 21 | * more details. 22 | * 23 | * You should have received a copy of the GNU Lesser General Public License 24 | * along with this program. If not, see 25 | * 26 | */ 27 | 28 | /** 29 | * @file usbbus.c 30 | * @brief libusb 0.1 driver wrapper 31 | */ 32 | 33 | #ifdef HAVE_CONFIG_H 34 | # include "config.h" 35 | #endif // HAVE_CONFIG_H 36 | 37 | #include 38 | 39 | #include "usbbus.h" 40 | #include "log.h" 41 | #define LOG_CATEGORY "libnfc.buses.usbbus" 42 | #define LOG_GROUP NFC_LOG_GROUP_DRIVER 43 | 44 | int usb_prepare(void) 45 | { 46 | static bool usb_initialized = false; 47 | if (!usb_initialized) { 48 | 49 | #ifdef ENVVARS 50 | char *env_log_level = getenv("LIBNFC_LOG_LEVEL"); 51 | // Set libusb debug only if asked explicitely: 52 | // LIBUSB_LOG_LEVEL=12288 (= NFC_LOG_PRIORITY_DEBUG * 2 ^ NFC_LOG_GROUP_LIBUSB) 53 | if (env_log_level && (((atoi(env_log_level) >> (NFC_LOG_GROUP_LIBUSB * 2)) & 0x00000003) >= NFC_LOG_PRIORITY_DEBUG)) { 54 | setenv("USB_DEBUG", "255", 1); 55 | } 56 | #endif 57 | 58 | usb_init(); 59 | usb_initialized = true; 60 | } 61 | 62 | int res; 63 | // usb_find_busses will find all of the busses on the system. Returns the 64 | // number of changes since previous call to this function (total of new 65 | // busses and busses removed). 66 | if ((res = usb_find_busses()) < 0) { 67 | log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to find USB busses (%s)", _usb_strerror(res)); 68 | return -1; 69 | } 70 | // usb_find_devices will find all of the devices on each bus. This should be 71 | // called after usb_find_busses. Returns the number of changes since the 72 | // previous call to this function (total of new device and devices removed). 73 | if ((res = usb_find_devices()) < 0) { 74 | log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to find USB devices (%s)", _usb_strerror(res)); 75 | return -1; 76 | } 77 | return 0; 78 | } 79 | 80 | -------------------------------------------------------------------------------- /libnfc-1.7.1/examples/nfc-emulate-uid.1: -------------------------------------------------------------------------------- 1 | .TH nfc-emulate-uid 1 "June 26, 2009" "libnfc" "libnfc's examples" 2 | .SH NAME 3 | nfc-emulate-uid \- NFC target emulation command line tool based on libnfc 4 | .SH SYNOPSIS 5 | .B nfc-emulate-uid 6 | .RI [ OPTIONS ] 7 | .RI [ UID ] 8 | .SH DESCRIPTION 9 | .B nfc-emulate-uid 10 | is a tag emulation tool that allows one to choose any tag UID. Tag emulation is one 11 | of the main added features in NFC. But to avoid abuse of existing systems, 12 | manufacturers of the NFC controller intentionally did not support emulation of 13 | fully customized UID but only of "random" UIDs, which always start with 0x08. 14 | The nfc-emulate-uid tool demonstrates that this can still be done using 15 | transmission of raw frames, and the desired UID can be optionally specified. 16 | 17 | This makes it a serious thread for security systems that rely only on the 18 | uniqueness of the UID. 19 | 20 | Unfortunately, this example can't directly start in fully customisable 21 | target mode. Just after launching this example, you will have to go through 22 | the hardcoded initial anti-collision with the 0x08-prefixed UID. 23 | To achieve it, you can e.g. send a RATS (Request for Answer To Select) command 24 | by using a second NFC device (placed in target's field) and launching nfc-list 25 | or nfc-anticol. After this first step, you now have a NFC device (configured 26 | as target) that really emulates a custom UID. 27 | You could view it using the second NFC device with nfc-list. 28 | 29 | Timing control is very important for a successful anti-collision sequence: 30 | 31 | - The emulator must be very fast to react: 32 | Using the ACR122 device gives many timing issues, "PN53x only" USB 33 | devices also give some timing issues but an embedded microprocessor 34 | would probably improve greatly the situation. 35 | 36 | - The reader should not be too strict on timing (the standard is very 37 | strict). The OmniKey CardMan 5321 is known to be very large on 38 | timings and is a good choice if you want to experiment with this 39 | emulator with a tolerant reader. 40 | Nokia NFC 6212 and Pegoda readers are much too strict and won't be fooled. 41 | 42 | .SH OPTIONS 43 | .IR UID 44 | 8 hex digits format that represents desired UID (default is DEADBEEF). 45 | 46 | .SH IMPORTANT 47 | ACR122 devices (like touchatag, etc.) can be used by this example (with timing 48 | issues), but if something goes wrong, you will have to unplug/replug your 49 | device. This is not a 50 | .B libnfc's 51 | bug, this problem is due to ACR122's internal MCU in front of NFC chip (PN532). 52 | .SH BUGS 53 | Please report any bugs on the 54 | .B libnfc 55 | issue tracker at: 56 | .br 57 | .BR http://code.google.com/p/libnfc/issues 58 | .SH LICENCE 59 | .B libnfc 60 | is licensed under the GNU Lesser General Public License (LGPL), version 3. 61 | .br 62 | .B libnfc-utils 63 | and 64 | .B libnfc-examples 65 | are covered by the the BSD 2-Clause license. 66 | .SH AUTHORS 67 | Roel Verdult 68 | .PP 69 | This manual page was written by Romuald Conty . 70 | It is licensed under the terms of the GNU GPL (version 2 or later). 71 | -------------------------------------------------------------------------------- /libnfc-1.7.1/mingw-cross-configure.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | WITH_USB=1 4 | 5 | LIBUSB_WIN32_BIN_VERSION="1.2.6.0" 6 | LIBUSB_WIN32_BIN_ARCHIVE="libusb-win32-bin-$LIBUSB_WIN32_BIN_VERSION.zip" 7 | LIBUSB_WIN32_BIN_URL="http://freefr.dl.sourceforge.net/project/libusb-win32/libusb-win32-releases/$LIBUSB_WIN32_BIN_VERSION/$LIBUSB_WIN32_BIN_ARCHIVE" 8 | LIBUSB_WIN32_BIN_DIR="libusb-win32-bin-$LIBUSB_WIN32_BIN_VERSION" 9 | 10 | if [ "$WITH_USB" = "1" ]; then 11 | if [ ! -d $LIBUSB_WIN32_BIN_DIR ]; then 12 | wget -c $LIBUSB_WIN32_BIN_URL 13 | unzip $LIBUSB_WIN32_BIN_ARCHIVE 14 | fi 15 | fi 16 | 17 | MINGW="${MINGW:=i686-w64-mingw32}" 18 | MINGW_DIR="/usr/$MINGW" 19 | 20 | # Use MinGW binaries before others 21 | #export PATH=$MINGW_DIR/bin:$PATH 22 | 23 | # Set CPATH to MinGW include files 24 | export CPATH=$MINGW_DIR/include 25 | export LD_LIBRARY_PATH=$MINGW_DIR/lib 26 | export LD_RUN_PATH=$MINGW_DIR/lib 27 | 28 | # Force pkg-config to search in cross environement directory 29 | export PKG_CONFIG_LIBDIR=$MINGW_DIR/lib/pkgconfig 30 | 31 | # Stop compilation on first error 32 | export CFLAGS="-Wfatal-errors" 33 | 34 | # Include default MinGW include directory, and libnfc's win32 files 35 | export CFLAGS="$CFLAGS -I$MINGW_DIR/include -I$PWD/contrib/win32" 36 | 37 | if [ "$MINGW" = "i686-w64-mingw32" ]; then 38 | # mingw-64 includes winscard.a and winscard.h 39 | # 40 | # It is not enough to set libpcsclite_LIBS to "-lwinscard", because it is 41 | # forgotten when libnfc is created with libtool. That's why we are setting 42 | # LIBS. 43 | export LIBS="-lwinscard" 44 | 45 | echo "MinGW-w64 ships all requirements libnfc." 46 | echo "Unfortunately the MinGW-w64 header are currently" 47 | echo "buggy. Also, Libtool doesn't support MinGW-w64" 48 | echo "very well." 49 | echo "" 50 | echo "Warning ________________________________________" 51 | echo "You will only be able to compile libnfc.dll, but" 52 | echo "none of the executables (see utils and examples)." 53 | echo "" 54 | # You can fix winbase.h by adding the following lines: 55 | # #include 56 | # #include 57 | # But the problem with Libtool remains. 58 | else 59 | if [ -z "$libpcsclite_LIBS$libpcsclite_CFLAGS" ]; then 60 | echo "Error __________________________________________" 61 | echo "You need to get the PC/SC library from a Windows" 62 | echo "machine and the appropriate header files. Then" 63 | echo "specify libpcsclite_LIBS=.../WinScard.dll and" 64 | echo "libpcsclite_CFLAGS=-I..." 65 | fi 66 | exit 1 67 | fi 68 | 69 | ## Configure to cross-compile using mingw32msvc 70 | if [ "$WITH_USB" = "1" ]; then 71 | # with direct-USB drivers (use libusb-win32) 72 | DRIVERS="all" 73 | else 74 | # with UART divers only (can be tested under wine) 75 | DRIVERS="pn532_uart,arygon" 76 | fi 77 | 78 | if [ ! -x configure ]; then 79 | autoreconf -is 80 | fi 81 | 82 | ./configure --target=$MINGW --host=$MINGW \ 83 | --with-drivers=$DRIVERS \ 84 | --with-libusb-win32=$PWD/$LIBUSB_WIN32_BIN_DIR \ 85 | $* 86 | 87 | if [ "$MINGW" = "i686-w64-mingw32" ]; then 88 | # due to the buggy headers from MINGW-64 we always add "contrib/windows.h", 89 | # otherwise some windows types won't be available. 90 | echo "#include \"contrib/windows.h\"" >> config.h 91 | fi 92 | -------------------------------------------------------------------------------- /libnfc-1.7.1/libnfc/log.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Free/Libre Near Field Communication (NFC) library 3 | * 4 | * Libnfc historical contributors: 5 | * Copyright (C) 2009 Roel Verdult 6 | * Copyright (C) 2009-2013 Romuald Conty 7 | * Copyright (C) 2010-2012 Romain Tartière 8 | * Copyright (C) 2010-2013 Philippe Teuwen 9 | * Copyright (C) 2012-2013 Ludovic Rousseau 10 | * See AUTHORS file for a more comprehensive list of contributors. 11 | * Additional contributors of this file: 12 | * 13 | * This program is free software: you can redistribute it and/or modify it 14 | * under the terms of the GNU Lesser General Public License as published by the 15 | * Free Software Foundation, either version 3 of the License, or (at your 16 | * option) any later version. 17 | * 18 | * This program is distributed in the hope that it will be useful, but WITHOUT 19 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 21 | * more details. 22 | * 23 | * You should have received a copy of the GNU Lesser General Public License 24 | * along with this program. If not, see 25 | */ 26 | 27 | #include "log.h" 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | const char * 37 | log_priority_to_str(const int priority) 38 | { 39 | switch (priority) { 40 | case NFC_LOG_PRIORITY_ERROR: 41 | return "error"; 42 | case NFC_LOG_PRIORITY_INFO: 43 | return "info"; 44 | case NFC_LOG_PRIORITY_DEBUG: 45 | return "debug"; 46 | default: 47 | break; 48 | } 49 | return "unknown"; 50 | } 51 | 52 | 53 | #ifdef LOG 54 | 55 | #include "log-internal.h" 56 | 57 | void 58 | log_init(const nfc_context *context) 59 | { 60 | #ifdef ENVVARS 61 | char str[32]; 62 | sprintf(str, "%"PRIu32, context->log_level); 63 | setenv("LIBNFC_LOG_LEVEL", str, 1); 64 | #else 65 | (void)context; 66 | #endif 67 | } 68 | 69 | void 70 | log_exit(void) 71 | { 72 | } 73 | 74 | void 75 | log_put(const uint8_t group, const char *category, const uint8_t priority, const char *format, ...) 76 | { 77 | char *env_log_level = NULL; 78 | #ifdef ENVVARS 79 | env_log_level = getenv("LIBNFC_LOG_LEVEL"); 80 | #endif 81 | uint32_t log_level; 82 | if (NULL == env_log_level) { 83 | // LIBNFC_LOG_LEVEL is not set 84 | #ifdef DEBUG 85 | log_level = 3; 86 | #else 87 | log_level = 1; 88 | #endif 89 | } else { 90 | log_level = atoi(env_log_level); 91 | } 92 | 93 | // printf("log_level = %"PRIu32" group = %"PRIu8" priority = %"PRIu8"\n", log_level, group, priority); 94 | if (log_level) { // If log is not disabled by log_level=none 95 | if (((log_level & 0x00000003) >= priority) || // Global log level 96 | (((log_level >> (group * 2)) & 0x00000003) >= priority)) { // Group log level 97 | 98 | va_list va; 99 | va_start(va, format); 100 | log_put_internal("%s\t%s\t", log_priority_to_str(priority), category); 101 | log_vput_internal(format, va); 102 | log_put_internal("\n"); 103 | va_end(va); 104 | } 105 | } 106 | } 107 | 108 | #endif // LOG 109 | -------------------------------------------------------------------------------- /libnfc-1.7.1/cmake/modules/UseDoxygen.cmake: -------------------------------------------------------------------------------- 1 | # - Run Doxygen 2 | # 3 | # Adds a doxygen target that runs doxygen to generate the html 4 | # and optionally the LaTeX API documentation. 5 | # The doxygen target is added to the doc target as dependency. 6 | # i.e.: the API documentation is built with: 7 | # make doc 8 | # 9 | # USAGE: GLOBAL INSTALL 10 | # 11 | # Install it with: 12 | # cmake ./ && sudo make install 13 | # Add the following to the CMakeLists.txt of your project: 14 | # include(UseDoxygen OPTIONAL) 15 | # Optionally copy Doxyfile.in in the directory of CMakeLists.txt and edit it. 16 | # 17 | # USAGE: INCLUDE IN PROJECT 18 | # 19 | # set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) 20 | # include(UseDoxygen) 21 | # Add the Doxyfile.in and UseDoxygen.cmake files to the projects source directory. 22 | # 23 | # 24 | # Variables you may define are: 25 | # DOXYFILE_OUTPUT_DIR - Path where the Doxygen output is stored. Defaults to "doc". 26 | # 27 | # DOXYFILE_LATEX_DIR - Directory where the Doxygen LaTeX output is stored. Defaults to "latex". 28 | # 29 | # DOXYFILE_HTML_DIR - Directory where the Doxygen html output is stored. Defaults to "html". 30 | # 31 | 32 | # 33 | # Copyright (c) 2009 Tobias Rautenkranz 34 | # 35 | # Redistribution and use is allowed according to the terms of the New 36 | # BSD license. 37 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 38 | # 39 | 40 | macro(usedoxygen_set_default name value) 41 | if(NOT DEFINED "${name}") 42 | set("${name}" "${value}") 43 | endif() 44 | endmacro() 45 | 46 | find_package(Doxygen) 47 | 48 | if(DOXYGEN_FOUND) 49 | find_file(DOXYFILE_IN "Doxyfile.in" 50 | PATHS "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_ROOT}/Modules/") 51 | 52 | include(FindPackageHandleStandardArgs) 53 | find_package_handle_standard_args(Doxyfile.in DEFAULT_MSG DOXYFILE_IN) 54 | endif() 55 | 56 | if(DOXYGEN_FOUND AND DOXYFILE_IN) 57 | add_custom_target(doxygen ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) 58 | 59 | usedoxygen_set_default(DOXYFILE_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/doc") 60 | usedoxygen_set_default(DOXYFILE_HTML_DIR "html") 61 | 62 | set_property(DIRECTORY APPEND PROPERTY 63 | ADDITIONAL_MAKE_CLEAN_FILES "${DOXYFILE_OUTPUT_DIR}/${DOXYFILE_HTML_DIR}") 64 | 65 | set(DOXYFILE_LATEX "NO") 66 | set(DOXYFILE_PDFLATEX "NO") 67 | set(DOXYFILE_DOT "NO") 68 | 69 | find_package(LATEX) 70 | if(LATEX_COMPILER AND MAKEINDEX_COMPILER) 71 | set(DOXYFILE_LATEX "YES") 72 | usedoxygen_set_default(DOXYFILE_LATEX_DIR "latex") 73 | 74 | set_property(DIRECTORY APPEND PROPERTY 75 | ADDITIONAL_MAKE_CLEAN_FILES 76 | "${DOXYFILE_OUTPUT_DIR}/${DOXYFILE_LATEX_DIR}") 77 | 78 | if(PDFLATEX_COMPILER) 79 | set(DOXYFILE_PDFLATEX "YES") 80 | endif() 81 | if(DOXYGEN_DOT_EXECUTABLE) 82 | set(DOXYFILE_DOT "YES") 83 | endif() 84 | 85 | add_custom_command(TARGET doxygen 86 | POST_BUILD 87 | COMMAND ${CMAKE_MAKE_PROGRAM} 88 | WORKING_DIRECTORY "${DOXYFILE_OUTPUT_DIR}/${DOXYFILE_LATEX_DIR}") 89 | endif() 90 | 91 | 92 | configure_file(${DOXYFILE_IN} Doxyfile ESCAPE_QUOTES IMMEDIATE @ONLY) 93 | 94 | get_target_property(DOC_TARGET doc TYPE) 95 | if(NOT DOC_TARGET) 96 | add_custom_target(doc) 97 | endif() 98 | 99 | add_dependencies(doc doxygen) 100 | endif() 101 | -------------------------------------------------------------------------------- /libnfc-1.7.1/examples/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = pn53x-tamashell-scripts 2 | 3 | bin_PROGRAMS = \ 4 | nfc-anticol \ 5 | nfc-dep-initiator \ 6 | nfc-dep-target \ 7 | nfc-emulate-forum-tag2 \ 8 | nfc-emulate-tag \ 9 | nfc-emulate-uid \ 10 | nfc-mfsetuid \ 11 | nfc-poll \ 12 | nfc-relay \ 13 | pn53x-diagnose \ 14 | pn53x-sam 15 | 16 | if POSIX_ONLY_EXAMPLES_ENABLED 17 | bin_PROGRAMS += \ 18 | pn53x-tamashell 19 | endif 20 | 21 | check_PROGRAMS = \ 22 | quick_start_example1 \ 23 | quick_start_example2 24 | 25 | # set the include path found by configure 26 | AM_CPPFLAGS = $(all_includes) $(LIBNFC_CFLAGS) 27 | 28 | AM_CFLAGS = -I$(top_srcdir)/libnfc -I$(top_srcdir) 29 | 30 | nfc_poll_SOURCES = nfc-poll.c 31 | nfc_poll_LDADD = $(top_builddir)/libnfc/libnfc.la \ 32 | $(top_builddir)/utils/libnfcutils.la 33 | 34 | nfc_anticol_SOURCES = nfc-anticol.c 35 | nfc_anticol_LDADD = $(top_builddir)/libnfc/libnfc.la \ 36 | $(top_builddir)/utils/libnfcutils.la 37 | 38 | nfc_relay_SOURCES = nfc-relay.c 39 | nfc_relay_LDADD = $(top_builddir)/libnfc/libnfc.la \ 40 | $(top_builddir)/utils/libnfcutils.la 41 | 42 | nfc_emulate_forum_tag2_SOURCES = nfc-emulate-forum-tag2.c 43 | nfc_emulate_forum_tag2_LDADD = $(top_builddir)/libnfc/libnfc.la \ 44 | $(top_builddir)/utils/libnfcutils.la 45 | 46 | nfc_emulate_tag_SOURCES = nfc-emulate-tag.c 47 | nfc_emulate_tag_LDADD = $(top_builddir)/libnfc/libnfc.la \ 48 | $(top_builddir)/utils/libnfcutils.la 49 | 50 | nfc_emulate_uid_SOURCES = nfc-emulate-uid.c 51 | nfc_emulate_uid_LDADD = $(top_builddir)/libnfc/libnfc.la \ 52 | $(top_builddir)/utils/libnfcutils.la 53 | 54 | nfc_dep_target_SOURCES = nfc-dep-target.c 55 | nfc_dep_target_LDADD = $(top_builddir)/libnfc/libnfc.la \ 56 | $(top_builddir)/utils/libnfcutils.la 57 | 58 | nfc_dep_initiator_SOURCES = nfc-dep-initiator.c 59 | nfc_dep_initiator_LDADD = $(top_builddir)/libnfc/libnfc.la \ 60 | $(top_builddir)/utils/libnfcutils.la 61 | 62 | nfc_mfsetuid_SOURCES = nfc-mfsetuid.c 63 | nfc_mfsetuid_LDADD = $(top_builddir)/libnfc/libnfc.la \ 64 | $(top_builddir)/utils/libnfcutils.la 65 | 66 | pn53x_diagnose_SOURCES = pn53x-diagnose.c 67 | pn53x_diagnose_LDADD = $(top_builddir)/libnfc/libnfc.la \ 68 | $(top_builddir)/utils/libnfcutils.la 69 | 70 | pn53x_sam_SOURCES = pn53x-sam.c 71 | pn53x_sam_LDADD = $(top_builddir)/libnfc/libnfc.la \ 72 | $(top_builddir)/utils/libnfcutils.la 73 | 74 | pn53x_tamashell_SOURCES = pn53x-tamashell.c 75 | pn53x_tamashell_LDADD = $(top_builddir)/libnfc/libnfc.la \ 76 | $(top_builddir)/utils/libnfcutils.la 77 | pn53x_tamashell_LDFLAGS = @READLINE_LIBS@ 78 | 79 | quick_start_example1_SOURCES = doc/quick_start_example1.c 80 | quick_start_example1_LDADD = $(top_builddir)/libnfc/libnfc.la \ 81 | $(top_builddir)/utils/libnfcutils.la 82 | 83 | quick_start_example2_SOURCES = doc/quick_start_example2.c 84 | quick_start_example2_LDADD = $(top_builddir)/libnfc/libnfc.la \ 85 | $(top_builddir)/utils/libnfcutils.la 86 | 87 | 88 | dist_man_MANS = \ 89 | nfc-anticol.1 \ 90 | nfc-dep-initiator.1 \ 91 | nfc-dep-target.1 \ 92 | nfc-emulate-tag.1 \ 93 | nfc-emulate-uid.1 \ 94 | nfc-poll.1 \ 95 | nfc-relay.1 \ 96 | nfc-mfsetuid.1 \ 97 | pn53x-diagnose.1 \ 98 | pn53x-sam.1 \ 99 | pn53x-tamashell.1 \ 100 | nfc-emulate-forum-tag2.1 101 | 102 | EXTRA_DIST = CMakeLists.txt 103 | -------------------------------------------------------------------------------- /libnfc-1.7.1/utils/crapto1.h: -------------------------------------------------------------------------------- 1 | /* crapto1.h 2 | 3 | This program is free software; you can redistribute it and/or 4 | modify it under the terms of the GNU General Public License 5 | as published by the Free Software Foundation; either version 2 6 | of the License, or (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 16 | MA 02110-1301, US$ 17 | 18 | Copyright (C) 2008-2008 bla 19 | */ 20 | #ifndef CRAPTO1_INCLUDED 21 | #define CRAPTO1_INCLUDED 22 | #include 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | struct Crypto1State {uint32_t odd, even;}; 28 | struct Crypto1State* crypto1_create(uint64_t); 29 | void crypto1_destroy(struct Crypto1State*); 30 | void crypto1_get_lfsr(struct Crypto1State*, uint64_t*); 31 | uint8_t crypto1_bit(struct Crypto1State*, uint8_t, int); 32 | uint8_t crypto1_byte(struct Crypto1State*, uint8_t, int); 33 | uint32_t crypto1_word(struct Crypto1State*, uint32_t, int); 34 | uint32_t prng_successor(uint32_t x, uint32_t n); 35 | 36 | struct Crypto1State* lfsr_recovery32(uint32_t ks2, uint32_t in); 37 | struct Crypto1State* lfsr_recovery64(uint32_t ks2, uint32_t ks3); 38 | uint32_t *lfsr_prefix_ks(uint8_t ks[8], int isodd); 39 | struct Crypto1State* 40 | lfsr_common_prefix(uint32_t pfx, uint32_t rr, uint8_t ks[8], uint8_t par[8][8]); 41 | 42 | uint8_t lfsr_rollback_bit(struct Crypto1State* s, uint32_t in, int fb); 43 | uint8_t lfsr_rollback_byte(struct Crypto1State* s, uint32_t in, int fb); 44 | uint32_t lfsr_rollback_word(struct Crypto1State* s, uint32_t in, int fb); 45 | int nonce_distance(uint32_t from, uint32_t to); 46 | #define FOREACH_VALID_NONCE(N, FILTER, FSIZE)\ 47 | uint32_t __n = 0,__M = 0, N = 0;\ 48 | int __i;\ 49 | for(; __n < 1 << 16; N = prng_successor(__M = ++__n, 16))\ 50 | for(__i = FSIZE - 1; __i >= 0; __i--)\ 51 | if(BIT(FILTER, __i) ^ parity(__M & 0xFF01))\ 52 | break;\ 53 | else if(__i)\ 54 | __M = prng_successor(__M, (__i == 7) ? 48 : 8);\ 55 | else 56 | 57 | #define LF_POLY_ODD (0x29CE5C) 58 | #define LF_POLY_EVEN (0x870804) 59 | #define BIT(x, n) ((x) >> (n) & 1) 60 | #define BEBIT(x, n) BIT(x, (n) ^ 24) 61 | static inline int parity(uint32_t x) 62 | { 63 | #if !defined __i386__ || !defined __GNUC__ 64 | x ^= x >> 16; 65 | x ^= x >> 8; 66 | x ^= x >> 4; 67 | return BIT(0x6996, x & 0xf); 68 | #else 69 | __asm__( "movl %1, %%eax\n" 70 | "mov %%ax, %%cx\n" 71 | "shrl $0x10, %%eax\n" 72 | "xor %%ax, %%cx\n" 73 | "xor %%ch, %%cl\n" 74 | "setpo %%al\n" 75 | "movzx %%al, %0\n": "=r"(x) : "r"(x): "eax","ecx"); 76 | return x; 77 | #endif 78 | } 79 | static inline int filter(uint32_t const x) 80 | { 81 | uint32_t f; 82 | 83 | f = 0xf22c0 >> (x & 0xf) & 16; 84 | f |= 0x6c9c0 >> (x >> 4 & 0xf) & 8; 85 | f |= 0x3c8b0 >> (x >> 8 & 0xf) & 4; 86 | f |= 0x1e458 >> (x >> 12 & 0xf) & 2; 87 | f |= 0x0d938 >> (x >> 16 & 0xf) & 1; 88 | return BIT(0xEC57E80A, f); 89 | } 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | #endif 94 | -------------------------------------------------------------------------------- /libnfc-1.7.1/libnfc/mirror-subr.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Free/Libre Near Field Communication (NFC) library 3 | * 4 | * Libnfc historical contributors: 5 | * Copyright (C) 2009 Roel Verdult 6 | * Copyright (C) 2009-2013 Romuald Conty 7 | * Copyright (C) 2010-2012 Romain Tartière 8 | * Copyright (C) 2010-2013 Philippe Teuwen 9 | * Copyright (C) 2012-2013 Ludovic Rousseau 10 | * See AUTHORS file for a more comprehensive list of contributors. 11 | * Additional contributors of this file: 12 | * 13 | * This program is free software: you can redistribute it and/or modify it 14 | * under the terms of the GNU Lesser General Public License as published by the 15 | * Free Software Foundation, either version 3 of the License, or (at your 16 | * option) any later version. 17 | * 18 | * This program is distributed in the hope that it will be useful, but WITHOUT 19 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 21 | * more details. 22 | * 23 | * You should have received a copy of the GNU Lesser General Public License 24 | * along with this program. If not, see 25 | */ 26 | 27 | /** 28 | * @file mirror-subr.c 29 | * @brief Mirror bytes 30 | */ 31 | 32 | #ifdef HAVE_CONFIG_H 33 | # include "config.h" 34 | #endif // HAVE_CONFIG_H 35 | 36 | #include 37 | 38 | #include "mirror-subr.h" 39 | 40 | static const uint8_t ByteMirror[256] = { 41 | 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, 0xd0, 0x30, 42 | 0xb0, 0x70, 0xf0, 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, 0x18, 0x98, 43 | 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 44 | 0xe4, 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, 0x0c, 0x8c, 0x4c, 0xcc, 45 | 0x2c, 0xac, 0x6c, 0xec, 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, 0x02, 46 | 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 47 | 0x72, 0xf2, 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, 0x1a, 0x9a, 0x5a, 48 | 0xda, 0x3a, 0xba, 0x7a, 0xfa, 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, 49 | 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 50 | 0xae, 0x6e, 0xee, 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, 0x01, 0x81, 51 | 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 52 | 0xf1, 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, 0x19, 0x99, 0x59, 0xd9, 53 | 0x39, 0xb9, 0x79, 0xf9, 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, 0x15, 54 | 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 55 | 0x6d, 0xed, 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, 0x03, 0x83, 0x43, 56 | 0xc3, 0x23, 0xa3, 0x63, 0xe3, 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, 57 | 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 58 | 0xbb, 0x7b, 0xfb, 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, 0x17, 0x97, 59 | 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 60 | 0xef, 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff 61 | }; 62 | 63 | uint8_t 64 | mirror(uint8_t bt) 65 | { 66 | return ByteMirror[bt]; 67 | } 68 | 69 | static void 70 | mirror_bytes(uint8_t *pbts, size_t szLen) 71 | { 72 | size_t szByteNr; 73 | 74 | for (szByteNr = 0; szByteNr < szLen; szByteNr++) { 75 | *pbts = ByteMirror[*pbts]; 76 | pbts++; 77 | } 78 | } 79 | 80 | uint32_t 81 | mirror32(uint32_t ui32Bits) 82 | { 83 | mirror_bytes((uint8_t *) & ui32Bits, 4); 84 | return ui32Bits; 85 | } 86 | 87 | uint64_t 88 | mirror64(uint64_t ui64Bits) 89 | { 90 | mirror_bytes((uint8_t *) & ui64Bits, 8); 91 | return ui64Bits; 92 | } 93 | -------------------------------------------------------------------------------- /libnfc-1.7.1/utils/nfc-mfclassic.1: -------------------------------------------------------------------------------- 1 | .TH nfc-mfclassic 1 "Nov 02, 2009" "libnfc" "NFC Utilities" 2 | .SH NAME 3 | nfc-mfclassic \- MIFARE Classic command line tool 4 | .SH SYNOPSIS 5 | .B nfc-mfclassic 6 | .RI \fR\fBf\fR|\fR\fBr\fR|\fR\fBR\fR|\fBw\fR\fR|\fBW\fR 7 | .RI \fR\fBa\fR|\fR\fBA\fR|\fBb\fR\fR|\fBB\fR 8 | .IR DUMP 9 | .RI [ 10 | .IR KEYS 11 | .RI [\fR\fBf\fR] 12 | .RI ] 13 | 14 | .SH DESCRIPTION 15 | .B nfc-mfclassic 16 | is a MIFARE Classic tool that allow to read or write 17 | .IR DUMP 18 | file using MIFARE keys provided in 19 | .IR KEYS 20 | file. 21 | 22 | MIFARE Classic tag is one of the most widely used RFID tags. 23 | 24 | The firmware in the NFC controller supports authenticating, reading and writing 25 | to/from MIFARE Classic tags. This tool demonstrates the speed of this library 26 | and its ease-of-use. It's possible to read and write the complete content of a 27 | MIFARE Classic 4KB tag within 1 second. It uses a binary MIFARE Dump file (MFD) 28 | to store the keys and data for all sectors. 29 | 30 | Be cautious that some parts of a MIFARE Classic memory are used for r/w access 31 | of the rest of the memory, so please read the tag documentation before experimenting too much! 32 | 33 | The 34 | .B f 35 | option to format the card will reset all keys to FFFFFFFFFFFF, all data to 00 and all ACLs to default. 36 | 37 | The 38 | .B W 39 | option allows writing of special MIFARE cards that can be 'unlocked' to allow block 0 40 | to be overwritten. This includes UID and manufacturer data. Take care when amending UIDs to set 41 | the correct BCC (UID checksum). Currently only 4 byte UIDs are supported. 42 | 43 | Similarly, the 44 | .B R 45 | option allows an 'unlocked' read. This bypasses authentication and allows 46 | reading of the Key A and Key B data regardless of ACLs. 47 | 48 | R/W errors on some blocks can be either considered as critical or ignored. 49 | To halt on first error, specify keys with lowercase ( 50 | .B a 51 | or 52 | .B b 53 | ). To ignore such errors, use uppercase ( 54 | .B A 55 | or 56 | .B B 57 | ). 58 | 59 | *** Note that 60 | .B W 61 | and 62 | .B R 63 | options only work on special versions of MIFARE 1K cards (Chinese clones). 64 | 65 | .SH OPTIONS 66 | .TP 67 | .BR f " | " r " | " R " | " w " | " W 68 | Perform format ( 69 | .B f 70 | ) or read from ( 71 | .B r 72 | ) or unlocked read from ( 73 | .B R 74 | ) or write to ( 75 | .B w 76 | ) or unlocked write to ( 77 | .B W 78 | ) card. 79 | .TP 80 | .BR a " | " A " | " b " | " B 81 | Use A or B MIFARE keys. 82 | Halt on errors ( 83 | .B a 84 | | 85 | .B b 86 | ) or tolerate errors ( 87 | .B A 88 | | 89 | .B 90 | B 91 | ). 92 | .TP 93 | .IR DUMP 94 | MiFare Dump (MFD) used to write (card to MFD) or (MFD to card) 95 | .TP 96 | .IR KEYS 97 | MiFare Dump (MFD) that contains the keys (optional). Data part of the dump is ignored. 98 | .TP 99 | .B f 100 | Force using the keyfile 101 | .IR KEYS 102 | even if UID does not match (optional). 103 | 104 | .SH BUGS 105 | Please report any bugs on the 106 | .B libnfc 107 | issue tracker at: 108 | .br 109 | .BR http://code.google.com/p/libnfc/issues 110 | .SH LICENCE 111 | .B libnfc 112 | is licensed under the GNU Lesser General Public License (LGPL), version 3. 113 | .br 114 | .B libnfc-utils 115 | and 116 | .B libnfc-examples 117 | are covered by the the BSD 2-Clause license. 118 | 119 | .SH AUTHORS 120 | Adam Laurie , 121 | .br 122 | Roel Verdult , 123 | .br 124 | Romain Tartière , 125 | .br 126 | Romuald Conty . 127 | .PP 128 | This manual page was written by Romuald Conty . 129 | It is licensed under the terms of the GNU GPL (version 2 or later). 130 | -------------------------------------------------------------------------------- /libnfc-1.7.1/utils/nfc-utils.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Free/Libre Near Field Communication (NFC) library 3 | * 4 | * Libnfc historical contributors: 5 | * Copyright (C) 2009 Roel Verdult 6 | * Copyright (C) 2009-2013 Romuald Conty 7 | * Copyright (C) 2010-2012 Romain Tartière 8 | * Copyright (C) 2010-2013 Philippe Teuwen 9 | * Copyright (C) 2012-2013 Ludovic Rousseau 10 | * See AUTHORS file for a more comprehensive list of contributors. 11 | * Additional contributors of this file: 12 | * 13 | * Redistribution and use in source and binary forms, with or without 14 | * modification, are permitted provided that the following conditions are met: 15 | * 1) Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2 )Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | * POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | * Note that this license only applies on the examples, NFC library itself is under LGPL 34 | * 35 | */ 36 | 37 | /** 38 | * @file nfc-utils.h 39 | * @brief Provide some examples shared functions like print, parity calculation, options parsing. 40 | */ 41 | 42 | #ifndef _EXAMPLES_NFC_UTILS_H_ 43 | # define _EXAMPLES_NFC_UTILS_H_ 44 | 45 | # include 46 | # include 47 | # include 48 | 49 | /** 50 | * @macro DBG 51 | * @brief Print a message of standard output only in DEBUG mode 52 | */ 53 | #ifdef DEBUG 54 | # define DBG(...) do { \ 55 | warnx ("DBG %s:%d", __FILE__, __LINE__); \ 56 | warnx (" " __VA_ARGS__ ); \ 57 | } while (0) 58 | #else 59 | # define DBG(...) {} 60 | #endif 61 | 62 | /** 63 | * @macro WARN 64 | * @brief Print a warn message 65 | */ 66 | #ifdef DEBUG 67 | # define WARN(...) do { \ 68 | warnx ("WARNING %s:%d", __FILE__, __LINE__); \ 69 | warnx (" " __VA_ARGS__ ); \ 70 | } while (0) 71 | #else 72 | # define WARN(...) warnx ("WARNING: " __VA_ARGS__ ) 73 | #endif 74 | 75 | /** 76 | * @macro ERR 77 | * @brief Print a error message 78 | */ 79 | #ifdef DEBUG 80 | # define ERR(...) do { \ 81 | warnx ("ERROR %s:%d", __FILE__, __LINE__); \ 82 | warnx (" " __VA_ARGS__ ); \ 83 | } while (0) 84 | #else 85 | # define ERR(...) warnx ("ERROR: " __VA_ARGS__ ) 86 | #endif 87 | 88 | #ifndef MIN 89 | #define MIN(a,b) (((a) < (b)) ? (a) : (b)) 90 | #endif 91 | #ifndef MAX 92 | #define MAX(a,b) (((a) > (b)) ? (a) : (b)) 93 | #endif 94 | 95 | uint8_t oddparity(const uint8_t bt); 96 | void oddparity_bytes_ts(const uint8_t *pbtData, const size_t szLen, uint8_t *pbtPar); 97 | 98 | void print_hex(const uint8_t *pbtData, const size_t szLen); 99 | void print_hex_bits(const uint8_t *pbtData, const size_t szBits); 100 | void print_hex_par(const uint8_t *pbtData, const size_t szBits, const uint8_t *pbtDataPar); 101 | 102 | void print_nfc_target(const nfc_target *pnt, bool verbose); 103 | 104 | #endif 105 | -------------------------------------------------------------------------------- /libnfc-1.7.1/utils/jewel.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Free/Libre Near Field Communication (NFC) library 3 | * 4 | * Libnfc historical contributors: 5 | * Copyright (C) 2009 Roel Verdult 6 | * Copyright (C) 2009-2013 Romuald Conty 7 | * Copyright (C) 2010-2012 Romain Tartière 8 | * Copyright (C) 2010-2013 Philippe Teuwen 9 | * Copyright (C) 2012-2013 Ludovic Rousseau 10 | * See AUTHORS file for a more comprehensive list of contributors. 11 | * Additional contributors of this file: 12 | * Copyright (C) 2014 Pim 't Hart 13 | * 14 | * Redistribution and use in source and binary forms, with or without 15 | * modification, are permitted provided that the following conditions are met: 16 | * 1) Redistributions of source code must retain the above copyright notice, 17 | * this list of conditions and the following disclaimer. 18 | * 2 )Redistributions in binary form must reproduce the above copyright 19 | * notice, this list of conditions and the following disclaimer in the 20 | * documentation and/or other materials provided with the distribution. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * Note that this license only applies on the examples, NFC library itself is under LGPL 35 | * 36 | */ 37 | /** 38 | * @file jewel.c 39 | * @brief provide samples structs and functions to manipulate Jewel Topaz tags using libnfc 40 | */ 41 | #include "jewel.h" 42 | 43 | #include 44 | 45 | #include 46 | 47 | /** 48 | * @brief Execute a Jewel Topaz Command 49 | * @return Returns true if action was successfully performed; otherwise returns false. 50 | * @param req The request 51 | * @param res The response 52 | * 53 | */ 54 | 55 | bool 56 | nfc_initiator_jewel_cmd(nfc_device *pnd, const jewel_req req, jewel_res *pres) 57 | { 58 | size_t nLenReq; 59 | size_t nLenRes; 60 | 61 | switch (req.rid.btCmd) { 62 | case TC_RID: 63 | nLenReq = sizeof(jewel_req_rid); 64 | nLenRes = sizeof(jewel_res_rid); 65 | break; 66 | case TC_RALL: 67 | nLenReq = sizeof(jewel_req_rall); 68 | nLenRes = sizeof(jewel_res_rall); 69 | break; 70 | case TC_READ: 71 | nLenReq = sizeof(jewel_req_read); 72 | nLenRes = sizeof(jewel_res_read); 73 | break; 74 | case TC_WRITEE: 75 | nLenReq = sizeof(jewel_req_writee); 76 | nLenRes = sizeof(jewel_res_writee); 77 | break; 78 | case TC_WRITENE: 79 | nLenReq = sizeof(jewel_req_writene); 80 | nLenRes = sizeof(jewel_res_writene); 81 | break; 82 | case TC_RSEG: 83 | nLenReq = sizeof(jewel_req_rseg); 84 | nLenRes = sizeof(jewel_res_rseg); 85 | break; 86 | case TC_READ8: 87 | nLenReq = sizeof(jewel_req_read8); 88 | nLenRes = sizeof(jewel_res_read8); 89 | break; 90 | case TC_WRITEE8: 91 | nLenReq = sizeof(jewel_req_writee8); 92 | nLenRes = sizeof(jewel_res_writee8); 93 | break; 94 | case TC_WRITENE8: 95 | nLenReq = sizeof(jewel_req_writene8); 96 | nLenRes = sizeof(jewel_res_writene8); 97 | break; 98 | default: 99 | return false; 100 | } 101 | 102 | if (nfc_initiator_transceive_bytes(pnd, (uint8_t *)&req, nLenReq, (uint8_t *)pres, nLenRes, -1) < 0) { 103 | nfc_perror(pnd, "nfc_initiator_transceive_bytes"); 104 | return false; 105 | } 106 | 107 | return true; 108 | } 109 | -------------------------------------------------------------------------------- /libnfc-1.7.1/libnfc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Windows MinGW workarounds 2 | IF(WIN32) 3 | SET(WINDOWS_SOURCES ../contrib/win32/stdlib) 4 | INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../contrib/win32) 5 | 6 | # Add in the rc for version information in the dll 7 | LIST(APPEND WINDOWS_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/../windows/libnfc.rc) 8 | ENDIF(WIN32) 9 | 10 | # Library's chips 11 | SET(CHIPS_SOURCES chips/pn53x) 12 | INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/chips) 13 | 14 | # Library's buses 15 | IF(USB_REQUIRED) 16 | LIST(APPEND BUSES_SOURCES buses/usbbus) 17 | ENDIF(USB_REQUIRED) 18 | 19 | IF(UART_REQUIRED) 20 | IF(WIN32) 21 | # Windows have a special implementation for UART 22 | LIST(APPEND BUSES_SOURCES ../contrib/win32/libnfc/buses/uart) 23 | ELSE(WIN32) 24 | LIST(APPEND BUSES_SOURCES buses/uart) 25 | ENDIF(WIN32) 26 | ENDIF(UART_REQUIRED) 27 | 28 | IF(I2C_REQUIRED) 29 | IF(WIN32) 30 | # Windows is not supported at the moment 31 | #LIST(APPEND BUSES_SOURCES ../contrib/win32/libnfc/buses/i2c) 32 | MESSAGE( FATAL_ERROR "I2C not (yet) supported under Windows!" ) 33 | ELSE(WIN32) 34 | LIST(APPEND BUSES_SOURCES buses/i2c) 35 | ENDIF(WIN32) 36 | ENDIF(I2C_REQUIRED) 37 | 38 | IF(SPI_REQUIRED) 39 | IF(WIN32) 40 | # Windows is not supported at the moment 41 | #LIST(APPEND BUSES_SOURCES ../contrib/win32/libnfc/buses/spi) 42 | MESSAGE( FATAL_ERROR "SPI not (yet) supported under Windows!" ) 43 | ELSE(WIN32) 44 | LIST(APPEND BUSES_SOURCES buses/spi) 45 | ENDIF(WIN32) 46 | ENDIF(SPI_REQUIRED) 47 | 48 | INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/buses) 49 | 50 | IF(WIN32) 51 | # Windows now requires regex, so we utilize PCRE 52 | # since Windows doesn't get the benefit of finding in CMake 53 | # it has to be added manually 54 | IF(PCRE_FOUND) 55 | INCLUDE_DIRECTORIES(${PCRE_INCLUDE_DIRS}) 56 | LINK_DIRECTORIES(${PCRE_LIBRARY_DIRS}) 57 | ENDIF(PCRE_FOUND) 58 | ENDIF(WIN32) 59 | 60 | IF(PCSC_FOUND) 61 | INCLUDE_DIRECTORIES(${PCSC_INCLUDE_DIRS}) 62 | LINK_DIRECTORIES(${PCSC_LIBRARY_DIRS}) 63 | ENDIF(PCSC_FOUND) 64 | 65 | IF(LIBUSB_FOUND) 66 | INCLUDE_DIRECTORIES(${LIBUSB_INCLUDE_DIRS}) 67 | LINK_DIRECTORIES(${LIBUSB_LIBRARY_DIRS}) 68 | ENDIF(LIBUSB_FOUND) 69 | 70 | # Library 71 | SET(LIBRARY_SOURCES nfc nfc-device nfc-emulation nfc-internal conf iso14443-subr mirror-subr target-subr ${DRIVERS_SOURCES} ${BUSES_SOURCES} ${CHIPS_SOURCES} ${WINDOWS_SOURCES}) 72 | INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) 73 | 74 | IF(LIBNFC_LOG) 75 | IF(WIN32) 76 | SET(CMAKE_C_FLAGS "-fgnu89-inline ${CMAKE_C_FLAGS}") 77 | LIST(APPEND LIBRARY_SOURCES log ../contrib/win32/libnfc/log-internal) 78 | ELSE(WIN32) 79 | LIST(APPEND LIBRARY_SOURCES log log-internal) 80 | ENDIF(WIN32) 81 | ENDIF(LIBNFC_LOG) 82 | ADD_LIBRARY(nfc SHARED ${LIBRARY_SOURCES}) 83 | 84 | IF(PCSC_FOUND) 85 | TARGET_LINK_LIBRARIES(nfc ${PCSC_LIBRARIES}) 86 | ENDIF(PCSC_FOUND) 87 | 88 | IF(LIBUSB_FOUND) 89 | TARGET_LINK_LIBRARIES(nfc ${LIBUSB_LIBRARIES}) 90 | ENDIF(LIBUSB_FOUND) 91 | 92 | SET_TARGET_PROPERTIES(nfc PROPERTIES SOVERSION 0) 93 | 94 | IF(WIN32) 95 | # Libraries that are windows specific 96 | TARGET_LINK_LIBRARIES(nfc wsock32) 97 | IF(PCRE_FOUND) 98 | TARGET_LINK_LIBRARIES(nfc ${PCRE_LIBRARIES}) 99 | ENDIF(PCRE_FOUND) 100 | 101 | ADD_CUSTOM_COMMAND( 102 | OUTPUT libnfc.lib 103 | COMMAND dlltool -d ${CMAKE_CURRENT_SOURCE_DIR}/../contrib/win32/nfc.def -l ${CMAKE_CURRENT_BINARY_DIR}/libnfc.lib ${CMAKE_CURRENT_BINARY_DIR}/libnfc.dll 104 | DEPENDS nfc ${CMAKE_CURRENT_SOURCE_DIR}/../contrib/win32/nfc.def 105 | ) 106 | ADD_CUSTOM_TARGET(win32lib ALL DEPENDS libnfc.lib) 107 | 108 | # On Windows the shared (runtime) library should be either in the same 109 | # directory as the excutables or in the path, we add it to same directory 110 | INSTALL(TARGETS nfc RUNTIME DESTINATION bin COMPONENT libraries) 111 | 112 | # At compile time we need the .LIB file, we place it in the lib directory 113 | INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libnfc.lib DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries) 114 | ELSE(WIN32) 115 | INSTALL(TARGETS nfc LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries) 116 | ENDIF(WIN32) 117 | 118 | -------------------------------------------------------------------------------- /libnfc-1.7.1/utils/nfc-utils.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Free/Libre Near Field Communication (NFC) library 3 | * 4 | * Libnfc historical contributors: 5 | * Copyright (C) 2009 Roel Verdult 6 | * Copyright (C) 2009-2013 Romuald Conty 7 | * Copyright (C) 2010-2012 Romain Tartière 8 | * Copyright (C) 2010-2013 Philippe Teuwen 9 | * Copyright (C) 2012-2013 Ludovic Rousseau 10 | * See AUTHORS file for a more comprehensive list of contributors. 11 | * Additional contributors of this file: 12 | * 13 | * Redistribution and use in source and binary forms, with or without 14 | * modification, are permitted provided that the following conditions are met: 15 | * 1) Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2 )Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | * POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | * Note that this license only applies on the examples, NFC library itself is under LGPL 34 | * 35 | */ 36 | /** 37 | * @file nfc-utils.c 38 | * @brief Provide some examples shared functions like print, parity calculation, options parsing. 39 | */ 40 | #include 41 | #include 42 | 43 | #include "nfc-utils.h" 44 | 45 | uint8_t 46 | oddparity(const uint8_t bt) 47 | { 48 | // cf http://graphics.stanford.edu/~seander/bithacks.html#ParityParallel 49 | return (0x9669 >> ((bt ^ (bt >> 4)) & 0xF)) & 1; 50 | } 51 | 52 | void 53 | oddparity_bytes_ts(const uint8_t *pbtData, const size_t szLen, uint8_t *pbtPar) 54 | { 55 | size_t szByteNr; 56 | // Calculate the parity bits for the command 57 | for (szByteNr = 0; szByteNr < szLen; szByteNr++) { 58 | pbtPar[szByteNr] = oddparity(pbtData[szByteNr]); 59 | } 60 | } 61 | 62 | void 63 | print_hex(const uint8_t *pbtData, const size_t szBytes) 64 | { 65 | size_t szPos; 66 | 67 | for (szPos = 0; szPos < szBytes; szPos++) { 68 | printf("%02x ", pbtData[szPos]); 69 | } 70 | printf("\n"); 71 | } 72 | 73 | void 74 | print_hex_bits(const uint8_t *pbtData, const size_t szBits) 75 | { 76 | uint8_t uRemainder; 77 | size_t szPos; 78 | size_t szBytes = szBits / 8; 79 | 80 | for (szPos = 0; szPos < szBytes; szPos++) { 81 | printf("%02x ", pbtData[szPos]); 82 | } 83 | 84 | uRemainder = szBits % 8; 85 | // Print the rest bits 86 | if (uRemainder != 0) { 87 | if (uRemainder < 5) 88 | printf("%01x (%d bits)", pbtData[szBytes], uRemainder); 89 | else 90 | printf("%02x (%d bits)", pbtData[szBytes], uRemainder); 91 | } 92 | printf("\n"); 93 | } 94 | 95 | void 96 | print_hex_par(const uint8_t *pbtData, const size_t szBits, const uint8_t *pbtDataPar) 97 | { 98 | uint8_t uRemainder; 99 | size_t szPos; 100 | size_t szBytes = szBits / 8; 101 | 102 | for (szPos = 0; szPos < szBytes; szPos++) { 103 | printf("%02x", pbtData[szPos]); 104 | if (oddparity(pbtData[szPos]) != pbtDataPar[szPos]) { 105 | printf("! "); 106 | } else { 107 | printf(" "); 108 | } 109 | } 110 | 111 | uRemainder = szBits % 8; 112 | // Print the rest bits, these cannot have parity bit 113 | if (uRemainder != 0) { 114 | if (uRemainder < 5) 115 | printf("%01x (%d bits)", pbtData[szBytes], uRemainder); 116 | else 117 | printf("%02x (%d bits)", pbtData[szBytes], uRemainder); 118 | } 119 | printf("\n"); 120 | } 121 | 122 | void 123 | print_nfc_target(const nfc_target *pnt, bool verbose) 124 | { 125 | char *s; 126 | str_nfc_target(&s, pnt, verbose); 127 | printf("%s", s); 128 | nfc_free(s); 129 | } 130 | -------------------------------------------------------------------------------- /libnfc-1.7.1/libnfc/iso14443-subr.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Free/Libre Near Field Communication (NFC) library 3 | * 4 | * Libnfc historical contributors: 5 | * Copyright (C) 2009 Roel Verdult 6 | * Copyright (C) 2009-2013 Romuald Conty 7 | * Copyright (C) 2010-2012 Romain Tartière 8 | * Copyright (C) 2010-2013 Philippe Teuwen 9 | * Copyright (C) 2012-2013 Ludovic Rousseau 10 | * See AUTHORS file for a more comprehensive list of contributors. 11 | * Additional contributors of this file: 12 | * 13 | * This program is free software: you can redistribute it and/or modify it 14 | * under the terms of the GNU Lesser General Public License as published by the 15 | * Free Software Foundation, either version 3 of the License, or (at your 16 | * option) any later version. 17 | * 18 | * This program is distributed in the hope that it will be useful, but WITHOUT 19 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 21 | * more details. 22 | * 23 | * You should have received a copy of the GNU Lesser General Public License 24 | * along with this program. If not, see 25 | */ 26 | 27 | /** 28 | * @file iso14443-subr.c 29 | * @brief Defines some function extracted for ISO/IEC 14443 30 | */ 31 | 32 | #ifdef HAVE_CONFIG_H 33 | # include "config.h" 34 | #endif // HAVE_CONFIG_H 35 | 36 | #include 37 | #include 38 | 39 | #include 40 | #include "nfc-internal.h" 41 | 42 | 43 | /** 44 | * @brief CRC_A 45 | * 46 | */ 47 | void 48 | iso14443a_crc(uint8_t *pbtData, size_t szLen, uint8_t *pbtCrc) 49 | { 50 | uint8_t bt; 51 | uint32_t wCrc = 0x6363; 52 | 53 | do { 54 | bt = *pbtData++; 55 | bt = (bt ^ (uint8_t)(wCrc & 0x00FF)); 56 | bt = (bt ^ (bt << 4)); 57 | wCrc = (wCrc >> 8) ^ ((uint32_t) bt << 8) ^ ((uint32_t) bt << 3) ^ ((uint32_t) bt >> 4); 58 | } while (--szLen); 59 | 60 | *pbtCrc++ = (uint8_t)(wCrc & 0xFF); 61 | *pbtCrc = (uint8_t)((wCrc >> 8) & 0xFF); 62 | } 63 | 64 | /** 65 | * @brief Append CRC_A 66 | * 67 | */ 68 | void 69 | iso14443a_crc_append(uint8_t *pbtData, size_t szLen) 70 | { 71 | iso14443a_crc(pbtData, szLen, pbtData + szLen); 72 | } 73 | 74 | /** 75 | * @brief CRC_B 76 | * 77 | */ 78 | void 79 | iso14443b_crc(uint8_t *pbtData, size_t szLen, uint8_t *pbtCrc) 80 | { 81 | uint8_t bt; 82 | uint32_t wCrc = 0xFFFF; 83 | 84 | do { 85 | bt = *pbtData++; 86 | bt = (bt ^ (uint8_t)(wCrc & 0x00FF)); 87 | bt = (bt ^ (bt << 4)); 88 | wCrc = (wCrc >> 8) ^ ((uint32_t) bt << 8) ^ ((uint32_t) bt << 3) ^ ((uint32_t) bt >> 4); 89 | } while (--szLen); 90 | wCrc = ~wCrc; 91 | *pbtCrc++ = (uint8_t)(wCrc & 0xFF); 92 | *pbtCrc = (uint8_t)((wCrc >> 8) & 0xFF); 93 | } 94 | 95 | /** 96 | * @brief Append CRC_B 97 | * 98 | */ 99 | void 100 | iso14443b_crc_append(uint8_t *pbtData, size_t szLen) 101 | { 102 | iso14443b_crc(pbtData, szLen, pbtData + szLen); 103 | } 104 | 105 | /** 106 | * @brief Locate historical bytes 107 | * @see ISO/IEC 14443-4 (5.2.7 Historical bytes) 108 | */ 109 | uint8_t * 110 | iso14443a_locate_historical_bytes(uint8_t *pbtAts, size_t szAts, size_t *pszTk) 111 | { 112 | if (szAts) { 113 | size_t offset = 1; 114 | if (pbtAts[0] & 0x10) { // TA 115 | offset++; 116 | } 117 | if (pbtAts[0] & 0x20) { // TB 118 | offset++; 119 | } 120 | if (pbtAts[0] & 0x40) { // TC 121 | offset++; 122 | } 123 | if (szAts > offset) { 124 | *pszTk = (szAts - offset); 125 | return (pbtAts + offset); 126 | } 127 | } 128 | *pszTk = 0; 129 | return NULL; 130 | } 131 | 132 | /** 133 | * @brief Add cascade tags (0x88) in UID 134 | * @see ISO/IEC 14443-3 (6.4.4 UID contents and cascade levels) 135 | */ 136 | void 137 | iso14443_cascade_uid(const uint8_t abtUID[], const size_t szUID, uint8_t *pbtCascadedUID, size_t *pszCascadedUID) 138 | { 139 | switch (szUID) { 140 | case 7: 141 | pbtCascadedUID[0] = 0x88; 142 | memcpy(pbtCascadedUID + 1, abtUID, 7); 143 | *pszCascadedUID = 8; 144 | break; 145 | 146 | case 10: 147 | pbtCascadedUID[0] = 0x88; 148 | memcpy(pbtCascadedUID + 1, abtUID, 3); 149 | pbtCascadedUID[4] = 0x88; 150 | memcpy(pbtCascadedUID + 5, abtUID + 3, 7); 151 | *pszCascadedUID = 12; 152 | break; 153 | 154 | case 4: 155 | default: 156 | memcpy(pbtCascadedUID, abtUID, szUID); 157 | *pszCascadedUID = szUID; 158 | break; 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /libnfc-1.7.1/examples/nfc-dep-initiator.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Free/Libre Near Field Communication (NFC) library 3 | * 4 | * Libnfc historical contributors: 5 | * Copyright (C) 2009 Roel Verdult 6 | * Copyright (C) 2009-2013 Romuald Conty 7 | * Copyright (C) 2010-2012 Romain Tartière 8 | * Copyright (C) 2010-2013 Philippe Teuwen 9 | * Copyright (C) 2012-2013 Ludovic Rousseau 10 | * See AUTHORS file for a more comprehensive list of contributors. 11 | * Additional contributors of this file: 12 | * 13 | * Redistribution and use in source and binary forms, with or without 14 | * modification, are permitted provided that the following conditions are met: 15 | * 1) Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2 )Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | * POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | * Note that this license only applies on the examples, NFC library itself is under LGPL 34 | * 35 | */ 36 | 37 | /** 38 | * @file nfc-dep-initiator.c 39 | * @brief Turns the NFC device into a D.E.P. initiator (see NFCIP-1) 40 | */ 41 | 42 | #ifdef HAVE_CONFIG_H 43 | # include "config.h" 44 | #endif // HAVE_CONFIG_H 45 | 46 | #include 47 | #include 48 | #include 49 | #include 50 | 51 | #include 52 | 53 | #include "utils/nfc-utils.h" 54 | 55 | #define MAX_FRAME_LEN 264 56 | 57 | static nfc_device *pnd; 58 | static nfc_context *context; 59 | 60 | static void stop_dep_communication(int sig) 61 | { 62 | (void) sig; 63 | if (pnd != NULL) { 64 | nfc_abort_command(pnd); 65 | } else { 66 | nfc_exit(context); 67 | exit(EXIT_FAILURE); 68 | } 69 | } 70 | 71 | int 72 | main(int argc, const char *argv[]) 73 | { 74 | nfc_target nt; 75 | uint8_t abtRx[MAX_FRAME_LEN]; 76 | uint8_t abtTx[] = "Hello World!"; 77 | 78 | if (argc > 1) { 79 | printf("Usage: %s\n", argv[0]); 80 | exit(EXIT_FAILURE); 81 | } 82 | 83 | nfc_init(&context); 84 | if (context == NULL) { 85 | ERR("Unable to init libnfc (malloc)"); 86 | exit(EXIT_FAILURE); 87 | } 88 | 89 | pnd = nfc_open(context, NULL); 90 | if (pnd == NULL) { 91 | ERR("Unable to open NFC device."); 92 | nfc_exit(context); 93 | exit(EXIT_FAILURE); 94 | } 95 | printf("NFC device: %s\n opened", nfc_device_get_name(pnd)); 96 | 97 | signal(SIGINT, stop_dep_communication); 98 | 99 | if (nfc_initiator_init(pnd) < 0) { 100 | nfc_perror(pnd, "nfc_initiator_init"); 101 | nfc_close(pnd); 102 | nfc_exit(context); 103 | exit(EXIT_FAILURE); 104 | } 105 | 106 | if (nfc_initiator_select_dep_target(pnd, NDM_PASSIVE, NBR_212, NULL, &nt, 1000) < 0) { 107 | nfc_perror(pnd, "nfc_initiator_select_dep_target"); 108 | nfc_close(pnd); 109 | nfc_exit(context); 110 | exit(EXIT_FAILURE); 111 | } 112 | print_nfc_target(&nt, false); 113 | 114 | printf("Sending: %s\n", abtTx); 115 | int res; 116 | if ((res = nfc_initiator_transceive_bytes(pnd, abtTx, sizeof(abtTx), abtRx, sizeof(abtRx), 0)) < 0) { 117 | nfc_perror(pnd, "nfc_initiator_transceive_bytes"); 118 | nfc_close(pnd); 119 | nfc_exit(context); 120 | exit(EXIT_FAILURE); 121 | } 122 | 123 | abtRx[res] = 0; 124 | printf("Received: %s\n", abtRx); 125 | 126 | if (nfc_initiator_deselect_target(pnd) < 0) { 127 | nfc_perror(pnd, "nfc_initiator_deselect_target"); 128 | nfc_close(pnd); 129 | nfc_exit(context); 130 | exit(EXIT_FAILURE); 131 | } 132 | 133 | nfc_close(pnd); 134 | nfc_exit(context); 135 | exit(EXIT_SUCCESS); 136 | } 137 | --------------------------------------------------------------------------------