Commit graph

67 commits

Author SHA1 Message Date
Romuald Conty
dd1315321d Update to current libnfc devel API.
libnfc changed its nfc_initiator_transceive_bytes(): it now takes a const size_t used as maximal allowed rx bytes.
libnfc now checks if rx buffer is large enough to get the full response, so libfreefare should take care about whole size of its buffers.
2012-06-01 21:26:01 +00:00
Ludovic Rousseau
a6675eda70 Update write_data() prototype so that the data buffer is constant 2012-05-18 16:32:47 +00:00
Ludovic Rousseau
71a5295e7d Fix compiler warnings
mifare_desfire.c:196: warning: no previous prototype for
'madame_soleil_get_read_communication_settings'
mifare_desfire.c:210: warning: no previous prototype for
'madame_soleil_get_write_communication_settings'
mifare_desfire.c:642: warning: no previous prototype for
'create_application'
2012-05-18 16:30:45 +00:00
Ludovic Rousseau
4a15097d15 Update mifare_desfire_write_data() and mifare_desfire_write_data_ex()
prototypes so that the data buffer is constant
2012-05-18 16:26:37 +00:00
Romain Tartiere
07c5c78a8e Fix wrong variable usage. 2012-05-14 13:58:06 +00:00
Audrey Diacre
4f0227ddcb update to use libnfc's trunk 2012-01-25 09:58:16 +00:00
Romain Tartiere
0a7ce855b8 Sync w/ libnfc-1.5.1. 2011-09-22 13:05:07 +00:00
Romain Tartiere
0f32259ee2 Return error if something bad happen in mifare_cryto_preprocess_data() / mifare_cryto_postprocess_data().
Fixes issue 60.

PR:		Issue 60
Submitted by:	ervin.kaljola
2011-04-23 16:01:05 +00:00
Romain Tartiere
ec16eb5572 Fix mifare_desfire_create_value_file().
Fixes issue 59
Committed, thanks!

PR:		Issue 59
Submitted by:	ervin.kaljola
2011-04-23 15:31:45 +00:00
Romain Tartiere
b6cbeb2e20 Fix invalid test. 2011-03-26 13:50:21 +00:00
Romain Tartiere
f27352180c Complete ISO 7816 compatibility for Mifare DESFire EV1
Fixes issue 37
2011-03-26 13:22:48 +00:00
Romain Tartiere
b41f93cd5b Start support of ISO files for Mifare DESFire EV1.
Fixes issue 57
New API functions:
  * mifare_desfire_create_application_iso()
  * mifare_desfire_create_application_3k3des_iso()
  * mifare_desfire_create_application_aes_iso()
  * mifare_desfire_get_df_names()

Plus unit test to check this.
2011-03-25 16:49:36 +00:00
Romain Tartiere
c7dc9f0ccc New API functions mifare_desfire_create_application_3k3des(), mifare_desfire_create_application_aes().
Update issue 37
Only ISO application creation as requested by Issue 57 is lacking now.
2011-03-25 13:00:24 +00:00
Romain Tartiere
22e9854995 Do not abort on crypto error.
Because in some circumstances the crypto is skipped regardless of the
communication settings by the Mifare DESFire (e.g. when reading a file which is
writable with any key), do not abort if the crypto fail, and make it possible
to the user to catch such an event to fix his code accordingly.

Only display crypto diagnostic if compiled with debug support.
2011-02-13 14:13:35 +00:00
Romain Tartiere
f418845fb4 Make mifare_desfire_authenticate() a bit more magic.
If the provided key is a 3K3DES key, authenticate in ISO mode.  If the key is
an AES one, authenticate in AES mode.  This sugar should help third party
applications to handle authentication in a more generic way.
2010-12-31 12:47:55 +00:00
Romain Tartiere
c2cc0ba53d Move away global variables. 2010-12-31 10:53:05 +00:00
Romain Tartiere
899ed3d7bb Fix create_file2().
ECOPYPASTETOOFAST | EBADLUCKITSVALID: The argument communication_settings is
not to be used to construct the parameters passed to the crypto functions
mifare_cryto_preprocess_data() & mifare_cryto_postprocess_data(), but only for
building the frame.
2010-12-29 22:18:30 +00:00
Romain Tartiere
8caa2da31e Fix write_data() return value when data is enciphered.
We only have to return the number of bytes of raw data which are sent.
2010-12-29 22:05:08 +00:00
Romain Tartiere
2750ed668c Fix usage of a potentially reallocated memory area. 2010-12-29 21:44:26 +00:00
Romain Tartiere
9a4b7b5882 New API function mifare_desfire_set_ats(). 2010-12-24 22:08:56 +00:00
Romain Tartiere
adbba0342b New API function mifare_desfire_set_default_key(). 2010-12-24 20:41:43 +00:00
Romain Tartiere
e587e26aeb Rename some internal functions.
A function with DES in its name that can perform AES crypto is somewhat
disturbing.
2010-12-24 14:10:44 +00:00
Romain Tartiere
01fff97d6c Add support for ISO authentication with 3DES keys. 2010-12-24 13:04:16 +00:00
Romain Tartiere
0d8a53308c Change the mifare_cbc_des() internal function prototype. 2010-12-24 11:41:15 +00:00
Romain Tartiere
dd5156a997 Reindent. 2010-12-18 13:32:05 +00:00
Romain Tartiere
b300ef5fcf Update the MifareDirection structure for consistency. 2010-12-18 03:11:05 +00:00
Romain Tartiere
ebd98b32e0 Switch from obscure 'int mac' argument to 'MifareCryptoOperation operation'. 2010-12-18 03:07:16 +00:00
Romain Tartiere
d098bf623f Add support for authentication using 3K3DES.
Please note that according to the NXP documentation of the Mifare DESFire EV1,
the mifare_desfire_authenticate_iso() function can be used using either 3DES or
3K3DES keys.  The former has not been tested yet and is likely not to work. To
word it differently, this is a 3K3DES crypto support, not a ISO authentication
support...
2010-12-18 02:28:27 +00:00
Romain Tartiere
373cb4f0ef Rewrite some tests using switch statements.
Add a note for the reason I do this in the HACKING file.
2010-12-18 02:07:56 +00:00
Romain Tartiere
48b161d67c Invalidate authentication when changing the currently used key. 2010-12-18 01:32:56 +00:00
Romain Tartiere
143042fb0b Remove weird code.
I should quit coding drunk... or maybe start to...
2010-12-18 01:09:30 +00:00
Romain Tartiere
a6e52db696 Workaround invalid write in read_data () (sic)
This has to be improved to some extend in the near future (hence the FIXME).
2010-12-18 01:05:35 +00:00
Romain Tartiere
5b55528008 Silent down the compiler.
The create_application() function has iso_ parameters for creating ISO
application but this mode is not available yet so the code is unused which
annoys the compiler when told to be somewhat strict.
2010-12-17 22:47:12 +00:00
Romain Tartiere
0a9a964c17 Fix a brunch of potentially reallocated memory areas. 2010-12-15 13:40:58 +00:00
Romain Tartiere
94bf8d83c6 Fix mifare_desfire_get_key_version() when authenticated with an AES key. 2010-12-15 13:34:15 +00:00
Romain Tartiere
3fd80a3eff Enable the mifare-desfire-ev1-configure-random-uid example. 2010-12-15 13:19:42 +00:00
Romain Tartiere
b91080ffc7 Fix mifare_desfire_free_mem(). 2010-12-15 12:51:22 +00:00
Romain Tartiere
42f9457d9f Add support for Mifare DESFire EV1 with AES encryption. 2010-12-15 12:43:31 +00:00
Audrey Diacre
1070d9bfde fix buffer overflow. 2010-12-13 10:56:27 +00:00
Audrey Diacre
5133491c2c replace deprecated bzero function by memset. 2010-12-10 17:10:12 +00:00
Romain Tartiere
0e2bc992bf Discard authentication information after deleting the currently selected application. 2010-12-10 14:30:28 +00:00
Romain Tartiere
e0a28547fd Reset session key in mifare_desfire_select_application().
For Mifare DESFire EV1 support, we need to know when the user has called
mifare_desfire_select_application() after being authenticated and before
authenticated again.
2010-11-23 01:15:27 +00:00
Romain Tartiere
a643e9149d Add an offset parameter to mifare_cryto_preprocess_data()
Some cryptographic operations are performed on the whole data frame and not
only the payload with Mifare DESFire EV1.  The solution for now is not perfect,
(one new macro wrapping another big macro) but makes the code a bit easier to
read, and with the MIFARE_DESFIRE macro rewriting as a function (at some point
in the future), the whole should be bearable :-)
2010-11-20 14:10:27 +00:00
Romain Tartiere
16ae154b42 Don't swap the status byte in the received data.
This have been done for consistency with other targets support, but
cryptographic operations with Mifare DESFire EV1 tags would require to swap
again this byte because MACing is performed on the following data (in this
order):
  - Plain data
  - Status
  - Padding
2010-11-20 02:22:37 +00:00
Romain Tartiere
f94c3c743f Rely on RAND_bytes() instead of DES_random_key() to generate random vectors. 2010-10-29 18:58:34 +00:00
Romain Tartiere
5b416ee508 Fix a regression introduced at r643. 2010-10-29 18:53:49 +00:00
Romain Tartiere
d9b2deebe2 Rework error reporting infrastructure. 2010-10-29 13:10:23 +00:00
Romain Tartiere
356219e21b Require the ivect to be provided to mifare_cbc_des().
- Store ivect in the struct mifare_desfire_tag;
- Reset it before and after authentication;
- Reset before each crypto operation (for now).
2010-10-29 12:22:47 +00:00
Romain Tartiere
13f03a60bb Change rol8() to rol() to work with buffers of any length. 2010-10-29 12:01:57 +00:00
Romain Tartiere
688d083f63 Fix build with recent libnfc API breakage. 2010-10-15 12:58:29 +00:00