Skip to content

Instantly share code, notes, and snippets.

@alexalouit
Created December 13, 2023 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexalouit/5ce1d2d477c61097aec0de6589f3f772 to your computer and use it in GitHub Desktop.
Save alexalouit/5ce1d2d477c61097aec0de6589f3f772 to your computer and use it in GitHub Desktop.
yubikey digital signature
$ brew install yubico-piv-tool
Go to yubico manager, generate a PIV Digital Signature certificates
- RSA2048
- Self-signed certificate
- Expiration to 2029-12-31
- Management key (default)
- PIN (default 123456)
Generate a certificate
$ yubico-piv-tool -a read-cert -s 9c -K PEM > yk.crt
Export public key
$ openssl x509 -pubkey -in yk.crt --nocert > yk.pub
Sign the file
$ yubico-piv-tool -a verify-pin --sign -s 9c -H SHA512 -A RSA2048 -i file.txt -o file.sig
Verify the signature according to pubkey <> file
$ openssl dgst -sha512 -verify yk.pub -signature file.sig file.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment