Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

A collection of types for writing custom SSH agents and connecting to existing ones.

The types in this crate closely follow the [SSH Agent Protocol Internet Draft](https://datatracker.ietf.org/doc/html/draft-miller-ssh-agent) specification and can be used to utilize remote keys not supported by the default OpenSSH agent.
The types in this crate closely follow the [SSH Agent Protocol (RFC 9987)](https://www.rfc-editor.org/rfc/rfc9987.html) specification and can be used to utilize remote keys not supported by the default OpenSSH agent.

## Examples

Expand Down
4 changes: 2 additions & 2 deletions src/proto/extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub use self::message::*;

/// SSH agent protocol message extension
///
/// Described in [draft-miller-ssh-agent-14 § 3.8](https://www.ietf.org/archive/id/draft-miller-ssh-agent-14.html#section-3.8)
/// Described in [RFC9987 § 5.8](https://www.rfc-editor.org/rfc/rfc9987.html#section-5.8)
pub trait MessageExtension: 'static {
/// Extension name, indicating the type of the message (as a UTF-8 string).
///
Expand All @@ -19,7 +19,7 @@ pub trait MessageExtension: 'static {

/// SSH agent protocol key constraint extension
///
/// Described in [draft-miller-ssh-agent-14 § 3.2.7.3](https://www.ietf.org/archive/id/draft-miller-ssh-agent-14.html#section-3.2.7.3)
/// Described in [RFC9987 § 5.2.7.3](https://www.rfc-editor.org/rfc/rfc9987.html#section-5.2.7.3)
pub trait KeyConstraintExtension: 'static {
/// Extension name, indicating the type of the key constraint (as a UTF-8 string).
///
Expand Down
4 changes: 2 additions & 2 deletions src/proto/extension/message.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! SSH agent protocol extension messages
//!
//! Includes extension message definitions from both:
//! - [draft-miller-ssh-agent-14](https://www.ietf.org/archive/id/draft-miller-ssh-agent-14.html)
//! - [RFC9987](https://www.rfc-editor.org/rfc/rfc9987.html)
//! - [OpenSSH `PROTOCOL.agent`](https://github.com/openssh/openssh-portable/blob/cbbdf868bce431a59e2fa36ca244d5739429408d/PROTOCOL.agent)

use signature::Verifier;
Expand All @@ -16,7 +16,7 @@ use crate::proto::ProtoError;
/// An optional extension request "query" is defined to allow a
/// client to query which, if any, extensions are supported by an agent.
///
/// Described in [draft-miller-ssh-agent-14 § 3.8.1](https://www.ietf.org/archive/id/draft-miller-ssh-agent-14.html#section-3.8.1)
/// Described in [RFC9987 § 5.8.1](https://www.rfc-editor.org/rfc/rfc9987.html#section-5.8.1)
#[derive(Debug, Clone, PartialEq)]
pub struct QueryResponse {
/// List of supported message extension names
Expand Down
6 changes: 3 additions & 3 deletions src/proto/message/add_remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::proto::{Error, Result};
///
/// This structure is sent in a [`Request::AddIdentity`](super::Request::AddIdentity) (`SSH_AGENTC_ADD_IDENTITY`) message.
///
/// Described in [draft-miller-ssh-agent-14 § 3.2](https://www.ietf.org/archive/id/draft-miller-ssh-agent-14.html#section-3.2)
/// Described in [RFC9987 § 5.2](https://www.rfc-editor.org/rfc/rfc9987.html#section-5.2)
#[derive(Clone, PartialEq, Debug)]
pub struct AddIdentity {
/// A credential (private & public key, or private key / certificate) to add to the agent
Expand Down Expand Up @@ -46,7 +46,7 @@ impl Encode for AddIdentity {
///
/// This structure is sent in a [`Request::AddSmartcardKey`](super::Request::AddSmartcardKey) (`SSH_AGENTC_ADD_SMARTCARD_KEY`) message.
///
/// Described in [draft-miller-ssh-agent-14 § 3.2](https://www.ietf.org/archive/id/draft-miller-ssh-agent-14.html#section-3.2)
/// Described in [RFC9987 § 5.2](https://www.rfc-editor.org/rfc/rfc9987.html#section-5.2)
#[derive(Clone, Debug)]
pub struct SmartcardKey {
/// An opaque identifier for the hardware token
Expand Down Expand Up @@ -97,7 +97,7 @@ impl PartialEq for SmartcardKey {
///
/// This structure is sent in a [`Request::RemoveIdentity`](super::Request::RemoveIdentity) (`SSH_AGENTC_REMOVE_IDENTITY`) message.
///
/// Described in [draft-miller-ssh-agent-14 § 3.4](https://www.ietf.org/archive/id/draft-miller-ssh-agent-14.html#section-3.4)
/// Described in [RFC9987 § 5.4](https://www.rfc-editor.org/rfc/rfc9987.html#section-5.4)
#[derive(Clone, PartialEq, Debug)]
pub struct RemoveIdentity {
/// The public key portion of the [`Identity`](super::Identity) to be removed
Expand Down
6 changes: 3 additions & 3 deletions src/proto/message/add_remove/constrained.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl Decode for KeyConstraint {

fn decode(reader: &mut impl Reader) -> Result<Self> {
let constraint_type = u8::decode(reader)?;
// see: https://www.ietf.org/archive/id/draft-miller-ssh-agent-12.html#section-5.2
// see: https://www.rfc-editor.org/rfc/rfc9987.html#section-8.2
Ok(match constraint_type {
1 => KeyConstraint::Lifetime(u32::decode(reader)?),
2 => KeyConstraint::Confirm,
Expand Down Expand Up @@ -92,7 +92,7 @@ impl Encode for KeyConstraint {
///
/// This is a variant of [`Request::AddIdentity`](crate::proto::Request::AddIdentity) with a set of [`KeyConstraint`]s attached.
///
/// Described in [draft-miller-ssh-agent-14 § 3.2](https://www.ietf.org/archive/id/draft-miller-ssh-agent-14.html#section-3.2)
/// Described in [RFC9987 § 5.2](https://www.rfc-editor.org/rfc/rfc9987.html#section-5.2)
#[derive(Clone, PartialEq, Debug)]
pub struct AddIdentityConstrained {
/// The credential to be added to the agent.
Expand Down Expand Up @@ -145,7 +145,7 @@ impl Encode for AddIdentityConstrained {
///
/// This is a variant of [`Request::AddSmartcardKey`](crate::proto::Request::AddSmartcardKey) with a set of [`KeyConstraint`]s attached.
///
/// Described in [draft-miller-ssh-agent-14 § 3.2.6](https://www.ietf.org/archive/id/draft-miller-ssh-agent-14.html#section-3.2.6)
/// Described in [RFC9987 § 5.2.6](https://www.rfc-editor.org/rfc/rfc9987.html#section-5.2.6)
#[derive(Clone, PartialEq, Debug)]
pub struct AddSmartcardKeyConstrained {
/// A key stored on a hardware token.
Expand Down
2 changes: 1 addition & 1 deletion src/proto/message/extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::proto::{
///
/// This structure is sent as part of a [`Request::Extension`](super::Request::Extension) (`SSH_AGENT_EXTENSION_RESPONSE`) message.
///
/// Described in [draft-miller-ssh-agent-14 § 3.8](https://www.ietf.org/archive/id/draft-miller-ssh-agent-14.html#section-3.8).
/// Described in [RFC9987 § 5.8](https://www.rfc-editor.org/rfc/rfc9987.html#section-5.8).
#[derive(Clone, PartialEq, Debug)]
pub struct Extension {
/// Indicates the type of the extension message (as a UTF-8 string)
Expand Down
2 changes: 1 addition & 1 deletion src/proto/message/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::proto::{Error, Result};
///
/// A list of these structures are sent in a [`Response::IdentitiesAnswer`](super::Response::IdentitiesAnswer) (`SSH_AGENT_IDENTITIES_ANSWER`) message body.
///
/// Described in [draft-miller-ssh-agent-14 § 3.5](https://www.ietf.org/archive/id/draft-miller-ssh-agent-14.html#section-3.5)
/// Described in [RFC9987 § 5.5](https://www.rfc-editor.org/rfc/rfc9987.html#section-5.5)
#[derive(Clone, PartialEq, Debug)]
pub struct Identity {
/// A standard public-key encoding of an underlying key.
Expand Down
6 changes: 3 additions & 3 deletions src/proto/message/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::proto::{Error, Result};
///
/// These message types are sent from a client *to* an agent.
///
/// Described in [draft-miller-ssh-agent-14 § 3](https://www.ietf.org/archive/id/draft-miller-ssh-agent-14.html#section-3).
/// Described in [RFC9987 § 5](https://www.rfc-editor.org/rfc/rfc9987.html#section-5).
#[derive(Clone, PartialEq, Debug)]
#[non_exhaustive]
pub enum Request {
Expand Down Expand Up @@ -65,7 +65,7 @@ pub enum Request {
/// In other words, this is a fallback for message numbers that the
/// "SSH Agent Protocol Message Type Numbers" Registry ([RFC9987 § 9.2]) defines as:
/// * `Reserved` (1-4, 7-10, 15-16, and 24 (inclusive)),
/// * Notably (per [RFC9987 § 8.8.1]), this covers pre-RFC "legacy"
/// * Notably (per [RFC9987 § 8.1.1]), this covers pre-RFC "legacy"
/// (i.e. SSHv1 agent protocol) message types.
/// * `Private Use` (240-255), or
/// * Any ranges not explicitly defined.
Expand All @@ -77,7 +77,7 @@ pub enum Request {
///
/// [RFC9987 § 9.2]: https://www.rfc-editor.org/rfc/rfc9987.html#section-9.2
/// [RFC9987 § 5.1]: https://www.rfc-editor.org/rfc/rfc9987.html#section-5.1
/// [RFC9987 § 8.8.1]: https://www.rfc-editor.org/rfc/rfc9987.html#section-8.1.1
/// [RFC9987 § 8.1.1]: https://www.rfc-editor.org/rfc/rfc9987.html#section-8.1.1
Unknown {
/// The raw protocol message type that
/// could not be parsed.
Expand Down
2 changes: 1 addition & 1 deletion src/proto/message/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::proto::{Error, Result};
///
/// These message types are sent to a client *from* an agent (in response to a [`Request`](super::Request) message).
///
/// Described in [draft-miller-ssh-agent-14 § 3](https://www.ietf.org/archive/id/draft-miller-ssh-agent-14.html#section-3).
/// Described in [RFC9987 § 5](https://www.rfc-editor.org/rfc/rfc9987.html#section-5).
#[derive(Clone, PartialEq, Debug)]
#[non_exhaustive]
pub enum Response {
Expand Down
4 changes: 2 additions & 2 deletions src/proto/message/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::proto::{Error, Result};
///
/// This structure is sent in a [`Request::SignRequest`](super::Request::SignRequest) (`SSH_AGENTC_SIGN_REQUEST`) message.
///
/// Described in [draft-miller-ssh-agent-14 § 3.6](https://www.ietf.org/archive/id/draft-miller-ssh-agent-14.html#section-3.6)
/// Described in [RFC9987 § 5.6](https://www.rfc-editor.org/rfc/rfc9987.html#section-5.6)
#[derive(Clone, PartialEq, Debug)]
pub struct SignRequest {
/// The public key portion of the [`Identity`](super::Identity) in the agent to sign the data with
Expand All @@ -19,7 +19,7 @@ pub struct SignRequest {
pub data: Vec<u8>,

/// Signature flags, as described in
/// [draft-miller-ssh-agent-14 § 3.6.1](https://www.ietf.org/archive/id/draft-miller-ssh-agent-14.html#section-3.6.1)
/// [RFC9987 § 5.6.1](https://www.rfc-editor.org/rfc/rfc9987.html#section-5.6.1)
pub flags: u32,
}

Expand Down
4 changes: 2 additions & 2 deletions src/proto/signature.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! Agent protocol signature flag constants.

/// The `SSH_AGENT_RSA_SHA2_256` signature flag, as described in
/// [draft-miller-ssh-agent-14 § 3.6.1](https://www.ietf.org/archive/id/draft-miller-ssh-agent-14.html#section-3.6.1)
/// [RFC9987 § 5.6.1](https://www.rfc-editor.org/rfc/rfc9987.html#section-5.6.1)
pub const RSA_SHA2_256: u32 = 0x02;
/// The `SSH_AGENT_RSA_SHA2_512` signature flag, as described in
/// [draft-miller-ssh-agent-14 § 3.6.1](https://www.ietf.org/archive/id/draft-miller-ssh-agent-14.html#section-3.6.1)
/// [RFC9987 § 5.6.1](https://www.rfc-editor.org/rfc/rfc9987.html#section-5.6.1)
pub const RSA_SHA2_512: u32 = 0x04;
5 changes: 3 additions & 2 deletions tests/unknown_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
//! unknown type and keep the connection open, instead of dropping it.
//!
//! This mirrors the behaviour of OpenSSH's `ssh-agent` and is required by
//! [draft-miller-ssh-agent-14 § 4.1](https://www.ietf.org/archive/id/draft-miller-ssh-agent-14.html#section-4.1):
//! [RFC9987 § 5.1](https://www.rfc-editor.org/rfc/rfc9987.html#section-5.1):
//!
//! > SSH_AGENT_FAILURE messages are also sent in reply to requests with unknown types.
//! > SSH_AGENT_FAILURE messages MUST also be sent in reply to requests with
//! > unknown or unsupported types.
//!
//! Some clients (for example Ruby's `net-ssh`) probe the agent with a legacy
//! `SSH2_AGENT_REQUEST_VERSION` (type 1) message that most agents do not
Expand Down
Loading