Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OpenPGP Card example #56

Merged
merged 2 commits into from
May 6, 2024
Merged

Add OpenPGP Card example #56

merged 2 commits into from
May 6, 2024

Conversation

wiktor-k
Copy link
Owner

I've added a more elaborate example of an SSH agent. Actually this is a code that I'm planning to use (semi-)daily.

It has a couple of limitations, first of all it supports ed25519 keys only but I think it's a good idea to show how agents can be built and also serves as a validation of our API.

@wiktor-k wiktor-k force-pushed the wiktor/add-openpgp-card-example branch 5 times, most recently from 0143beb to c46d30e Compare April 22, 2024 10:25
@wiktor-k wiktor-k marked this pull request as draft April 22, 2024 10:58
@wiktor-k wiktor-k force-pushed the wiktor/add-openpgp-card-example branch 3 times, most recently from 455a76f to f0b9dc7 Compare April 23, 2024 09:58
@wiktor-k wiktor-k marked this pull request as ready for review April 23, 2024 10:02
@jcspencer
Copy link
Collaborator

Looks good!

Always a big fan of adding more examples!

Perhaps you could use zeroize for safely dealing with PIN data in memory? Perhaps also in combination with a simple TTL cache like retainer to evict them after some time?

These are only nits of course! This LGTM as is :^)


On another note, I've started work on two examples I'll add in next week:

  • Using the yubikey.rs crate to show how this may work with a PIV card.
  • A simple implementation of session binding to show how an agent could store contraints alongside keys and enforce them

@wiktor-k
Copy link
Owner Author

🤔 Hmm... retainer looks interesting. I think we could use that for implementing the Lifetime key constraint... I'll see how complex it'd be to add this. Zeroize looks like a lower hanging fruit :)

I was previously thinking about wrapping it in tpm-box which would only decrypt the PIN when needed but didn't want to pack too much into one example.

On another note, I've started work on two examples I'll add in next week:

This sounds very nice 🤩 looking forward to your PRs!

@wiktor-k wiktor-k force-pushed the wiktor/add-openpgp-card-example branch 2 times, most recently from 8af3275 to 01e6f00 Compare April 25, 2024 11:07
@wiktor-k
Copy link
Owner Author

Okay, I've added the lifetime constraint support and... it's pretty cool... I can do:

SSH_AUTH_SOCK=/run/user/1000/openpgp-card-agent.sock ssh-add -t 120 -s 0006:15422467

And it caches my PIN only for 120 seconds (2 minutes). Additionally since the constrained key structure is quite simple I could parametrize it so that the regular call uses no expiration. Really, really cool! Thanks @jcspencer for all ideas! 👏

Btw it made me think whether we should use SecretString or something similar for PINs. Currently all these structures derive Debug which would dump pins in logs which may, or may not, be problematic. WDYT folks? (CC'ing @baloo)

wiktor-k added 2 commits May 6, 2024 11:16
Signed-off-by: Wiktor Kwapisiewicz <[email protected]>
@wiktor-k wiktor-k force-pushed the wiktor/add-openpgp-card-example branch from 01e6f00 to 81105ce Compare May 6, 2024 09:17
@wiktor-k wiktor-k merged commit 6b369db into main May 6, 2024
16 checks passed
@wiktor-k wiktor-k deleted the wiktor/add-openpgp-card-example branch May 6, 2024 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants