|
18 | 18 | */
|
19 | 19 | public class KeycardCommandSet {
|
20 | 20 | static final byte INS_INIT = (byte) 0xFE;
|
| 21 | + static final byte INS_FACTORY_RESET = (byte) 0xFD; |
21 | 22 | static final byte INS_GET_STATUS = (byte) 0xF2;
|
22 | 23 | static final byte INS_SET_NDEF = (byte) 0xF3;
|
23 | 24 | static final byte INS_IDENTIFY_CARD = (byte) 0x14;
|
@@ -81,6 +82,9 @@ public class KeycardCommandSet {
|
81 | 82 | public static final byte EXPORT_KEY_P2_PUBLIC_ONLY = 0x01;
|
82 | 83 | public static final byte EXPORT_KEY_P2_EXTENDED_PUBLIC = 0x02;
|
83 | 84 |
|
| 85 | + static final byte FACTORY_RESET_P1_MAGIC = (byte) 0xAA; |
| 86 | + static final byte FACTORY_RESET_P2_MAGIC = 0x55; |
| 87 | + |
84 | 88 | static final byte TLV_APPLICATION_INFO_TEMPLATE = (byte) 0xA4;
|
85 | 89 |
|
86 | 90 | private final CardChannel apduChannel;
|
@@ -887,4 +891,15 @@ public APDUResponse init(String pin, String altPin, String puk, byte[] sharedSec
|
887 | 891 | APDUCommand init = new APDUCommand(0x80, INS_INIT, 0, 0, secureChannel.oneShotEncrypt(initData));
|
888 | 892 | return apduChannel.send(init);
|
889 | 893 | }
|
| 894 | + |
| 895 | + /** |
| 896 | + * Sends the FACTORY RESET command to the card. |
| 897 | + * |
| 898 | + * @return the raw card response |
| 899 | + * @throws IOException communication error |
| 900 | + */ |
| 901 | + public APDUResponse factoryReset() throws IOException { |
| 902 | + APDUCommand factoryReset = new APDUCommand(0x80, INS_FACTORY_RESET, FACTORY_RESET_P1_MAGIC, FACTORY_RESET_P2_MAGIC, new byte[0]); |
| 903 | + return apduChannel.send(factoryReset); |
| 904 | + } |
890 | 905 | }
|
0 commit comments