Modifications

Sauter à la navigation Sauter à la recherche
Ligne 22 : Ligne 22 :  
}}
 
}}
   −
== Secteur de 4 blocs ==
+
== Secteurs de 4 blocs ==
 
1K and 4K cards both use 16 sectors of 4 blocks each, with the bottom 1K of memory on the 4K cards being organised identically to the 1K models for compatability reasons. These individual 4 block sectors (containing 64 byts each) have basic security features are can each be configured with seperate read/write access and two different 6-byte authentication keys (the keys can be different for each sector). Due to these security features (which are stored in the last block, called the '''Sector Trailer'''), only the bottom 3 blocks of each sector are actually available for data storage, meaning you have 48 bytes per 64 byte sector available for your own use.
 
1K and 4K cards both use 16 sectors of 4 blocks each, with the bottom 1K of memory on the 4K cards being organised identically to the 1K models for compatability reasons. These individual 4 block sectors (containing 64 byts each) have basic security features are can each be configured with seperate read/write access and two different 6-byte authentication keys (the keys can be different for each sector). Due to these security features (which are stored in the last block, called the '''Sector Trailer'''), only the bottom 3 blocks of each sector are actually available for data storage, meaning you have 48 bytes per 64 byte sector available for your own use.
   Ligne 38 : Ligne 38 :  
               1      [                            Data                          ]  Data
 
               1      [                            Data                          ]  Data
 
               0      [                    Manufacturer Data                    ]  Manufacturer Block</nowiki>
 
               0      [                    Manufacturer Data                    ]  Manufacturer Block</nowiki>
 +
 +
=== Secteur de fin (3 blocs) ===
 +
Le secteur de fin s'appelle "sector trailer" en anglais. Ce secteur contient deux clés secrètes Clé A et Clé B (''Key A'' et ''Key B'' en anglais), ainsi que les conditions d'accès pour les 4 blocs.
 +
 +
Ce secteur à la structure suivante:
 +
<nowiki>          Sector Trailer Bytes
 +
          --------------------------------------------------------------
 +
          0  1  2  3  4  5  6  7  8  9  10  11  12  13  14  15
 +
          [      Key A      ]  [Access Bits]  [      Key B        ]</nowiki>
 +
 +
For more information in using Keys to access the clock contents, see Accessing Data Blocks further below.
 +
 +
=== Blocs de données (Blocs 0..2) ===
 +
Data blocks are 16 bytes wide and, depending on the permissions set in the access bits, can be read from and written to. You are free to use the 16 data bytes in any way you wish. You can easily store text input, store four 32-bit integer values, a 16 character uri, etc.
 +
 +
=== Blocs de données comme "bloc valeurs" ===
 +
An alternative to storing random data in the 16 byte-wide blocks is to configure them as "bloc valeur" ("''Value Blocks''" en anglais). Value blocks allow performing electronic purse functions (valid commands are: read, write, increment, decrement, restore, transfer).
 +
 +
Each Value block contains a single signed 32-bit value, and this value is stored 3 times for data integrity and security reasons. It is stored twice non-inverted, and once inverted. The last 4 bytes are used for a 1-byte address, which is stored 4 times (twice non-inverted, and twice inverted).
 +
 +
Data blocks configured as "Value Blocks" have the following structure:
 +
 +
<nowiki>          Value Block Bytes
 +
          --------------------------------------------------------------
 +
          0  1  2  3  4  5  6  7  8  9  10  11  12  13  14  15
 +
          [  Value  ]  [  ~Value  ]  [  Value  ]  [A  ~A  A  ~A]</nowiki>
 +
 +
=== Bloc Fabricant (Secteur 0, Bloc 0) ===
 +
Sector 0 is special since it contains the bloc Fabricant ("''Manufacturer Block''" en anglais). This block contains the manufacturer data, and is read-only. It should be avoided unless you know what you are doing.
 +
 +
== Secteurs de 16 blocs ==
 +
16 block sectors are identical to 4 block sectors, but with more data blocks. The same structure described in the 4 block sectors above applies.
 +
 +
<nowiki>      Sector  Block  Bytes                                                          Description
 +
      ------  -----  -----                                                          ----------
 +
                      0  1  2  3  4  5  6  7  8  9  10  11  12  13  14  15</nowiki>
 +
<nowiki>      32      15      [-------KEY A-------]  [Access Bits]  [-------KEY B-------]  Sector Trailer 32
 +
              14      [                            Data                          ]  Data
 +
              13      [                            Data                          ]  Data
 +
              ...
 +
              2      [                            Data                          ]  Data
 +
              1      [                            Data                          ]  Data
 +
              0      [                            Data                          ]  Data</nowiki>
 +
 +
== Accéder à la mémoire de l'EEPROM ==
 +
To access the EEPROM on the cards, you need to perform the following steps:
 +
 +
# You must retrieve the 4-byte NUID of the card (this can sometimes be 7-bytes long as well, though rarely for Mifare Classic cards). This is required for the subsequent authentication process.
 +
# You must authenticate the sector you wish to access according to the access rules defined in the Sector Trailer block for that sector, by passing in the appropriate 6 byte Authentication Key (ex. 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF for new cards).
 +
# Once authenication has succeeded, and depending on the sector permissions, you can then read/write/increment/decrement the contents of the specific block. Note that you need to re-authenticate for each sector that you access, since each sector can have it's own distinct access keys and rights!
 +
 +
== Note sur l'Authentification ==
 +
Before you can do access the sector's memory, you first need to "authenticate" according to the security settings stored in the Sector Trailer. By default, any new card will generally be configured to allow full access to every block in the sector using Key A and a value of 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF. Some other common keys that you may wish to try if this doesn't work are:
 +
 +
<nowiki>              0XFF 0XFF 0XFF 0XFF 0XFF 0XFF
 +
              0XD3 0XF7 0XD3 0XF7 0XD3 0XF7
 +
              0XA0 0XA1 0XA2 0XA3 0XA4 0XA5
 +
              0XB0 0XB1 0XB2 0XB3 0XB4 0XB5
 +
              0X4D 0X3A 0X99 0XC3 0X51 0XDD
 +
              0X1A 0X98 0X2C 0X7E 0X45 0X9A
 +
              0XAA 0XBB 0XCC 0XDD 0XEE 0XFF
 +
              0X00 0X00 0X00 0X00 0X00 0X00
 +
              0XAB 0XCD 0XEF 0X12 0X34 0X56</nowiki>
 +
 +
== Carte MiFare Classic 1K - Exemple ==
 +
Voici un exemple avec un carte MiFare Classic toute neuve.
    
{{PN532-RFID-NFC-TRAILER}}
 
{{PN532-RFID-NFC-TRAILER}}
29 917

modifications

Menu de navigation