@@ -31,6 +31,7 @@ use crypto::openssl;
31
31
use crypto:: table;
32
32
use crypto:: CryptoMode ;
33
33
use crypto:: rc4_md5;
34
+ use crypto:: dummy;
34
35
use crypto:: crypto:: CryptoCipher ;
35
36
36
37
use crypto:: digest:: { self , DigestType } ;
@@ -120,9 +121,12 @@ const CIPHER_CHACHA20: &'static str = "chacha20";
120
121
#[ cfg( feature = "cipher-salsa20" ) ]
121
122
const CIPHER_SALSA20 : & ' static str = "salsa20" ;
122
123
124
+ const CIPHER_DUMMY : & ' static str = "dummy" ;
125
+
123
126
#[ derive( Clone , Debug , Copy ) ]
124
127
pub enum CipherType {
125
128
Table ,
129
+ Dummy ,
126
130
127
131
#[ cfg( feature = "cipher-aes-cfb" ) ]
128
132
Aes128Cfb ,
@@ -157,6 +161,7 @@ impl CipherType {
157
161
pub fn block_size ( & self ) -> usize {
158
162
match * self {
159
163
CipherType :: Table => 0 ,
164
+ CipherType :: Dummy => 0 ,
160
165
161
166
#[ cfg( feature = "cipher-aes-cfb" ) ]
162
167
CipherType :: Aes128Cfb => symm:: Type :: AES_128_CFB128 . block_size ( ) ,
@@ -186,6 +191,7 @@ impl CipherType {
186
191
pub fn key_size ( & self ) -> usize {
187
192
match * self {
188
193
CipherType :: Table => 0 ,
194
+ CipherType :: Dummy => 0 ,
189
195
190
196
#[ cfg( feature = "cipher-aes-cfb" ) ]
191
197
CipherType :: Aes128Cfb => symm:: Type :: AES_128_CFB128 . key_len ( ) ,
@@ -243,6 +249,7 @@ impl CipherType {
243
249
pub fn iv_size ( & self ) -> usize {
244
250
match * self {
245
251
CipherType :: Table => 0 ,
252
+ CipherType :: Dummy => 0 ,
246
253
247
254
#[ cfg( feature = "cipher-aes-cfb" ) ]
248
255
CipherType :: Aes128Cfb => symm:: Type :: AES_128_CFB128 . iv_len ( ) . unwrap_or ( 0 ) ,
@@ -286,6 +293,7 @@ impl FromStr for CipherType {
286
293
fn from_str ( s : & str ) -> Result < CipherType , Error > {
287
294
match s {
288
295
CIPHER_TABLE | "" => Ok ( CipherType :: Table ) ,
296
+ CIPHER_DUMMY => Ok ( CipherType :: Dummy ) ,
289
297
#[ cfg( feature = "cipher-aes-cfb" ) ]
290
298
CIPHER_AES_128_CFB => Ok ( CipherType :: Aes128Cfb ) ,
291
299
#[ cfg( feature = "cipher-aes-cfb" ) ]
@@ -323,6 +331,7 @@ impl Display for CipherType {
323
331
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
324
332
match * self {
325
333
CipherType :: Table => write ! ( f, "{}" , CIPHER_TABLE ) ,
334
+ CipherType :: Dummy => write ! ( f, "{}" , CIPHER_DUMMY ) ,
326
335
#[ cfg( feature = "cipher-aes-cfb" ) ]
327
336
CipherType :: Aes128Cfb => write ! ( f, "{}" , CIPHER_AES_128_CFB ) ,
328
337
#[ cfg( feature = "cipher-aes-cfb" ) ]
@@ -400,6 +409,7 @@ macro_rules! define_ciphers {
400
409
401
410
define_ciphers ! {
402
411
TableCipher => table:: TableCipher ,
412
+ DummyCipher => dummy:: DummyCipher ,
403
413
Rc4Md5Cipher => rc4_md5:: Rc4Md5Cipher ,
404
414
OpenSSLCipher => openssl:: OpenSSLCipher ,
405
415
CryptoCipher => CryptoCipher ,
@@ -409,6 +419,7 @@ define_ciphers! {
409
419
pub fn with_type ( t : CipherType , key : & [ u8 ] , iv : & [ u8 ] , mode : CryptoMode ) -> CipherVariant {
410
420
match t {
411
421
CipherType :: Table => CipherVariant :: new ( table:: TableCipher :: new ( key, mode) ) ,
422
+ CipherType :: Dummy => CipherVariant :: new ( dummy:: DummyCipher ) ,
412
423
413
424
#[ cfg( feature = "cipher-chacha20" ) ]
414
425
CipherType :: ChaCha20 => CipherVariant :: new ( CryptoCipher :: new ( t, key, iv) ) ,
0 commit comments