Commit Graph
82 Commits
Author SHA1 Message Date
iceman1001andClaude Opus 5 28d49510e2 hf mf: add RKF travel card parser
The RKF travel card (Resekortsföreningen i Norden) is the Nordic public
transport card, specified 2001-2002 on MIFARE Classic and deployed by
Västtrafik, SL Stockholm, Länstrafiken and the Danish Rejsekort.

Decodes the card issuer and support layers (CMI, TCCI, TCAS, TCDI) and
every application object the specification pins down: TCPU purse, TCEL
event log, TCDB, TCCP, TCST, and TCTI/TCCO through an identifier chain
walker covering all 18 data element groups. AID owners are named from
RKF-0019.

Three things the specification does not state, determined from 21 cards:

  - RKF-0022 7.7.1 calls the block checksum 'standard CRC-8' without
    naming the parameters. It is CRC-8/MIFARE-MAD, poly 0x1D init 0xC7,
    which the tree already ships as CRC8Mad().

  - The MAC trio is the final 24 bits of a MACed object. The RKF-0023
    tables list Free (bits) as a trailing summary row, which reads as if
    the authenticator follows a gap after the key identifier; it does
    not. Measured on the fact that MACAlgorithmIdentifier must be 0:
    TCST 42/42 against 15/42, TCCP 20/20 against 13/20.

  - TCPU version 4 drops EndDate and moves Value to bit 16.

Cards reporting a version other than 2 are flagged, and a MAC algorithm
the specification does not define is reported as a layout failure rather
than printed as data.

MAC values are not verified. The master key is in RKF-0018, which was
never published. des_mac() is added to libpcrypto for when that changes,
with the FIPS 113 worked example as its test.

