66 html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg"
77) ]
88
9- mod error;
9+ #[ cfg( any( feature = "aes" , feature = "tdes" ) ) ]
10+ pub mod block_cipher;
1011
11- #[ cfg( feature = "aes" ) ]
12- mod aes;
1312#[ cfg( feature = "chacha20poly1305" ) ]
1413mod chacha20poly1305;
15- #[ cfg( any( feature = "aes" , feature = "tdes" ) ) ]
16- mod decryptor;
17- #[ cfg( any( feature = "aes" , feature = "tdes" ) ) ]
18- mod encryptor;
14+ mod error;
1915
2016pub use crate :: error:: { Error , Result } ;
2117pub use cipher;
2218
23- #[ cfg( any( feature = "aes" , feature = "tdes" ) ) ]
24- pub use crate :: { decryptor:: Decryptor , encryptor:: Encryptor } ;
25-
2619#[ cfg( feature = "chacha20poly1305" ) ]
2720pub use crate :: chacha20poly1305:: { ChaCha20 , ChaCha20Poly1305 , ChaChaKey , ChaChaNonce } ;
2821
2922use cipher:: array:: { Array , typenum:: U16 } ;
3023use core:: { fmt, str} ;
3124use encoding:: { Label , LabelError } ;
3225
26+ #[ cfg( any( feature = "aes" , feature = "chacha20poly1305" ) ) ]
27+ use aead:: { AeadInOut , KeyInit } ;
3328#[ cfg( feature = "aes" ) ]
3429use {
3530 aead:: array:: typenum:: U12 ,
3631 aes_gcm:: { Aes128Gcm , Aes256Gcm } ,
3732} ;
3833
39- #[ cfg( any( feature = "aes" , feature = "chacha20poly1305" ) ) ]
40- use aead:: { AeadInOut , KeyInit } ;
41-
4234/// AES-128 in block chaining (CBC) mode
4335const AES128_CBC : & str = "aes128-cbc" ;
44-
4536/// AES-192 in block chaining (CBC) mode
4637const AES192_CBC : & str = "aes192-cbc" ;
47-
4838/// AES-256 in block chaining (CBC) mode
4939const AES256_CBC : & str = "aes256-cbc" ;
5040
5141/// AES-128 in counter (CTR) mode
5242const AES128_CTR : & str = "aes128-ctr" ;
53-
5443/// AES-192 in counter (CTR) mode
5544const AES192_CTR : & str = "aes192-ctr" ;
56-
5745/// AES-256 in counter (CTR) mode
5846const AES256_CTR : & str = "aes256-ctr" ;
5947
6048/// AES-128 in Galois/Counter Mode (GCM).
6149const AES128_GCM : & str = "aes128-gcm@openssh.com" ;
62-
6350/// AES-256 in Galois/Counter Mode (GCM).
6451const AES256_GCM : & str = "aes256-gcm@openssh.com" ;
6552
@@ -81,7 +68,7 @@ pub type Tag = Array<u8, U16>;
8168
8269/// Cipher algorithms.
8370///
84- /// A "cipher" within the context of SSH was originally described in [RFC4253 § 6.3] in the context
71+ /// A "cipher" within the scope of SSH was originally described in [RFC4253 § 6.3] as a part of
8572/// of the packet encryption protocol, where it refers to the combination of a symmetric block
8673/// cipher, such as AES or 3DES, with a particular mode of operation, such as CBC or CTR.
8774///
@@ -313,16 +300,16 @@ impl Cipher {
313300 }
314301 }
315302
316- /// Get a stateful [`Decryptor`] for the given key and IV.
303+ /// Get a stateful [`block_cipher:: Decryptor`] for the given key and IV.
317304 ///
318305 /// Only applicable to unauthenticated modes (e.g. AES-CBC, AES-CTR). Not usable with
319306 /// authenticated modes which are inherently one-shot (AES-GCM, ChaCha20Poly1305).
320307 ///
321308 /// # Errors
322- /// Propagates errors from [`Decryptor::new`].
309+ /// Propagates errors from [`block_cipher:: Decryptor::new`].
323310 #[ cfg( any( feature = "aes" , feature = "tdes" ) ) ]
324- pub fn decryptor ( self , key : & [ u8 ] , iv : & [ u8 ] ) -> Result < Decryptor > {
325- Decryptor :: new ( self , key, iv)
311+ pub fn decryptor ( self , key : & [ u8 ] , iv : & [ u8 ] ) -> Result < block_cipher :: Decryptor > {
312+ block_cipher :: Decryptor :: new ( self , key, iv)
326313 }
327314
328315 /// Encrypt the ciphertext in the `buffer` in-place using this cipher.
@@ -373,16 +360,16 @@ impl Cipher {
373360 }
374361 }
375362
376- /// Get a stateful [`Encryptor`] for the given key and IV.
363+ /// Get a stateful [`block_cipher:: Encryptor`] for the given key and IV.
377364 ///
378365 /// Only applicable to unauthenticated modes (e.g. AES-CBC, AES-CTR). Not usable with
379366 /// authenticated modes which are inherently one-shot (AES-GCM, ChaCha20Poly1305).
380367 ///
381368 /// # Errors
382- /// Propagates errors from [`Encryptor::new`].
369+ /// Propagates errors from [`block_cipher:: Encryptor::new`].
383370 #[ cfg( any( feature = "aes" , feature = "tdes" ) ) ]
384- pub fn encryptor ( self , key : & [ u8 ] , iv : & [ u8 ] ) -> Result < Encryptor > {
385- Encryptor :: new ( self , key, iv)
371+ pub fn encryptor ( self , key : & [ u8 ] , iv : & [ u8 ] ) -> Result < block_cipher :: Encryptor > {
372+ block_cipher :: Encryptor :: new ( self , key, iv)
386373 }
387374
388375 /// Check that the key and IV are the expected length for this cipher.
0 commit comments