Skip to main content

Query and export RSA keys

Query RSA private keys

To query private keys on smart card, enter:

$ pkcs15-tool --list-keys
Using reader with a card: Feitian SCR301 01 00
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

The RSA private key cannot leave the smartcard.

Query RSA public keys

To query RSA public keys on smart card, enter:

$ pkcs15-tool --list-public-keys
Using reader with a card: Feitian SCR301 01 00
Public RSA Key [Public Key]
Com. Flags : 2
Usage : [0x4], sign
Access Flags: [0x0]
ModLength : 2048
Key ref : 0
Native : no
Path : 3f0050153000
Auth ID : 01
ID : c6f280080fb0ed1ebff0480a01d00a98a1b3b89a

Export RSA public keys

Public RSA key can be exported in RSA format:

$ pkcs15-tool --read-public-key < ID >

Public RSA keys can be exported in SSH format:

$ pkcs15-tool --read-ssh-key < ID >

Eventualy, add the -o filemane swith to output to a file.