====== DESFire User Manual ====== ===== Overview ===== MIFARE DESFire EV1 card operates at 13.56 MHz wireless frequency, according to the ISO 14443A standard with the transport protocol complying to the ISO 14443-4 standard. It features a 4K byte NVM, a high speed triple-DES data encryption co-processor, a flexible memory organization structure, a mutual 3-pass authentication technique together with a true random number generator and an anti-tear mechanism to guarantee data integrity during contactless transactions. It can be applied to multiple applications that needed high security, such as, entrance guard system, staff attendance, company access, identification and so on. ===== Preparation ===== Hardware: * [[https://javacardos.com/store/smartcard-reader-r502.php|R502 Reader]]\\ * [[https://javacardos.com/store/mifare-desfire-ev1-2k-card.php|DESFire Card]]\\ Software: * [[https://javacardos.com/tools/pyresman.html|pyResMan.exe]]\\ Note: Please download [[https://javacardos.com/tools/pyresman.html|pyResMan]] from [[https://javacardos.com/tools/pyresman.html|javacardos.com]] or [[https://github.com/JavaCardOS/pyResMan/releases|gitHub]]. ===== User Guide ===== Connect [[https://javacardos.com/store/smartcard-reader-r502.php|R502 Reader]] to computer via USB cable and put DESFire Card on [[https://javacardos.com/store/smartcard-reader-r502.php|R502 Reader]]. Double click [[https://javacardos.com/tools/pyresman.html|pyResMan.exe]]. Select contactless mode reader from the ReaderName dropdown list and click "Connect" button to connect the smart card reader. Then switch to "DESFire" tab. {{:001.png?600|}} ==== 1.Security Related Commands ==== === 1.1 Authenticate === Click "Authenticate" to complete the card authentication. When "DESFire authenticated" appears, it indicates that the authentication is successful. This procedure not only confirms that both entities can trust each other but also generates a session key which can be used to keep the further communication path secure. After the authentication procedure is successfully, the further operation on PICC, application, file, file data can be executed. {{:002.png?600|}} === 1.2 ChangeKey === Not implemented yet. === 1.3 GetKeySettings === Click "Get key settings" button to get the configuration information on PICC and application master key configuration settings, as shown below. {{:003.png?600|}} ==== 2.PICC Level Commands ==== === 2.1 GetVersion === Click "GetVersion" to get manufacturing related data of the PICC. {{:004.png?600|}} === 2.2 FormatPICC=== Click "FormatPICC" to release the PICC user memory. Note: This operation requires a preceding authentication with the PICC master key, otherwise it will return the error code. {{:005.png?600|}} === 2.3 CreateApplication === Click "Create Application" to create new applications on the PICC. Type Application Identifier (AID) and then press "OK". Note: AID must be an unique identification, and it cannot be repeated. {{:006.png?600|}} === 2.4 GetAppliationIDS === The "Get Application IDS" command returns the Application IDentifiers of all active applications on a PICC and add them to the right dropdown list. {{:007.png?600|}} === 2.5 SelectApplication === "SelectApplication" command allows to select one specific application for further access. {{:008.png?600|}} === 2.6 DeleteApplication === Click "DeleteApplication" button to permanently deactivate the selected applications on the PICC. {{:009.png?600|}} ==== 3.Application and Data Manipulation Level Commands ==== === 3.1 Create Std Data File === Click "Create Std Data File" to create files for the storage of plain unformatted user data within the currently selected application on the PICC. In the pop-up dialog box, enter File No. and set the file size, press "OK". File No.: File Identifier is non-repeatable, otherwise the error code will be returned. File Size: The size of the file in bytes. {{:010.png?600|}} === 3.2 Create Backup Data File === Click "Create Backup Data File…" to create backup files for the storage of plain unformatted user data within the currently selected application on the PICC. In the pop-up dialog box, enter File No. and set the file size, press "OK". File No.: File Identifier is non-repeatable, otherwise the error code will be returned. File Size: The size of the file in bytes. {{:011.png?600|}} === 3.3 CreateValueFile === Click "Create Value File…" to create files for the storage and manipulation of 32bit signed integer values within an existing application on the PICC. In the pop-up dialog box, enter "File No.", set "Upper Limit" and "Value". {{:012.png?600|}} === 3.4 CreateLinearRecordFile === Click "Create Linear RecordFile…" in the pop-up dialog box, enter "File No." and set "Record Size" to to create Linear Record File. Once the file is filled completely with data records and the maximum number of records. further writing to the file is not possible unless it is cleared. File No.: File Identifier is non-repeatable, otherwise the error code will be returned. Record Size: The size of the file to record. Max Num. of records: The maximum number of records in bytes. {{:013.png?600|}} === 3.5 Create Cyclic Record File === Click "Create Cyclic Record File…" to create files within the currently selected application on the PICC. In the pop-up dialog box, enter File No. and set the size of the file to record and the maximum number of records. Once the file is filled completely with data records, the PICC automatically overwrites the oldest record with the latest written one. Note: Parameters with the create LinearRecordFile consistent. {{:014.png?600|}} === 3.6 Get File IDs === Click "Get File IDs" button to get File IDentifiers of all active files within the currently selected application and add them to the right dropdown list. {{:015.png?600|}} === 3.7 Get File Settings === Click "Get File Settings" to get information on the properties of a specific file. {{:016.png?600|}} === 3.8 Changes Files Settings === Not implemented yet. === 3.9 Delete File === Click "Delete File" to permanently delete a file within the file directory of the currently selected application. {{:017.png?600|}} ==== 4.Data Manipulation Commands ==== === 4.1 Write Record === In the dropdown list, select the created standard data files or backup data files, click "Write Data…" and enter the data in the pop-up dialog box. {{:018.png?600|}} === 4.2 Read Data === In the dropdown list, select the standard data files or backup data files, click "Read Data…" and enter the length of data to read in the pop-up dialog box, press "OK". {{:019.png?600|}} {{:020.png?600|}} === 4.3 Credit === In the dropdown list, select the created value file, then the buttons of "value File" line and "Transaction" line are avaliable. {{:021.png?600|}} Click "Credit…", enter data in the "value" textbox and press "OK". {{:022.png?600|}} === 4.4 Get Value === From the list box, select the created value file, click "Get Value…" to read data. {{:023.png?600|}} === 4.5 Debit === From the list box, select the created value file, click "Debit" to decrease a value stored in a Value File. {{:024.png?600|}} The step must click "Commit Transaction" to commit transaction. Click "Get Value" to verify the previous operation. {{:025.png?600|}} === 4.6 LimitedCredit === Click "Limited Credit" button, enter data in "value" textbox and press "OK". {{:026.png?600|}} === 4.7 Write Record === Select the created "linear Record File" or "cyclic record file" in the list. then the buttons of "Record File" line are available. {{:027.png?600|}} Click "Write Record" and enter Data in the pop-up dialog box, press "OK". {{:028.png?600|}} === 4.8 Read Records === Click “Read Records…” and enter the length of data to read in the pop-up dialog box, press "OK". {{:029.png?600|}} {{:030.png?600|}} === 4.9 Clear Record File === Click "Clear Record File…" to clear LinearRecordFile data or CyclicRecordFile data,then remember to click "Commit Transaction" to validate the data. {{:031.png?600|}} At this time, if you read data and it doesn't return any information, it indicates this command is executed successfully. {{:032.png?600|}} === 4.10 Commit Transaction === Besides std data file, for other files, it requires "Commit Transaction" operation to validate the data. Otherwise, the data won't have any changes. Note: You can use "GetValue" to verify the validity of the data. {{:033.png?600|}} === 4.11 Abort Transaction === The AbortTransaction command allows to invalidate all previous write access on Backup Data Files, Value Files and Record Files within one application. This is useful to cancel a transaction without the need for re-authentication to the PICC, which would lead to the same functionality. {{:034.png?600|}}