Top «Prev(2009-11-30) Latest Next(2010-01-02)» Edit

pterjan's diary


2009-12-21

  Navigo card decoding

After buying the card reader, I had to use it, so I had a look at the content of my Navigo card.

Navigo is a French transport card, implementing Calypso standard

« The European standard for ticketing data (EN1545) has also been contributed by the actors of Calypso. After a few years of trials, the system has been generalised in the early 2000's in major European cities such as Lisbon, Paris, Venice, later followed by Milan, Porto, Marseille, Lyon, Turin, and many smaller cities. Calypso is extended now in other countries such as Belgium, Israel, Canada, Mexico, Colombia, etc. »

So, hopefuly this info will be useful to people in these places. Please let me know :)

Seat in Bois-Colombes
Seat at my train station under snow on December 17

EN1545 is an expensive document, so I could not access it and had to reverse the data in my card, here is what I found. All of this is based on data collected with Integrale subscription. Bits are numbered starting at 1 because I used cardpeek to work on the data, which uses lua where we count from 1.

Before looking at the real data, all the cards I saw where 3B6F0000805A080303000000CARD NUMBER829000 with CARD NUMBER using 8 hex digits.

Event log

Then we can start with event log which is the one I spent most time one. It contains the last 3 uses of the card. Reading it for a few days, and reading the ones of my colleagues gave me plenty of information (many thanks #bureau3).

I have split each record into two parts, the first part is 68 bits long, the second part is 38 to 86 bits

First Part

1    5    9    13   17   21   25   29   33   37   41   45   49   53   57   61   65
DDDD DDDD DDDD DDTT TTTT TTTT T001 0000 0000 00BB CC10 1000 1010 0KKK KRRR RXXX XXXX
  • D: Days since 01/01/1997
  • T: Minutes since midnight
  • B: 3 for Bus, 0 for other
  • C: 1 for Metro and some Bus, 0 for Train and some Bus. Related to length of second part
  • K: 1 for Bus, 3 for Metro, 4 for Tram 5 for Train
  • R: 1 for Entry, 2 for Exit, 6 for a Metro to Train transition, 7 for Train to Metro transition
  • X: 58 found on a non RATP bus, 1 for everything else

Second Part
This part is varying a lot.

  • For SNCF trains it is 38 bits long, for metro or RER, 54 bits.
    69   73   77   81
    YSSS SSSS AAAA A??? ... ?000 01
    • S: Sector
    • A: Station

    For a list of sectors and stations, refer to this page and this one.

  • For bus, if C=0, it is 68 bits and Bus number is 13 bits starting at bit 121. Else it is 86 bits and Bus number is 13 bits starting at 137. Bus line is sometimes 8 bits starting at 110.

Contracts

  • 14 bits stating at 86: Days since 01/01/1997 for the contract subscription date
  • 14 bits stating at 100: Days since 01/01/1997 for the contract end
  • 8 bits starting at 114: Allowed zones as a bitfield, 114 is zone 8, ..., 121 is zone 1

Miracle

After finding all of this I found a PDF on Google describing coding for interoperability in France between cities using EN1545. I was happy because it both confirmed that I was right on most things, and because it contains a lot of information, like the additional codes for other kinds of transport, the complete coding for event log (the changing length indeed depended on some previous bits, each structure has a bitmap telling which fields will be there).

All the result of my findings, and some from that PDF are in a fork of cardpeek that I maintain there (because the author did not reply to my email with a first patch one month ago). I fixed a few issues in cardpeek but not the main one: it copies lua decoders to ~/.cardpeek/scripts the first time you run it and they never get updated. To workaround that, I replaced that directory with a symlink to my git checkout...

While collecting data I had some surprise, for example Tramway T4 in one station (La remise à Jorelle) did not write anything to event log, does this mean that they can't control you? T3 does, and T4 did in the next station Les coquetiers.

More expected, using your navigo card to get a Velib bike does not write anything, they just use the id of your card.

Plenty of Velib available today
Velib station under snow on December 17

I also happily could not find some data that I would not have liked to find as they are accessible via RFID too, like my name, birth date, ...

Today's TSUKKOMI(Total: 4) [Add a TSUKKOMI]
  tbscope (2009-12-22 07:13)

Are you still interested in EN 1545-1 and EN 1545-2?<br><br>It's a lot of work to remove my personal details from each page (yay for copyright information and barcodes), but I'll happily do it if you're interested.

  Wiflye81 (2009-12-22 12:42)

This is very interesting, hopefully for us, it seems personal data are encrypted. Do you know if I can still buy this reader cheaper than the original gemalto one ?

  Pascal (2009-12-23 01:16)

Sorry, their test offer is finished, they no longer sell it at all currently. I don't know what will be the public price when they will really launch it...

  liberforce (2009-12-28 06:10)

Pascal, if you have specific questions, you can ask me as I'll work until March for RATP ;-). I eat with the card guys every day. Also about the personal data in the card, don't worry too much : the CNIL has a pretty good control of what we do there. The data you can find is the user subscription number, but I believe the personnal data attached to that information is available only server-side. And for an complete anonymous use (but then if you lose your card, you'll lose your contract with no way to ask for a replacement ticket), there's the "Navigo Découverte" card, which is what I use.


2004|06|07|08|09|11|
2005|01|02|05|06|07|08|09|10|11|12|
2006|01|02|03|06|08|10|11|12|
2007|01|02|03|04|05|06|07|08|09|10|11|12|
2008|01|03|04|05|06|07|08|09|10|11|12|
2009|01|02|03|04|05|06|07|08|09|10|11|12|
2010|01|02|03|04|05|06|07|08|09|10|12|
2011|02|04|06|
2012|01|05|11|
2013|01|02|04|06|
2014|02|
2015|06|