Page MenuHome GnuPG

gpg-card: Authenticate to PIV applet with non-3DES card management key
Open, NormalPublic

Description

gpg-card currently supports authenticating to PIV applets with 3DES and performing various useful operations on the card. Modern cards are supplied with AES management keys and there is no way to authenticate to these cards.

piv-tool in OpenSC supposedly can do this but I could not find any useful documentation to allow me to do so.

Yubikey documentation lists their supported algorithms: "9B: Triple-DES key (algorithm 03) for PIV management. YubiKeys with firmware 5.4 and up also support AES-128 (algorithm 08), AES-192 (algorithm 0A) and AES-256 (algorithm 0C) keys for PIV management."

The card I'm using is a Gemalto IDPrime PIV 2.1 and is supplied with an AES-128 card management key.

I'm not sure if it's possible, but a workaround that allows swapping the AES-128 key for a 3DES key using another tool, then allowing management with gpg-card, would be a good bridging solution.

Event Timeline

Setting the management key has been implemented only for Yubikeys. So for Gemalto this won't work.

For using the management key we could distinguish the algorithm simply bu the provided key length:
24 bytes = 3DES
16 bytes = AES128
32 bytes = AES256
I see no easy way to support AES192, though.

Implementing the above suggestion should not be too hard, I just need to read the docs again

werner triaged this task as Normal priority.
werner added projects: gnupg (gpg23), scd.

Setting the management key has been implemented only for Yubikeys. So for Gemalto this won't work.

I'm happy to use OpenSC's tools to set the management key initially, but was not able to get that to work yet.

For using the management key we could distinguish the algorithm simply bu the provided key length:

Distinguishing by key length sounds very reasonable. I'm yet to come across a card actually using AES-192 even if it is technically supported by the standard.

OpenSC allows specification of the algorithm by code, i.e. AES-128 is 08. I've only found those documented on Yubikey's documentation and not in the piv-tool documentation, so if you were to name the algorithms then a mapping from the string "aes-128" to 08 internally would make it friendlier.