Why did you need to do this?
I couldn't use age-plugin-yubikey for key generation. My Yubikey has a custom management key (not supported), and it's AES192 (also not supported.) However, I was able to generate a key on my own using ykman directly.
How?
- Generate the key-pair:
ykman piv keys generate -P <pin text> -a ECCP256 --pin-policy NEVER --touch-policy NEVER -m <management key hex> 82 yk_slot_82.pub
- Generate a self-signed cert:
ykman piv certificates generate -s CN=<user name> -m <management key hex> -P <pin text>
- Verify that the plugin detects it:
❯ age-plugin-yubikey.exe -i --slot 1
# Serial: <REDACTED>, Slot: 1
# Name: CN=<REDACTED>
# Created: Fri, 23 Jan 1969 11:11:11 +0000
# PIN policy: Never (A PIN is NOT required to decrypt)
# Touch policy: Never (A physical touch is NOT required to decrypt)
# Recipient: <REDACTED>
AGE-PLUGIN-YUBIKEY-<REDACTED>
Possible caveats
- Cert expires after one year by default (not sure if the plugin checks validity, or why it even would.)
- Plugin marks OID extensions for the PIN and touch policies. Not sure if the plugin uses those, or if it's just gravy.
Still, it'd be nice to add this to the docs, since it's not that scary.
EDIT: C# Script for Generation
Turns out age-plugin-yubikey relies on organization (O=age-plugin-yubikey) for auto-discovery, if you don't specify a slot number. I think it also does use the OID extension to read the PIN/touch policies.
Here's a C# script I hacked together which generates a compatible ECCP256 key + self-signed cert: https://gist.github.com/sterlind/1dd3bf3b61894f49025b189acfce7d09
It's very fragile - it only handles slot 0x82, sets hard-coded policies, etc. - but this was the lesser evil for me.
Why did you need to do this?
I couldn't use
age-plugin-yubikeyfor key generation. My Yubikey has a custom management key (not supported), and it's AES192 (also not supported.) However, I was able to generate a key on my own usingykmandirectly.How?
Possible caveats
Still, it'd be nice to add this to the docs, since it's not that scary.
EDIT: C# Script for Generation
Turns out age-plugin-yubikey relies on organization (
O=age-plugin-yubikey) for auto-discovery, if you don't specify a slot number. I think it also does use the OID extension to read the PIN/touch policies.Here's a C# script I hacked together which generates a compatible ECCP256 key + self-signed cert: https://gist.github.com/sterlind/1dd3bf3b61894f49025b189acfce7d09
It's very fragile - it only handles slot 0x82, sets hard-coded policies, etc. - but this was the lesser evil for me.