@@ -43,22 +43,22 @@ public class ConnectionInfo : IConnectionInfoInternal
43
43
/// <summary>
44
44
/// Gets supported key exchange algorithms for this connection.
45
45
/// </summary>
46
- public IDictionary < string , Type > KeyExchangeAlgorithms { get ; private set ; }
46
+ public IDictionary < PriorityString , Type > KeyExchangeAlgorithms { get ; private set ; }
47
47
48
48
/// <summary>
49
49
/// Gets supported encryptions for this connection.
50
50
/// </summary>
51
- public IDictionary < string , CipherInfo > Encryptions { get ; private set ; }
51
+ public IDictionary < PriorityString , CipherInfo > Encryptions { get ; private set ; }
52
52
53
53
/// <summary>
54
54
/// Gets supported hash algorithms for this connection.
55
55
/// </summary>
56
- public IDictionary < string , HashInfo > HmacAlgorithms { get ; private set ; }
56
+ public IDictionary < PriorityString , HashInfo > HmacAlgorithms { get ; private set ; }
57
57
58
58
/// <summary>
59
59
/// Gets supported host key algorithms for this connection.
60
60
/// </summary>
61
- public IDictionary < string , Func < byte [ ] , KeyHostAlgorithm > > HostKeyAlgorithms { get ; private set ; }
61
+ public IDictionary < PriorityString , Func < byte [ ] , KeyHostAlgorithm > > HostKeyAlgorithms { get ; private set ; }
62
62
63
63
/// <summary>
64
64
/// Gets supported authentication methods for this connection.
@@ -321,12 +321,12 @@ public ConnectionInfo(string host, int port, string username, ProxyTypes proxyTy
321
321
MaxSessions = 10 ;
322
322
Encoding = Encoding . UTF8 ;
323
323
324
- KeyExchangeAlgorithms = new Dictionary < string , Type >
324
+ KeyExchangeAlgorithms = new Dictionary < PriorityString , Type >
325
325
{
326
- { "diffie-hellman-group-exchange-sha256" , typeof ( KeyExchangeDiffieHellmanGroupExchangeSha256 ) } ,
327
- { "diffie-hellman-group-exchange-sha1" , typeof ( KeyExchangeDiffieHellmanGroupExchangeSha1 ) } ,
328
- { "diffie-hellman-group14-sha1" , typeof ( KeyExchangeDiffieHellmanGroup14Sha1 ) } ,
329
- { "diffie-hellman-group1-sha1" , typeof ( KeyExchangeDiffieHellmanGroup1Sha1 ) } ,
326
+ { new PriorityString ( "diffie-hellman-group-exchange-sha256" , 10 ) , typeof ( KeyExchangeDiffieHellmanGroupExchangeSha256 ) } ,
327
+ { new PriorityString ( "diffie-hellman-group-exchange-sha1" , 5 ) , typeof ( KeyExchangeDiffieHellmanGroupExchangeSha1 ) } ,
328
+ { new PriorityString ( "diffie-hellman-group14-sha1" , 1 ) , typeof ( KeyExchangeDiffieHellmanGroup14Sha1 ) } ,
329
+ { new PriorityString ( "diffie-hellman-group1-sha1" , 1 ) , typeof ( KeyExchangeDiffieHellmanGroup1Sha1 ) } ,
330
330
//{"ecdh-sha2-nistp256", typeof(KeyExchangeEllipticCurveDiffieHellman)},
331
331
//{"ecdh-sha2-nistp256", typeof(...)},
332
332
//{"ecdh-sha2-nistp384", typeof(...)},
@@ -335,52 +335,52 @@ public ConnectionInfo(string host, int port, string username, ProxyTypes proxyTy
335
335
//"gss-gex-sha1-toWM5Slw5Ew8Mqkay+al2g==" - WinSSHD
336
336
} ;
337
337
338
- Encryptions = new Dictionary < string , CipherInfo >
338
+ Encryptions = new Dictionary < PriorityString , CipherInfo >
339
339
{
340
- { "aes256-ctr" , new CipherInfo ( 256 , ( key , iv ) => new AesCipher ( key , new CtrCipherMode ( iv ) , null ) ) } ,
341
- { "3des-cbc" , new CipherInfo ( 192 , ( key , iv ) => new TripleDesCipher ( key , new CbcCipherMode ( iv ) , null ) ) } ,
342
- { "aes128-cbc" , new CipherInfo ( 128 , ( key , iv ) => new AesCipher ( key , new CbcCipherMode ( iv ) , null ) ) } ,
343
- { "aes192-cbc" , new CipherInfo ( 192 , ( key , iv ) => new AesCipher ( key , new CbcCipherMode ( iv ) , null ) ) } ,
344
- { "aes256-cbc" , new CipherInfo ( 256 , ( key , iv ) => new AesCipher ( key , new CbcCipherMode ( iv ) , null ) ) } ,
345
- { "blowfish-cbc" , new CipherInfo ( 128 , ( key , iv ) => new BlowfishCipher ( key , new CbcCipherMode ( iv ) , null ) ) } ,
346
- { "twofish-cbc" , new CipherInfo ( 256 , ( key , iv ) => new TwofishCipher ( key , new CbcCipherMode ( iv ) , null ) ) } ,
347
- { "twofish192-cbc" , new CipherInfo ( 192 , ( key , iv ) => new TwofishCipher ( key , new CbcCipherMode ( iv ) , null ) ) } ,
348
- { "twofish128-cbc" , new CipherInfo ( 128 , ( key , iv ) => new TwofishCipher ( key , new CbcCipherMode ( iv ) , null ) ) } ,
349
- { "twofish256-cbc" , new CipherInfo ( 256 , ( key , iv ) => new TwofishCipher ( key , new CbcCipherMode ( iv ) , null ) ) } ,
340
+ { new PriorityString ( "aes256-ctr" , 100 ) , new CipherInfo ( 256 , ( key , iv ) => new AesCipher ( key , new CtrCipherMode ( iv ) , null ) ) } ,
341
+ { new PriorityString ( "3des-cbc" , 10 ) , new CipherInfo ( 192 , ( key , iv ) => new TripleDesCipher ( key , new CbcCipherMode ( iv ) , null ) ) } ,
342
+ { new PriorityString ( "aes128-cbc" , 90 ) , new CipherInfo ( 128 , ( key , iv ) => new AesCipher ( key , new CbcCipherMode ( iv ) , null ) ) } ,
343
+ { new PriorityString ( "aes192-cbc" , 91 ) , new CipherInfo ( 192 , ( key , iv ) => new AesCipher ( key , new CbcCipherMode ( iv ) , null ) ) } ,
344
+ { new PriorityString ( "aes256-cbc" , 92 ) , new CipherInfo ( 256 , ( key , iv ) => new AesCipher ( key , new CbcCipherMode ( iv ) , null ) ) } ,
345
+ { new PriorityString ( "blowfish-cbc" , 80 ) , new CipherInfo ( 128 , ( key , iv ) => new BlowfishCipher ( key , new CbcCipherMode ( iv ) , null ) ) } ,
346
+ { new PriorityString ( "twofish-cbc" , 70 ) , new CipherInfo ( 256 , ( key , iv ) => new TwofishCipher ( key , new CbcCipherMode ( iv ) , null ) ) } ,
347
+ { new PriorityString ( "twofish192-cbc" , 71 ) , new CipherInfo ( 192 , ( key , iv ) => new TwofishCipher ( key , new CbcCipherMode ( iv ) , null ) ) } ,
348
+ { new PriorityString ( "twofish128-cbc" , 72 ) , new CipherInfo ( 128 , ( key , iv ) => new TwofishCipher ( key , new CbcCipherMode ( iv ) , null ) ) } ,
349
+ { new PriorityString ( "twofish256-cbc" , 73 ) , new CipherInfo ( 256 , ( key , iv ) => new TwofishCipher ( key , new CbcCipherMode ( iv ) , null ) ) } ,
350
350
////{"serpent256-cbc", typeof(CipherSerpent256CBC)},
351
351
////{"serpent192-cbc", typeof(...)},
352
352
////{"serpent128-cbc", typeof(...)},
353
- { "arcfour" , new CipherInfo ( 128 , ( key , iv ) => new Arc4Cipher ( key , false ) ) } ,
354
- { "arcfour128" , new CipherInfo ( 128 , ( key , iv ) => new Arc4Cipher ( key , true ) ) } ,
355
- { "arcfour256" , new CipherInfo ( 256 , ( key , iv ) => new Arc4Cipher ( key , true ) ) } ,
353
+ { new PriorityString ( "arcfour" , 50 ) , new CipherInfo ( 128 , ( key , iv ) => new Arc4Cipher ( key , false ) ) } ,
354
+ { new PriorityString ( "arcfour128" , 51 ) , new CipherInfo ( 128 , ( key , iv ) => new Arc4Cipher ( key , true ) ) } ,
355
+ { new PriorityString ( "arcfour256" , 52 ) , new CipherInfo ( 256 , ( key , iv ) => new Arc4Cipher ( key , true ) ) } ,
356
356
////{"idea-cbc", typeof(...)},
357
- { "cast128-cbc" , new CipherInfo ( 128 , ( key , iv ) => new CastCipher ( key , new CbcCipherMode ( iv ) , null ) ) } ,
357
+ { new PriorityString ( "cast128-cbc" , 40 ) , new CipherInfo ( 128 , ( key , iv ) => new CastCipher ( key , new CbcCipherMode ( iv ) , null ) ) } ,
358
358
////{"rijndael-cbc@lysator.liu.se", typeof(...)},
359
- { "aes128-ctr" , new CipherInfo ( 128 , ( key , iv ) => new AesCipher ( key , new CtrCipherMode ( iv ) , null ) ) } ,
360
- { "aes192-ctr" , new CipherInfo ( 192 , ( key , iv ) => new AesCipher ( key , new CtrCipherMode ( iv ) , null ) ) } ,
359
+ { new PriorityString ( "aes128-ctr" , 98 ) , new CipherInfo ( 128 , ( key , iv ) => new AesCipher ( key , new CtrCipherMode ( iv ) , null ) ) } ,
360
+ { new PriorityString ( "aes192-ctr" , 99 ) , new CipherInfo ( 192 , ( key , iv ) => new AesCipher ( key , new CtrCipherMode ( iv ) , null ) ) } ,
361
361
} ;
362
362
363
- HmacAlgorithms = new Dictionary < string , HashInfo >
363
+ HmacAlgorithms = new Dictionary < PriorityString , HashInfo >
364
364
{
365
- { "hmac-md5" , new HashInfo ( 16 * 8 , CryptoAbstraction . CreateHMACMD5 ) } ,
366
- { "hmac-md5-96" , new HashInfo ( 16 * 8 , key => CryptoAbstraction . CreateHMACMD5 ( key , 96 ) ) } ,
367
- { "hmac-sha1" , new HashInfo ( 20 * 8 , CryptoAbstraction . CreateHMACSHA1 ) } ,
368
- { "hmac-sha1-96" , new HashInfo ( 20 * 8 , key => CryptoAbstraction . CreateHMACSHA1 ( key , 96 ) ) } ,
369
- { "hmac-sha2-256" , new HashInfo ( 32 * 8 , CryptoAbstraction . CreateHMACSHA256 ) } ,
370
- { "hmac-sha2-256-96" , new HashInfo ( 32 * 8 , key => CryptoAbstraction . CreateHMACSHA256 ( key , 96 ) ) } ,
371
- { "hmac-sha2-512" , new HashInfo ( 64 * 8 , CryptoAbstraction . CreateHMACSHA512 ) } ,
372
- { "hmac-sha2-512-96" , new HashInfo ( 64 * 8 , key => CryptoAbstraction . CreateHMACSHA512 ( key , 96 ) ) } ,
365
+ { new PriorityString ( "hmac-md5" , 1 ) , new HashInfo ( 16 * 8 , CryptoAbstraction . CreateHMACMD5 ) } ,
366
+ { new PriorityString ( "hmac-md5-96" , 0 ) , new HashInfo ( 16 * 8 , key => CryptoAbstraction . CreateHMACMD5 ( key , 96 ) ) } ,
367
+ { new PriorityString ( "hmac-sha1" , 50 ) , new HashInfo ( 20 * 8 , CryptoAbstraction . CreateHMACSHA1 ) } ,
368
+ { new PriorityString ( "hmac-sha1-96" , 49 ) , new HashInfo ( 20 * 8 , key => CryptoAbstraction . CreateHMACSHA1 ( key , 96 ) ) } ,
369
+ { new PriorityString ( "hmac-sha2-256" , 100 ) , new HashInfo ( 32 * 8 , CryptoAbstraction . CreateHMACSHA256 ) } ,
370
+ { new PriorityString ( "hmac-sha2-256-96" , 99 ) , new HashInfo ( 32 * 8 , key => CryptoAbstraction . CreateHMACSHA256 ( key , 96 ) ) } ,
371
+ { new PriorityString ( "hmac-sha2-512" , 100 ) , new HashInfo ( 64 * 8 , CryptoAbstraction . CreateHMACSHA512 ) } ,
372
+ { new PriorityString ( "hmac-sha2-512-96" , 99 ) , new HashInfo ( 64 * 8 , key => CryptoAbstraction . CreateHMACSHA512 ( key , 96 ) ) } ,
373
373
//{"umac-64@openssh.com", typeof(HMacSha1)},
374
- { "hmac-ripemd160" , new HashInfo ( 160 , CryptoAbstraction . CreateHMACRIPEMD160 ) } ,
375
- { "hmac-ripemd160@openssh.com" , new HashInfo ( 160 , CryptoAbstraction . CreateHMACRIPEMD160 ) } ,
374
+ { new PriorityString ( "hmac-ripemd160" , 40 ) , new HashInfo ( 160 , CryptoAbstraction . CreateHMACRIPEMD160 ) } ,
375
+ { new PriorityString ( "hmac-ripemd160@openssh.com" , 40 ) , new HashInfo ( 160 , CryptoAbstraction . CreateHMACRIPEMD160 ) } ,
376
376
//{"none", typeof(...)},
377
377
} ;
378
378
379
- HostKeyAlgorithms = new Dictionary < string , Func < byte [ ] , KeyHostAlgorithm > >
379
+ HostKeyAlgorithms = new Dictionary < PriorityString , Func < byte [ ] , KeyHostAlgorithm > >
380
380
{
381
- { "ssh-rsa" , data => new KeyHostAlgorithm ( "ssh-rsa" , new RsaKey ( ) , data , 2 ) } ,
382
- { "ssh-dss" , data => new KeyHostAlgorithm ( "ssh-dss" , new DsaKey ( ) , data , int . MaxValue ) } ,
383
- { "ssh-rsa-cert-v01@openssh.com" , data => new KeyHostAlgorithm ( "ssh-rsa-cert-v01@openssh.com" , new RsaCertV01Key ( ) , data , 3 ) }
381
+ { new PriorityString ( "ssh-rsa" , 50 ) , data => new KeyHostAlgorithm ( "ssh-rsa" , new RsaKey ( ) , data , 2 ) } ,
382
+ { new PriorityString ( "ssh-dss" , 49 ) , data => new KeyHostAlgorithm ( "ssh-dss" , new DsaKey ( ) , data , int . MaxValue ) } ,
383
+ { new PriorityString ( "ssh-rsa-cert-v01@openssh.com" , 100 ) , data => new CertificateKeyHostAlgorithm ( "ssh-rsa-cert-v01@openssh.com" , new RsaCertV01Key ( ) , data , 3 ) }
384
384
//{"ecdsa-sha2-nistp256 "}
385
385
//{"x509v3-sign-rsa", () => { ... },
386
386
//{"x509v3-sign-dss", () => { ... },
0 commit comments