Repository navigation
PIV: X.509 key usage option for certificates and CSRs - #164
Conversation
Let the slot's Certificate section request an X.509 keyUsage extension, so certificates and CSRs can carry the usages the PIV profiles prescribe instead of never having any extension. The selection is remembered per device:slot, starts at the PIV default for the slot, follows the slot key's algorithm (keyEncipherment and keyAgreement swap, unsupported bits are disabled and dropped) and "Undefined" keeps today's no-extension output. "Default" is a UI-only shortcut. keyroostctl passes no key usage and is unchanged. Co-Authored-By: Claude <noreply@anthropic.com>
Unsupported key usages used to be disabled in the dropdown. Keep them selectable but flag them in the warning colour, and show a warning marker next to the dropdown listing what is incompatible with the slot key's type. A CA or later verifier may still reject such a certificate, which the tooltip says. Also rename the "Default" entry to "Slot default". Co-Authored-By: Claude <noreply@anthropic.com>
piv self-sign and piv request-cert can now request an X.509 keyUsage extension. Values are the nine usages plus "default" (the PIV standard's usages for the slot) and "undefined" (no extension, same as omitting the option). "undefined" must stand alone; "default" may only accompany exactly the usages that form the default. Invalid RFC 5280 combinations fail before any PIN is read where the key type is known. Usages the key type can't back only warn. Co-Authored-By: Claude <noreply@anthropic.com>
|
according to 5280 section 4.2.1.9 Basic Constraints
So if we start to play around with extensions it becomes quite more complicated quite fast. I do appreciate the work and it makes it simple to play around with tokens even more by introducing x509 - but should keyroost really become some gui certificate manager? If at all I would put this as some form of external like an extension or plugin or even its own application. |
The keyUsage extension used to be marked critical whenever it was written. Make that opt-in: a "Critical" entry in the GUI dropdown and a `critical` value for keyroostctl --key-usage. It needs at least one usage and can't be combined with Undefined. The PIV slot default now includes critical, as the PIV profiles require it. In the GUI "Slot default" is only shown when both usages and critical match; in the CLI `default` stands alone or with exactly those usages plus `critical`. Co-Authored-By: Claude <noreply@anthropic.com>
|
To test PIV, support for some extensions is crucial. Key Usage is just a prominent example I've started with, as this is evaluated by my KeePass plugin. Indeed, supporting all PIV-mandated extensions makes the UI more complex. Not all extensions are of practical relevance, though. To keep the UI lean, only a practical subset may be incorporated. Supporting certificate extensions in the PIV module would not be specific to Key Roost; HID's Crescendo Manager has nicely implemented this as well (screenshots in section The "Basic Constraints" extension you've cited is optional for PIV, as ordinary PIV certificates are commonly end-entity certificates. The PIV standard document FIPS201 referenced/required Federal PKI policy therefore marks "Basic Constraints" as optional and requires CA=false if it is present (see e.g. worksheet 6). But using a PIV key as an lightweight/minimal HSM for a CA might be a tempting and valid use case outside the strict PIV certificate profile. But how far KeyRoost wants to support this is a different question. The FIPS201 required strict Non-CA profile is effectively relevant/required for US government applications only. |
With several usages selected the caption ran off the pane on a small window. Let it wrap at the pane edge, keeping room for the warning marker next to it. Co-Authored-By: Claude <noreply@anthropic.com>
|
Oh, wasn't aware of PIV specifics when it comes to x509 - but since I started to play around with PIV I somewhat phased out this whole "US" stuff - as I don't care about such over here in europe (and in fact, if at all, would rather focus on europe specifucs if such exists). |
|
Thanks @episource! I do have a couple thoughts, welcome your input:
We'll add the changelog entry when we merge, and will hold and rebase #165 once #163 and #164 are merged in to avoid causing you a bunch of pain. |
Ed25519 can't do key agreement, yet 9D and the retired slots default to keyAgreement. Intersect the slot default with what the key can back; if nothing is left the default is undefined (no extension). The CLI warns when `--key-usage default` degrades this way. The GUI marks the "Slot default (undefined)" entry and the box with a warning triangle, and lets Undefined be picked separately from Slot default in that case. Co-Authored-By: Claude <noreply@anthropic.com>
|
Thanks for catching the ED25519 issue. I've just relied on the PIV defaults, but missed that there is one specific ECC algorithm not supporting Key Agree. I've fixed this. Regarding the CLI's default: I'd rather prefer |
|
Thanks @episource! You convinced me: "Slot default" will be the default everywhere. |
Changelog fragments and README contributor credit for the Swissbit iShield reads (#163) and X.509 key usage (#164). The v0.13.0 migration table gains a row for `piv self-sign` / `request-cert`, which now write the slot's standard key usage when `--key-usage` is omitted, with `--key-usage undefined` as the way back to the old output. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Skvxkb6eMzytjPDmL6mPYU
Adds a key usage option to PIV self-signed certificates and CSRs, in both the GUI (dropdown in the slot's Certificate section) and keyroostctl (
--key-usageonpiv self-signandpiv request-cert). The selection is written as a X.509 keyUsage extension.Slot defaultselects the PIV profile for the slot (CLI:default).