go-piv / piv-go

Keys and certificates for YubiKeys, written in Go
Apache License 2.0
368 stars 65 forks source link

piv: implement algorithm discovery #1

Open ericchiang opened 4 years ago

ericchiang commented 4 years ago

Different smart cards can implement different algorithm sets. See if YubiKey's PIV implementation supports algorithm discovery:

https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-73-4.pdf#page=61

nickray commented 4 years ago

To the best of my knowledge, there is no "interoperable way" to do this, nor a direct Yubico-specific one. Close misses:

Your reference above points to this last method, in a world where every key is expected to have an associated certificate. I understand this is the originally PIV-intended way. Moreover, it lives in the very small universe of SP 800-78-4 algorithms, something like Ed25519 is immediately non-standard.

There isn't even a standard way, if there is no certificate, to tell if there's a key (in a "slot"), except trying to do cryptographic operations with GENERAL AUTHENTICATE and recording 0x6a86 failures (for Yubico you can use GetMetadata). I assume the card administrator is assumed to know the support in the cards they're deploying...

As I intend for the SoloKeys PIV implementation to have additional/variable algorithms, it would make a lot of sense to have a command with parameter key ID (9a etc.) and response "list of supported algorithms". This would be a SoloKeys extension though (unless I can find anything resembling a standard way).

arekinath commented 4 years ago

So, Yubico don't currently do this, but in the application property template (response-to-select data), applets can list the algorithm IDs which they support (under tag AC). This is currently only compulsory if you support the PIV SM suites (27 or 2E), but the standard seems to imply that cards which support only a subset of the specified algorithms should advertise their subset in the APT. It might be nice to try to encourage newer implementations to make use of this? If it's worth anything, my PivApplet implementation for JavaCard-compatible devices does advertise its full list of supported algorithms here.