feat: support for external signers in NIOSSHPrivateKey - #220
Conversation
|
Thanks for putting this together - external signing is a need I've been carrying via a fork for a while. One adjacent case I'm not sure falls under this PR: support for Would the |
Motivation: Enables hardware-backed authentication and remote identity protocols by allowing NIOSSHPrivateKey to delegate signing operations to external providers (e.g., Secure Enclave, TPM, or ssh-agent) without requiring raw private key material in memory. Modifications: - Defined NIOSSHExternalSigner protocol for delegated signing. - Added .external case to NIOSSHPrivateKey for all supported algorithms (Ed25519, P-256, P-384, P-521). - Added NIOSSHError.externalSignerFailure for better error propagation. - Updated documentation and added comprehensive tests for external signing logic. Result: NIOSSH now supports public-key authentication where the signing operation is handled by an external delegate, providing a foundational hook for ssh-agent and hardware security integrations.
84567df to
380d619
Compare
|
Hi @Lukasa (and maintainers), I have rebased this branch onto the latest To make the review of these SSH Agent hooks as lightweight as possible:
When you have a moment, could you approve the workflow runs and let me know if the overall API design aligns with your preferences? Thanks! |
Thanks for raising this. The current #220 does not cover algorithm registration; it delegates signing only for key/signature algorithms that NIOSSH already represents. RSA requires additional handling because a public key using the Therefore RFC 8332 support would be a separate step, likely built with #219 or equivalent RSA support. If RSA lands, this external-signer hook would need follow-up integration—potentially an explicit algorithm parameter or typed signing request. I have not tried to solve that speculatively in #220, but I will document the limitation. Maintainer guidance on whether the external-signer API should anticipate multiple algorithms per key would be welcome. |
Lukasa
left a comment
There was a problem hiding this comment.
Thanks for this patch, and apologies for the substantial delay in getting around to the review.
Before we go much further, I want to ask a fundamental API question: do we want this API to be asynchronous? My instinct is that if we can do so it would be very valuable, but it does substantially raise the cost of implementation. The major advantage here is that it enables keys to be delegated to substantially more interesting places, such as cloud provider KMSes or other remote locations.
The big downside is that it forces the code path here to be made asynchronous, to tolerate resumption. What are your instincts here @camunro?
Support for External Signers in NIOSSHPrivateKey
Motivation
This PR enables hardware-backed authentication and remote identity protocols by allowing NIOSSHPrivateKey to delegate signing operations to external providers (e.g., Secure Enclave, TPM, or ssh-agent) without requiring raw private key material to be loaded into memory.
This is a foundational architectural change that enables several high-level features for the Swift ecosystem:
Modifications
NIOSSHPrivateKeyEvolution: Added an .external(NIOSSHExternalSigner) case to NIOSSHPrivateKey for all supported algorithms:Result
NIOSSH now supports public-key authentication where the signing operation is handled by an external delegate. This provides the critical architectural hook required for modern identity-aware SSH implementations (like #189) on both Apple and Linux platforms.