Skip to main content

Deleting objects from smart card

Let's display the content of our card:

$ pkcs15-tool --dump
Using reader with a card: Feitian SCR301 01 00
PKCS#15 Card [François Pérou]:
Version : 1
Serial number : 2998511513171109
Manufacturer ID: EnterSafe
Last update : 20100316211626Z
Flags : PRN generation, EID compliant

PIN [User PIN]
Com. Flags: 0x3
ID : 01
Flags : [0x30], initialized, needs-padding
Length : min_len:4, max_len:16, stored_len:16
Pad char : 0x00
Reference : 1
Type : ascii-numeric
Path :

Private RSA Key [Private Key]
Com. Flags : 3
Usage : [0x4], sign
Access Flags: [0x1D], sensitive, alwaysSensitive, neverExtract, local
ModLength : 2048
Key ref : 1
Native : yes
Path : 3f005015
Auth ID : 01
ID : c6f280080fb0ed1ebff0480a01d00a98a1b3b89a

Public RSA Key [Private Key]
Com. Flags : 2
Usage : [0x4], sign
Access Flags: [0x0]
ModLength : 2048
Key ref : 0
Native : no
Path : 3f0050153000
Auth ID :
ID : c6f280080fb0ed1ebff0480a01d00a98a1b3b89a

X.509 Certificate [Certificate]
Flags : 2
Authority: no
Path : 3f0050153100
ID : c6f280080fb0ed1ebff0480a01d00a98a1b3b89a

Reading data object <0>
applicationName: pkcs15-init
Label: Fichier test
applicationOID: NONE
Path: 3f0050153300
Auth ID: 01
Data Object (16 bytes): < 54 68 69 73 20 69 73 20 61 20 74 65 73 74 2E 0A >

To delete an object:

$ pkcs15-init --delete-objects arg

Delete arguments: a comma-separated list containing any of the following:
privkey,pubkey,cert,chain,data

Private keys, public keys and certificates cannot be deleted. This is a security issue to make sure that an attacker would not replace your keys on a card.

The only way to replace keys is to format the card.