@@ -78,40 +78,73 @@ pub type AesGcmNonce = Array<u8, U12>;
7878pub type Tag = Array < u8 , U16 > ;
7979
8080/// Cipher algorithms.
81+ ///
82+ /// A "cipher" within the context of SSH was originally described in [RFC4253 § 6.3] in the context
83+ /// of the packet encryption protocol, where it refers to the combination of a symmetric block
84+ /// cipher, such as AES or 3DES, with a particular mode of operation, such as CBC or CTR.
85+ ///
86+ /// This has been subsequently expanded by other standards documents, and now includes modern
87+ /// authenticated or "AEAD" modes such as AES-GCM and ChaCha20Poly1305, which we recommend and are
88+ /// marked with a ✅ in the table below.
89+ ///
90+ /// Below is a table of the ciphers we support and what standards document defines them, along with
91+ /// which crate feature needs to be enabled to perform encryption with a given algorithm:
92+ ///
93+ /// | Cipher name | Feature | AEAD | Algorithm | Standard
94+ /// |---------------------------------|---------|------|-------------|---------
95+ /// | `3des-cbc` | `tdes` | ⛔ | 3DES-CBC | [RFC4253 § 6.3]
96+ /// | `aes128‑cbc` | `aes` | ⛔ | AES-128-CBC | [RFC4253 § 6.3]
97+ /// | `aes192‑cbc` | `aes` | ⛔ | AES-192-CBC | [RFC4253 § 6.3]
98+ /// | `aes256‑cbc` | `aes` | ⛔ | AES-256-CBC | [RFC4253 § 6.3]
99+ /// | `aes128‑ctr` | `aes` | ⛔ | AES-128-CTR | [RFC4344]
100+ /// | `aes192‑ctr` | `aes` | ⛔ | AES-192-CTR | [RFC4344]
101+ /// | `aes256‑ctr` | `aes` | ⛔ | AES-256-CTR | [RFC4344]
102+ /// | `aes128‑gcm@openssh.com` | `aes` | ✅ | AES-128-GCM | [RFC5647]
103+ /// | `aes256‑gcm@openssh.com` | `aes` | ✅ | AES-256-GCM | [RFC5647]
104+ /// | `chacha20‑poly1305@openssh.com` | `chacha20poly1305` | ✅ | ChaCha20Poly1305† | [PROTOCOL.chacha20poly1305]
105+ ///
106+ /// † The construction called "ChaCha20Poly1305" as used by OpenSSH is different from other
107+ /// constructions with that name including the one defined in RFC8439 and the one found in NaCl
108+ /// variants like libsodium. See [`ChaCha20Poly1305`] for more information.
109+ ///
110+ /// [RFC4253 § 6.3]: https://datatracker.ietf.org/doc/html/rfc4253#section-6.3
111+ /// [RFC4344]: https://datatracker.ietf.org/doc/html/rfc4344
112+ /// [RFC5647]: https://datatracker.ietf.org/doc/html/rfc5647
113+ /// [PROTOCOL.chacha20poly1305]: https://web.mit.edu/freebsd/head/crypto/openssh/PROTOCOL.chacha20poly1305
81114#[ derive( Copy , Clone , Debug , Eq , Hash , PartialEq , PartialOrd , Ord ) ]
82115#[ non_exhaustive]
83116pub enum Cipher {
84- /// No cipher.
117+ /// `none`: no cipher.
85118 None ,
86119
87- /// AES-128 in cipher block chaining (CBC) mode.
120+ /// `aes128-cbc`: AES-128 in cipher block chaining (CBC) mode.
88121 Aes128Cbc ,
89122
90- /// AES-192 in cipher block chaining (CBC) mode.
123+ /// `aes192-cbc`: AES-192 in cipher block chaining (CBC) mode.
91124 Aes192Cbc ,
92125
93- /// AES-256 in cipher block chaining (CBC) mode.
126+ /// `aes256-cbc`: AES-256 in cipher block chaining (CBC) mode.
94127 Aes256Cbc ,
95128
96- /// AES-128 in counter (CTR) mode.
129+ /// `aes128-ctr`: AES-128 in counter (CTR) mode.
97130 Aes128Ctr ,
98131
99- /// AES-192 in counter (CTR) mode.
132+ /// `aes192-ctr`: AES-192 in counter (CTR) mode.
100133 Aes192Ctr ,
101134
102- /// AES-256 in counter (CTR) mode.
135+ /// `aes256-ctr`: AES-256 in counter (CTR) mode.
103136 Aes256Ctr ,
104137
105- /// AES-128 in Galois/Counter Mode (GCM).
138+ /// `aes128-gcm@openssh.com`: AES-128 in Galois/Counter Mode (GCM).
106139 Aes128Gcm ,
107140
108- /// AES-256 in Galois/Counter Mode (GCM).
141+ /// `aes256-gcm@openssh.com`: AES-256 in Galois/Counter Mode (GCM).
109142 Aes256Gcm ,
110143
111- /// ChaCha20-Poly1305
144+ /// `chacha20-poly1305@openssh.com`: ChaCha20-Poly1305
112145 ChaCha20Poly1305 ,
113146
114- /// TripleDES in block chaining (CBC) mode
147+ /// `3des-cbc`: TripleDES in block chaining (CBC) mode
115148 TDesCbc ,
116149}
117150
0 commit comments