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

ssh-key: externally generated signatures for certificates #333

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

shimunn
Copy link

@shimunn shimunn commented Feb 8, 2025

This adds an async function with_signer to the certificate builder to delegate the signature generation to an user defined function such an fido2 implementation to sign an certificate using an security key.

I'd really prefer to use an async closure instead of Fn(&[u8]) -> impl Future however that would require bumping rust-version to 1.84

@tarcieri
Copy link
Member

tarcieri commented Feb 8, 2025

I would suggest following the existing pattern for the SigningKey trait and defining an AsyncSigningKey trait which bounds on AsyncSigner<Signature>. Then you can add a certificate::Builder::sign_async method. This is similar to how equivalent functionality works in the x509-cert crate

Comment on lines +67 to +79
/// Sign the provided message bytestring using `Self` (e.g. a cryptographic key
/// or connection to an HSM), returning a digital signature.
pub trait AsyncSigner<S> {
// Using an associated type here to force the implementor to be explicit with Send/Sync
/// Future type which will be returned by `try_sign`
type SignFuture: Future<Output = signature::Result<S>>;
/// Attempt to sign the given message, returning a digital signature on
/// success, or an error if something went wrong.
///
/// The main intended use case for signing errors is when communicating
/// with external signers, e.g. cloud KMS, HSMs, or other hardware tokens.
fn try_sign(&self, msg: &[u8]) -> Self::SignFuture;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the upstream trait from async-signature (which we plan on merging into the signature crate soon)

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