libfreefare/test
Robert Quattlebaum ec91014ebf Properly handle edge cases in AN10922 key diversification
This commit fixes issue #91.

[AN10922][] specifies the key diversification algorithms used by the
MIFARE SAM AV3. Support for these algorithms was added to
`libfreefare` via pull-request #79.

However, while every attempt was made to write a faithful
implementation, the implemented code did not properly handle cases
where the diversification data was less than or equal to the block
size of the cipher: 16 bytes for AES, and 8 bytes for DES. This
bug was identified in issue #91.

This commit addresses this problem while providing a way to revert to
the previous behavior in cases where it is necessary to maintain
previous deployments. This was accomplished by introducing a new
`flags` parameter to the `mifare_key_deriver_new_an10922` method.

Normally, `flags` should simply be set to `AN10922_FLAG_DEFAULT`.
However, if the previous behavior is required, it should be set to
`AN10922_FLAG_EMULATE_ISSUE_91`.

[AN10922][] does not include any test vectors that might have helped to
identify this problem earlier. However, [AN10957][] (pages 13-14) was
found to have a suitable example usage of [AN10922][] with an
appropriately short value for *M* that we are using as a test vector
to verify correct behavior.

Note that the issue being addressed here is not a security issue:
using the `AN10922_FLAG_EMULATE_ISSUE_91` should not be any less
secure than using `AN10922_FLAG_DEFAULT`.

[AN10922]: https://www.nxp.com/docs/en/application-note/AN10922.pdf
[AN10957]: https://www.nxp.com/docs/en/application-note/AN10957.pdf
2019-10-29 11:21:56 -07:00
..
common Remove copyright comments. 2017-06-29 09:29:15 +02:00
felica_fixture.c Deduplicate fixture headers. 2017-06-29 09:29:15 +02:00
fixture.h Fix issues for NTAG21x tags 2018-03-09 23:19:30 +01:00
Makefile.am Support for AN10922 key derivation 2018-01-08 22:08:37 -08:00
mifare_classic_fixture.c Deduplicate fixture headers. 2017-06-29 09:29:15 +02:00
mifare_desfire_ev1_fixture.c Deduplicate fixture headers. 2017-06-29 09:29:15 +02:00
mifare_desfire_fixture.c Deduplicate fixture headers. 2017-06-29 09:29:15 +02:00
mifare_ultralight_fixture.c Deduplicate fixture headers. 2017-06-29 09:29:15 +02:00
run-test.sh Build test then run them 2017-06-26 13:17:37 +02:00
test_felica.c Deduplicate fixture headers. 2017-06-29 09:29:15 +02:00
test_freefare.c Run make style to fix style 2017-06-27 13:58:31 +02:00
test_mad.c Remove copyright comments. 2017-06-29 09:29:15 +02:00
test_mifare_application.c Remove copyright comments. 2017-06-29 09:29:15 +02:00
test_mifare_classic.c Deduplicate fixture headers. 2017-06-29 09:29:15 +02:00
test_mifare_classic_create_trailer_block.c Remove copyright comments. 2017-06-29 09:29:15 +02:00
test_mifare_classic_mad.c Deduplicate fixture headers. 2017-06-29 09:29:15 +02:00
test_mifare_classic_sector_boundaries.c Remove copyright comments. 2017-06-29 09:29:15 +02:00
test_mifare_desfire.c Run make style to indent macros 2017-06-29 12:25:53 +02:00
test_mifare_desfire_aes.c Remove copyright comments. 2017-06-29 09:29:15 +02:00
test_mifare_desfire_aid.c Remove copyright comments. 2017-06-29 09:29:15 +02:00
test_mifare_desfire_des.c Remove copyright comments. 2017-06-29 09:29:15 +02:00
test_mifare_desfire_ev1.c Run make style to indent macros 2017-06-29 12:25:53 +02:00
test_mifare_desfire_ev1_3des.c Run make style to indent macros 2017-06-29 12:25:53 +02:00
test_mifare_desfire_ev1_3k3des.c Run make style to indent macros 2017-06-29 12:25:53 +02:00
test_mifare_desfire_ev1_aes.c Run make style to indent macros 2017-06-29 12:25:53 +02:00
test_mifare_desfire_ev1_iso.c Run make style to indent macros 2017-06-29 12:25:53 +02:00
test_mifare_desfire_key.c Additional MifareDesfireKey fixes + tests 2018-01-08 09:23:07 -08:00
test_mifare_key_deriver_an10922.c Properly handle edge cases in AN10922 key diversification 2019-10-29 11:21:56 -07:00
test_mifare_ultralight.c mifare-ultralight: Added mifare_ultralightc_set_key() 2018-01-06 08:19:00 -08:00
test_tlv.c Remove copyright comments. 2017-06-29 09:29:15 +02:00