1 (edited by romain 2010-07-13 09:44:13)

Topic: [Call for Testers] Announcing Mifare DESFire support in libfreefare!

Good news everyone! The Mifare DESFire support in libfreefare [1] is complete! While some polishing is still required before merging the -desfire branch into libfreefare's trunk and releasing the updated code, I am confident enough in the implementation to do a call for testers!

How to test?

If you would like to give libfreefare's Mifare DESFire support a try:

svn co https://nfc-tools.googlecode.com/svn/branches/libfreefare-desfire
cd libfreefare-desfire
autoreconf -is
./configure --prefix="/usr"
make
make install

Then you can read the mifare_desfire(3) man page, and have a look to the examples and the unit test suite to get started.

What to test ?

Well, actually I only ported a regression test suite (supposed to be inspired by some code from NXP) to cutter [2] to check my implementation, and since I only own a single Mifare DESFire 4K card, I only have tested with it.

I would be interested in feedback about building the software on other platforms (I run FreeBSD-8 amd64), running the regression test suite, using Mifare DESFire 2K / 8K, your experiments results, etc…

I have to mention that I had some trouble when using a Snapper Feeder and the problem has been reported to Snapper, but the problem might be tied to this reader or at the chip the device uses since I could not reproduce it on a touchatag device, so if the communication with the tag stops unexpectedly at random locations, please try with another device and report the issue.


Due credits:
This work was sponsored by IL4P [3] the Mifare DESFire tag was donated by SpringCard [4].

Thank you for your feedback!

Romain

References:
  1. http://code.google.com/p/nfc-tools/wiki/libfreefare
  2. http://cutter.sourceforge.net/
  3. http://www.il4p.fr/
  4. http://www.springcard.com/

Re: [Call for Testers] Announcing Mifare DESFire support in libfreefare!

Great work Romain!

It is nice to see that related projects seem to get more and more body every day smile
Maybe I can help you in the future with some new cards (like the Plus and the Ultralight C).

Cheers,

  Roel

3 (edited by bigjay 2010-07-15 21:32:52)

Re: [Call for Testers] Announcing Mifare DESFire support in libfreefare!

Hi Romain!

I have 2 DESfire Cards and a touchatag reader and was really curious to see what can be done with them.
So i tried your software, but "make" didn't work. It exited with:

../libfreefare/.libs/libfreefare.so: undefined reference to `htole16'
../libfreefare/.libs/libfreefare.so: undefined reference to `le16toh'
collect2: ld returned 1 exit status
make[2]: *** [mifare-classic-format] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

My C-skills are pretty non existant. So I don't know what to do.

I am using Ubuntu 10.04 (amd64) and the "normal" libfreefare (Revision 462) compiles without problems.
Hope that helps.

Greetings

Re: [Call for Testers] Announcing Mifare DESFire support in libfreefare!

Hi bigjay.

This error is related to endianness conversion functions: FreeBSD provides a set of functions, OpenBSD another one, and old GNU libc does not provide such macros.  Since there is no POSIX solution that would work everywhere, there is some glue in <freefare_internal.h> so I updated it.

If you update at revision 463 it should be okay.
http://code.google.com/p/nfc-tools/source/detail?r=463

Please note that I changed something I think was wrong regarding endianness on 32bit values in that glue. These functions are used in Mifare Classic value management functions, so if you use them, I utterly recommand checking it works using the regression test suite.  I have no spare machine ATM to test if it is okay unfortunately, so feedback would be really appreciated.

Thanks!
Romain

Re: [Call for Testers] Announcing Mifare DESFire support in libfreefare!

Thanks roel!

I would be happy to add support for new tags in libfreefare, and invite anybody who has documentation, samples, etc. to get in touch with me by private mail.  The short-term plans are:

  1. Ensure the Mifare DESFire support is complete (hence this topic);

  2. Merge and release the Mifare DESFire support in libfreefare's trunk;

  3. Add support for tags with random UID (e.g. Mifare DESFire EV1);

Re: [Call for Testers] Announcing Mifare DESFire support in libfreefare!

Wow, that was fast, man!!!

Thanks a lot. All compiles well - no errors :-D

It's really late here, so i will continue testing tomorrow/today.

Thanks again for the fast action!

Re: [Call for Testers] Announcing Mifare DESFire support in libfreefare!

Hello,

Nice job Romain ;-)

As you already know, I have tested on Debian Squeeze (up-to-date on 19 Jul 2010) with amd64 architecture.
With the SVN revision r471, I ran

make check