Verified against a Danish Rejsekort whose provenance notes give the
purchase timestamp, card number and balance; the parser reproduces all
three. 48 self test checks on 'hf mf view --selftest', no false
positives across 460 local dumps.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-22 11:14:44 +02:00
iceman1001 2b51280725 apply some style and consts 2026-06-29 22:42:37 +02:00
iceman1001 cbb572afad style 2026-05-11 14:36:17 +02:00
kormax 1167bd9701 Decompose utils from duox-related code 2026-05-05 18:27:19 +03:00
kormax fa414f3b65 Implement 'hf mfd verifycert' command 2026-05-04 22:07:33 +03:00
Benjamin DELPY 12bf5cc0f6 Update originality.c to add ICODE 3 in ICODE public key description
Signed-off-by: Benjamin DELPY <benjamin@gentilkiwi.com>
2026-04-30 22:50:26 +02:00
kormax 63848f24ea Add pcrypto_rng_fill_oneshot util 2026-04-28 16:55:03 +03:00
kormax 67db3b15c6 Support compressed public EC points 2026-04-16 23:57:30 +03:00
kormax f99af1b706 Add crypto helper methods for loading public EC keys of various formats 2026-04-16 23:30:37 +03:00
iceman1001 ad82c50158 enforce NULL checks after all malloc, calloc, realloc 2026-03-29 10:20:30 +07:00
iceman1001 000d086d59 text 2026-03-29 09:41:46 +07:00
kormax ec3b249d30 Remove redundant methods from Aliro/VAS, make private key load helpers universal 2026-03-15 10:08:30 +02:00
kormax c8a4314353 Add hf gst commands 2026-03-14 17:34:58 +02:00
Philippe Teuwen 7c4758f40b ulaes: add verify_cmac, display counters in mfu info, fix sig when schann in mfu info 2026-02-09 12:44:50 +01:00
Philippe Teuwen fdf3b2690a Various fixes to content GCC 16... 2026-02-07 00:51:53 +01:00
Philippe Teuwen f278633f51 NTAG21x Pk reused on NTAG 5... 2025-09-22 23:30:49 +02:00
Philippe Teuwen efb808c385 basic support for NTAG 223/224 2025-09-10 23:45:29 +02:00
Philippe Teuwen 948dce9230 new pk 2025-07-31 15:00:24 +02:00
iceman1001 0dc80263e8 add aes256 2025-07-13 11:03:20 +02:00
iceman1001 79400d0779 text and style 2025-06-17 18:28:22 +02:00
iceman1001 ad292e8810 unify test - step 2 2025-03-25 10:17:42 +01:00
iceman1001 4d603a4530 unify hint text 2025-03-20 22:55:26 +01:00
iceman1001 cef07dedf6 code style, code clean up of redundant functions, comments, its many minor fixes across the platform. Sorry for not making 20 commits 2025-02-21 15:38:33 +01:00
iceman1001 778ede25e7 renamed lua scripts. minor adaptations 2025-02-17 21:24:09 +01:00
iceman1001 6af2df51bf style 2025-01-14 16:40:22 +01:00
iceman1001 17338e2a5f style 2024-12-31 23:35:16 +01:00
Philippe Teuwen 59ae5d2285 hf 15 info: show all type matches and check ST25TVxC signature 2024-12-15 20:54:28 +01:00
Philippe Teuwen be79654eb9 Add initial support for ST25TN and its signature verification 2024-12-15 17:14:41 +01:00
Philippe Teuwen a4b595c79b got DESFire Light with that pk... 2024-12-15 15:14:17 +01:00
Philippe Teuwen c9f2c17841 relax ecdsa_publickey_ng_t, should help MacOS compilation 2024-12-14 14:53:08 +01:00
Philippe Teuwen f26727eb28 Refactor originality checks. Notes:
- removed pk "NTAG424DNA, NTAG424DNATT, DESFire Light Ev2", "04B304...3B" which is a typo of "DESFire Ev2", "04B3...3A"},
- MIKRON pk currently not used because I don't know if it's for MFC, MFUL or sth else
- ST25TN pk added but currently not used, need to be implemented/tested
- ST25TV pk currently not used, need to be implemented/tested
2024-12-14 14:29:50 +01:00
iceman1001 72900d1bf9 fix and style 2024-09-06 22:36:44 +02:00
iceman1001 c8849af5e0 This is the major changes made to the HITAG2 commands. Its heavly based on RFIDLers implementation and its been converted to work with Proxmark3. Special thanks to @kevsecurity for his amazing implementations of the Gone in 360 Seconds paper by Roel, Flavio & Balasch. Thanks to @adamlaurie for his RFIDler project. It wouldnt been doable without it. 2024-04-22 16:20:24 +02:00
iceman1001 2ccf84f40a use a local str_nlen fct instead of hinting to POSIX 2023-11-05 02:08:30 +01:00
iceman1001 185da09e62 we use calloc 2023-10-18 20:20:55 +02:00
iceman1001 0e84860c2f less inline calls 2023-08-03 08:42:52 +02:00
Philippe Teuwen 1a19640d18 make style 2023-07-21 18:22:46 +02:00
iceman1001 89e6f88522 add asn1 selftest batch 2023-07-21 06:40:26 +02:00
Grayson Martin 1e54cd661c make style 2023-07-08 18:18:36 -05:00
Grayson Martin 945f03e646 add import, oops 2023-07-08 18:18:35 -05:00
Grayson Martin 610b8a7410 Implement ANSI X9.63 sha256 per spec 2023-07-08 18:18:34 -05:00
AloneLiberty fae8ffda44 Fix formatting and run make style 2023-03-26 16:12:39 +03:00
iceman1001 aa05e2eeae textual and cleanup 2023-03-21 20:55:57 +01:00
iceman1001 69e43b362e fix asn1 parsing of dates 2023-03-19 12:47:24 +01:00
iceman1001 1cc19c3429 asn1 decoder now handles big integers 2023-03-13 22:09:30 +01:00
iceman1001 04173fc961 added bit string printing in ASN1 decoder 2023-03-13 21:36:59 +01:00
iceman1001 d11d1fbc33 data asn1 now decodes timestamp correct... Or I hope so. And strings values are now highlighted with GREEN 2023-03-12 19:18:55 +01:00
iceman1001 4a7713070b fix object strings. Integers is now 64b which isnt enough. Will need to use big_num here 2023-03-12 18:59:53 +01:00
iceman1001 5938938226 print the string and hex 2023-03-12 18:54:53 +01:00
merlokk 9fa8d9175b make style 2022-07-08 00:19:26 +03:00