The WRITE KEY command is used to add or modify keys in the key file
code | value |
CLA | 80/84 |
INS | D4 |
P1 | Indicates that this WRITE KEY command is used to add a key |
Indicates that this WRITE KEY command is used to update the key of the specified type in P1 | |
P2 | key ID |
Lc | See command message data field |
Data | |
the | does not exist |
Command message data field
Note: Key type and key ID are not the same thing
Example of adding an external authentication key:
Create a key file under the main directory:
then execute the command to create a key file: 80 E0 00 00 07 3F 00 B0 01 F0 FF FF
Description:
80 E0 : Command type and command code; create file or directory
00 00 : File ID;
07: length; 07 means there are 7 bytes behind
3F : file type, this is the key file.
00 B0: The space available for the created file, that is, the space of 0XB0 bytes;
01 : read permission; F0 : write permission.
01表示没有读的权限 F0表示可以任意写
After the key file is created, it is necessary to add a key to it.
Execute the command: 80D4 0100 0D 39 F0F0 AA55 FFFFFFFFFFFFFFFF
Description:
80D4 : Instruction category and instruction code;
01 00 : file identification;
0D: length; 0D means there are 13 bytes behind
39: file type, this is the external authentication key
F0: read permission; F0: write permission;
AA: follow-up status;
55 : Error count, currently 5 chances,
The returned error code is 63 CX, and X is the number of times. When X is 0, the card is permanently locked. Please pay attention when operating the master key!
Example of adding a password key:
Create a key file in the DF directory
Execute command: 80E0 0001 07 3F 01 8F 95 F0 FFFF
80 E0 : Command type and command code; create file or directory
00 01 : File ID;
07: length; 07 means there are 7 bytes behind
3F : file type, this is the key file.
01 8F: The space available for the created file, that is, 0X018F bytes of space can be used; this place is wrong
95 : read permission; F0 : write permission.
95表示 F0表示可以任意写
Add the password key to the key file in the DF directory.
Execution command: 80 D4 0101 08 3A F0 EF 44 55 12 34 56
Description:
80 D4 : Instruction category and instruction code;
0101 : file identification;
08:length;
3A: file type, i.e. password key
F0 : read permission;
EF: write permission;
44 : follow-up status;
55 : Error count;
123456 : 3-byte PIN password