Previous Table of Contents Next


Selecting a Directory

Even though the Multiflex operating system makes the master file the current file, since you may want to use other cards with your application, it would be typical for your application program to make this selection again and, in the process, retrieve some information about the specific card with which it was dealing. The master file on all ISO 7816-compliant smart cards has the filename 3F0016. You can make the master file the current file by sending a 7-byte Select File command to the card with the fileId of the master file as its argument. Here’s an example:

C016 A416 0016 0016 0216 3F16 0016

The meaning of each of the bytes in the Select File command is given in Table 5.2.

Table 5.2. The 3K Multiflex Select File command.
ISO 7816 Name Description Value Interpretation

CLA Class C016
INS Instruction A416
P1 First parameter 0016
P2 Second parameter 0016
P3 Third parameter 0216 Two data bytes follow
Data Data 3F16 0016 Fileld of the file to be selected

Whenever you send a command to an ISO 7816 smart card, it will respond with two status bytes called status word 1 (SW1) and status word 2 (SW2). This will tell you what the result of processing your command was. Assuming that there is a file with the file identifier 3F0016, you’d expect the card to respond with

9016 0016

which is the required ISO 7816-4 status return code for successful completion. This would indicate that the operating system on the card found the file 3F0016 and that it is now the current file. Instead of 9016 0016 however, the 3K Multiflex card responds with

6116 1416

This is also a successful completion but with some additional information. It says, “I found the file you selected successfully and I have some information about it available for you.” The second byte tells how much information is available: 1416, or 20 bytes.

In order to retrieve this file description information, you’ll send a Get Response command to the card with the number of bytes you want to retrieve as its third argument. In particular, the bytes

C016 C016 0016 0016 1416

would request the operating system to send back the 20 bytes of information about the master file from your 3K Multiflex card. If you do this for the unused 3K Multiflex card contained in the book, the card returns the following 20 bytes:

0016 0016 0B16 1016 3F16 0016 3816 FF16 FF16 4416 4416 0116 0516 0316 0016 0216 0016 0016 0016 0016

The interpretation is given in Table 5.3.

Table 5.3. File control information for the master file (3F0016).
Byte Description Value Interpretation of Value

1-2 Unused 0016 0016 Unused.
3-4 Free bytes in selected file 0B16 0116 There are 2,832 bytes available in this directory.
5-6 Fileld of selected file 3F16 0016 The selected file has fileId 3F0016.
7 Type of selected file 3816 The selected file is a directory file.
8 High Byte unused F16 Unused.
8 Low Byte unused F16 Unused.
9 High Byte access condition for the Directory command F16 The Directory command can never be used on this directory.
9 Low Byte unused. F16 Unused.
10 High Byte access condition for the Delete File command 416 You must know a cryptographic key to use the Delete File command.
10 Low Byte access condition for the Create File command 416 You must know a cryptographic key to use the Create File command.
11 High Byte access condition for the Rehabilitate command 416 You must know a cryptographic key to use the Rehabilitate command.
11 Low Byte access condition for the Invalidate command 416 You must know a cryptographic key to use the Invalidate command.
12 Status of the selected file 0116 The file is currently unblocked.
13 Number of bytes in following data 0516 5 bytes of data follow.
14 Features 0316 Unused.
15 Number of subdirectories 0016 There are no subdirectories in this directory.
16 Number of elementary files 0216 There are two elementary files in this directory.
17 Number of secret codes 0016 There are no secret codes in this directory.
18 Unused 0016 Unused.
19 Status of the PIN for this directory 0016 There is no PIN file in the current directory.
20 Status of PIN unblocking key 0016 The PIN unblocking key is not itself blocked.


Previous Table of Contents Next