with a Touchatag reader:

  • one DESFire 4k, OK

  • one DESFire 4k EV1, OK

  • one DESFire 8k EV1, OK

  • one DESFire 2k EV1, 2 failures, KO (tests are probably designed to run on 4k : http://pastebin.com/6CRB1TJr)

romain wrote:

I have to mention that I had some trouble when using a Snapper Feeder and the problem has been reported to Snapper, but the problem might be tied to this reader or at the chip the device uses since I could not reproduce it on a touchatag device, so if the communication with the tag stops unexpectedly at random locations, please try with another device and report the issue.

I experiment a similar problem with an SCM SCL3711 which is a PN533 connected in USB. I expect that there is a problem in PN53x_USB driver in libnfc.

BTW, that's a great enhancement !

Romuald Conty

Re: [Call for Testers] Announcing Mifare DESFire support in libfreefare!

Hey!

rconty wrote:

As you already know, I have tested on Debian Squeeze (up-to-date on 19 Jul 2010) with amd64 architecture.
With the SVN revision r471, I ran

make check

with a Touchatag reader:

  • one DESFire 4k, OK

  • one DESFire 4k EV1, OK

  • one DESFire 8k EV1, OK

  • one DESFire 2k EV1, 2 failures, KO (tests are probably designed to run on 4k : http://pastebin.com/6CRB1TJr)

Yep, it looks like it is the problem: I only have a 4K card and I have not added a test such as the one in the Mifare Classic MAD tests to avoid manipulations of the card beyond it's capacity: the first test fails because the card is OOM (it tries to create a record file with 22 repords of 100 bytes each → 2200 > 2048) and the card is left with a master key the second test does not know so it fails too when authenticateing on an assumed blank card.

We can either reduce the numbre of records we store or ensure the card is large enougth to run the test suite.

Thanks for the feedback!

Re: [Call for Testers] Announcing Mifare DESFire support in libfreefare!

hi, my problem is ltmain.sh is missing!
I check with libtoolize and other ways but i dont pass these point

all those links aren´t working well:
http://forums.freebsd.org/showthread.php?t=11596
http://www.gnu.org/software/libtool/man … found.html
http://cygwin.ru/ml/automake/2002-09/msg00089.html


my output is:

guepardo libfreefare-desfire # autoreconf -is
configure.ac:8: required file `../ltmain.sh' not found
autoreconf: automake failed with exit status: 1

Consequently,subsequent "configure +make" runs fail

any suggestion?¿

developing the future!

Re: [Call for Testers] Announcing Mifare DESFire support in libfreefare!

Hello,

*dudux wrote:

any suggestion?

Yep, run autoreconf in verbose mode:

autoreconf -vis
Romuald Conty

Re: [Call for Testers] Announcing Mifare DESFire support in libfreefare!

the same.......

guepardo libfreefare-desfire # autoreconf -vis
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal -I m4
autoreconf: configure.ac: tracing
autoreconf: running: libtoolize
autoreconf: running: /usr/bin/autoconf
autoreconf: running: /usr/bin/autoheader
autoreconf: running: automake --add-missing --no-force
configure.ac:8: required file `../ltmain.sh' not found
autoreconf: automake failed with exit status: 1
guepardo libfreefare-desfire #
developing the future!

Re: [Call for Testers] Announcing Mifare DESFire support in libfreefare!

*dudux wrote:

the same.......

Not exactly: you have more information about autoreconf run and I didn't except more from that command...

Could you report your version of autoreconf, autoconf, autoheader, automake and libtoolize ?
Which is your platform ?

configure.ac:8: required file `../ltmain.sh' not found
autoreconf: automake failed with exit status: 1
guepardo libfreefare-desfire #

The dot-dot-slash before ltmain.sh sounds strange... How did you install libtool ?

Could you try with a fresh fetch of libfreefare-desfire ?

Romuald Conty

13 (edited by *dudux 2010-07-23 07:31:03)

Re: [Call for Testers] Announcing Mifare DESFire support in libfreefare!

Hi,rconty
you are right! not is the same!

my version of.....
autoreconf,autoheader ,automake,autoconf  is
(GNU Autoconf) 2.65
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+/Autoconf: GNU GPL version 3 or later

and  libtoolize
libtoolize (GNU libtool) 2.2.6b

my system is debian , and i installed libtool with "apt-get" if dont remember  bad!

developing the future!

Re: [Call for Testers] Announcing Mifare DESFire support in libfreefare!

Hi *dudux.

Check that the ltmain.sh file does not already exists with wrong permission or is a dead symlink.  If unsure, extract another copy of the repository.

While unlikely, your libtool install may be broken.  The ltmain.sh script is installed in ${prefix}/share/libtool/config/ on my system, I guess it is basically the same for you.  Ensure you can find the script and try to purge and install again the package.

Re: [Call for Testers] Announcing Mifare DESFire support in libfreefare!

Hello,

I checked out the latest version yesterday. Autoreconf and configure give no errors at all but when I execute the "make" command I receive the following errors:

make[2]: Entering directory `/home/benoit/Desktop/libfreefare/examples'
  CCLD   mifare-classic-format
../libfreefare/.libs/libfreefare.so: undefined reference to `nfc_initiator_deselect_target'
../libfreefare/.libs/libfreefare.so: undefined reference to `nfc_initiator_select_passive_target'
collect2: ld returned 1 exit status

Any thoughts?

Re: [Call for Testers] Announcing Mifare DESFire support in libfreefare!

Hi

The code source in libfreefare's trunk is expected to build aganist the libnfc trunk.  As of r452 of libnfc, the API has been enhanced [1] and so it's the new API that the libfreefare uses.

Checkout and build libnfc's trunk [2] and it should be okay ;-)

We are planning to release a new libnfc version in a few weeks, we would then tag and release a new libfreefare version, allowing you to use official releases instead of checking out the projects' trunk.  Stay tuned!

Regards,
Romain

References:
  1. http://code.google.com/p/libnfc/source/detail?r=452
  2. http://code.google.com/p/libnfc/source/checkout

Re: [Call for Testers] Announcing Mifare DESFire support in libfreefare!

That's very usefull information!
Only problem now is when I compiled the latest revision of libnfc I get the following error:

nfc-list: error while loading shared libraries: libnfc.so.0: cannot open shared object file: No such file or directory

I received no errors at all during compilation and I used the same procedure as before ...

Re: [Call for Testers] Announcing Mifare DESFire support in libfreefare!

Hi

Looks like the binary can't find the library.  If you are running the program from the source code directory, (./example/nfc-list) it should definitively work since it is just a shell script that setup the LD_LIBRARY_PATH correctly (./libnfc/.libs/) before running the actual program (./example/.libs/nfc-list).  This is supposed to work regardless of any installation of the libnfc in any prefix.

If you are running an installed binary, you can check using ldd(1) the location of the libraries the dynamic libraries linker will use when running the program:

romain% ldd `which nfc-list`
/usr/local/bin/nfc-list:
    libnfc.so.0 => /usr/local/lib/libnfc.so.0 (0x800748000)
    libpcsclite.so.1 => /usr/local/lib/libpcsclite.so.1 (0x800953000)
    libusb.so.2 => /usr/lib/libusb.so.2 (0x800a5e000)
    libc.so.7 => /lib/libc.so.7 (0x800b6e000)
    libthr.so.3 => /lib/libthr.so.3 (0x800daf000)

It will also tell you what libraries it can't find.  Common causes are prefix problems, for example the library is installed in the /usr/local/lib directory while the system looks for the library in /lib and /usr/lib only on GNU/Linux.  You can try to remove the libnfc installed files, run ./configure using a sane prefix (--prefix=/usr) build and install the library again.

Re: [Call for Testers] Announcing Mifare DESFire support in libfreefare!

Great! I got it al working now.
Is there already some more documentation or sample code available by now?
A pastebin with sample code of the most common functions with some comments would be awesome!

Re: [Call for Testers] Announcing Mifare DESFire support in libfreefare!

\o/ cool!

Well, there are no real-world application I am aware of (yet), but you can find quick'n'dirty examples in the libfreefare's "examples" directory, a more complete use of all the API in the test/test_mifare_desfire.c file (100% coverage actualy), and an overview of the API is available through the man pages.

Feel free to ask questions / send patches / suggest enhancements if something is not clear, so that the next official libfreefare release, introducing Mifare DESFire targets support, be even more awesome !:-)

Thanks!

Re: [Call for Testers] Announcing Mifare DESFire support in libfreefare!

Hi romain,

Thanks for the Desfire support. I am facing a problem with write file command to desfire card EV1.

write command (Length:38): 0x=3d 0f 00 00 00 1e 00 00 53 6f 6d 65 20 64 61 74 61 20 74 6f 20 77 72 69 74 65 20 74 6f 20 74 68 65 20 63 61 72 64 -- ("Some data to write to the card")

The error is always 7e (Invalid command string length). I also get the same error message for read file command.

read_cmd(Length:8):  0x=bd 0f 00 00 00 00 00 00

Could you please help me here? Thanks in advance.

Regards,
Skay

Re: [Call for Testers] Announcing Mifare DESFire support in libfreefare!

Hi skay

I am on another project right now (LLCP) but will hopefuly have some time to give it a look next month.  May I kindly ask you to fill-in an issue with a simple test-case that builds against libfreefare's trunk so that I can jump into the problem quickly as soon as I get some time to manage it?

http://code.google.com/p/nfc-tools/issues/entry

Thanks!