Skip to content

Commit 04178d8

Browse files
Always use factories for HmacAlgorithms (#1262)
* Always use factories for HmacAlgorithms * Re-order HmacAlgorithms --------- Co-authored-by: Wojciech Nagórski <[email protected]>
1 parent f45af38 commit 04178d8

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/Renci.SshNet/ConnectionInfo.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -378,19 +378,21 @@ public ConnectionInfo(string host, int port, string username, ProxyTypes proxyTy
378378
{ "cast128-cbc", new CipherInfo(128, (key, iv) => new CastCipher(key, new CbcCipherMode(iv), padding: null)) },
379379
};
380380

381+
#pragma warning disable IDE0200 // Remove unnecessary lambda expression; We want to prevent instantiating the HashAlgorithm objects.
381382
HmacAlgorithms = new Dictionary<string, HashInfo>
382383
{
383-
{ "hmac-md5", new HashInfo(16*8, CryptoAbstraction.CreateHMACMD5) },
384-
{ "hmac-md5-96", new HashInfo(16*8, key => CryptoAbstraction.CreateHMACMD5(key, 96)) },
385-
{ "hmac-sha1", new HashInfo(20*8, CryptoAbstraction.CreateHMACSHA1) },
386-
{ "hmac-sha1-96", new HashInfo(20*8, key => CryptoAbstraction.CreateHMACSHA1(key, 96)) },
387-
{ "hmac-sha2-256", new HashInfo(32*8, CryptoAbstraction.CreateHMACSHA256) },
388-
{ "hmac-sha2-256-96", new HashInfo(32*8, key => CryptoAbstraction.CreateHMACSHA256(key, 96)) },
389-
{ "hmac-sha2-512", new HashInfo(64 * 8, CryptoAbstraction.CreateHMACSHA512) },
384+
{ "hmac-sha2-256", new HashInfo(32*8, key => CryptoAbstraction.CreateHMACSHA256(key)) },
385+
{ "hmac-sha2-512", new HashInfo(64 * 8, key => CryptoAbstraction.CreateHMACSHA512(key)) },
390386
{ "hmac-sha2-512-96", new HashInfo(64 * 8, key => CryptoAbstraction.CreateHMACSHA512(key, 96)) },
391-
{ "hmac-ripemd160", new HashInfo(160, CryptoAbstraction.CreateHMACRIPEMD160) },
392-
{ "[email protected]", new HashInfo(160, CryptoAbstraction.CreateHMACRIPEMD160) },
387+
{ "hmac-sha2-256-96", new HashInfo(32*8, key => CryptoAbstraction.CreateHMACSHA256(key, 96)) },
388+
{ "hmac-ripemd160", new HashInfo(160, key => CryptoAbstraction.CreateHMACRIPEMD160(key)) },
389+
{ "[email protected]", new HashInfo(160, key => CryptoAbstraction.CreateHMACRIPEMD160(key)) },
390+
{ "hmac-sha1", new HashInfo(20*8, key => CryptoAbstraction.CreateHMACSHA1(key)) },
391+
{ "hmac-sha1-96", new HashInfo(20*8, key => CryptoAbstraction.CreateHMACSHA1(key, 96)) },
392+
{ "hmac-md5", new HashInfo(16*8, key => CryptoAbstraction.CreateHMACMD5(key)) },
393+
{ "hmac-md5-96", new HashInfo(16*8, key => CryptoAbstraction.CreateHMACMD5(key, 96)) },
393394
};
395+
#pragma warning restore IDE0200 // Remove unnecessary lambda expression
394396

395397
HostKeyAlgorithms = new Dictionary<string, Func<byte[], KeyHostAlgorithm>>
396398
{

0 commit comments

Comments
 (0)