Example #1
0
        public void InitializedTest5()
        {
            try
            {
                ServiceLocatorWrapper.Reset();
                _unityServiceLocator = new UnityServiceLocator(
                    new UnityContainer()
                    /*.RegisterInstance<string>(Algorithms.Hash.ResolveName, "SHA1")*/
                    /*.RegisterType<HashAlgorithm, SHA512Cng>()*/);
                ServiceLocator.SetLocatorProvider(() => _unityServiceLocator);

                var target = new HashAlgorithmFactory();

                target.Initialize("SHA384");

                var hasher = target.Create();

                Assert.IsNotNull(hasher);
                Assert.IsInstanceOfType(hasher, typeof(SHA384));
            }
            finally
            {
                CleanupTest();
            }
        }
 /// <summary>
 /// Hashes the specified data bytes.
 /// </summary>
 /// <param name="hashBytes">Data to hash.</param>
 /// <returns>
 /// Hashed bytes
 /// </returns>
 protected override byte[] Hash(byte[] hashBytes)
 {
     using (var sha256 = HashAlgorithmFactory.CreateSHA256())
     {
         return(sha256.ComputeHash(hashBytes));
     }
 }
Example #3
0
        public void InitializedWithAlgorithmFromDITest()
        {
            try
            {
                InitializeHashAlgorithmTest();

                var target = new HashAlgorithmFactory();

                target.Initialize();
                var hasher1 = target.Create();

                Assert.IsNotNull(hasher1);

                var hasher2 = target.Create();

                Assert.IsNotNull(hasher2);
                Assert.IsFalse(object.ReferenceEquals(hasher1, hasher2));
                Assert.IsInstanceOfType(hasher1, typeof(MD5));
                Assert.IsInstanceOfType(hasher2, typeof(MD5));
            }
            finally
            {
                CleanupTest();
            }
        }
Example #4
0
 /// <summary>
 /// Hashes the specified data bytes.
 /// </summary>
 /// <param name="hashData">The hash data.</param>
 /// <returns>
 /// Hashed bytes
 /// </returns>
 protected virtual byte[] Hash(byte[] hashData)
 {
     using (var sha1 = HashAlgorithmFactory.CreateSHA1())
     {
         return(sha1.ComputeHash(hashData, 0, hashData.Length));
     }
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="KeyExchangeInitMessage"/> class.
        /// </summary>
        public KeyExchangeInitMessage()
        {
            var cookie = new byte[16];

            HashAlgorithmFactory.GenerateRandom(cookie);
            Cookie = cookie;
        }
Example #6
0
        protected override void ProcessRecordInEH()
        {
            string encodingName = EncodingName;

            if (string.IsNullOrWhiteSpace(encodingName))
            {
                encodingName = EncodingFactory.EncodingNames.UTF8;
            }

            Encoding encoding = EncodingFactory.Get(encodingName);

            if (encoding == null)
            {
                throw new PSArgumentException(string.Format("Unsupported encoding: {0}", encodingName));
            }

            HashAlgorithm algorithm = HashAlgorithmFactory.Create(Algorithm);

            if (algorithm == null)
            {
                throw new PSArgumentException(string.Format("Unsupported algorithm: {0}", Algorithm));
            }

            byte[] hashBuffer = HashGenerator.ComputeStringHash(InputObject, algorithm, encoding);

            HashResult result = new HashResult()
            {
                Algorithm  = Algorithm,
                Hash       = hashBuffer.ToHex(),
                HashBuffer = hashBuffer,
            };

            WriteObject(result);
        }
Example #7
0
 /// <summary>
 /// 取得雜湊結果
 /// </summary>
 /// <param name="data">要雜湊的資料</param>
 /// <returns>雜湊完畢的字串</returns>
 public string GetHash(string data)
 {
     using (var shaM = HashAlgorithmFactory.GetInstance(HashType))
     {
         var byteData = Encoding.UTF8.GetBytes(data);
         return(ConvertToText(shaM.ComputeHash(byteData)));
     }
 }
        public override string GetAlgorithmName(IComponentContext ctx)
        {
            var hash = HashAlgorithmFactory.GetHash(ctx, HeaderHasher);

            if (hash.GetType() == typeof(DigestReverser))
            {
                return(((DigestReverser)hash).Upstream.GetType().Name.ToLower());
            }

            return(hash.GetType().Name.ToLower());
        }
        protected override void SetupCrypto()
        {
            coinbaseHasher = HashAlgorithmFactory.GetHash(ctx, coin.CoinbaseHasher);
            headerHasher   = HashAlgorithmFactory.GetHash(ctx, coin.HeaderHasher);

            blockHasher = !isPoS?
                          HashAlgorithmFactory.GetHash(ctx, coin.BlockHasher) :
                              (HashAlgorithmFactory.GetHash(ctx, coin.CoinbaseHasher ?? coin.BlockHasher));

            ShareMultiplier = coin.ShareMultiplier;
        }
Example #10
0
        public void ShouldGenerateRandomSequenceOfValues()
        {
            var dataLength = new Random().Next(1, 100);
            var dataA      = new byte[dataLength];
            var dataB      = new byte[dataLength];

            HashAlgorithmFactory.GenerateRandom(dataA);
            HashAlgorithmFactory.GenerateRandom(dataB);

            Assert.IsFalse(dataA.SequenceEqual(dataB));
        }
Example #11
0
        public void HashAlgorithmFactoryTest1()
        {
            var algorithm = HashAlgorithmFactory.Create("md5");

            Assert.Equal(typeof(System.Security.Cryptography.MD5CryptoServiceProvider), algorithm.GetType());
            algorithm = HashAlgorithmFactory.Create("MD5");
            Assert.Equal(typeof(System.Security.Cryptography.MD5CryptoServiceProvider), algorithm.GetType());

            algorithm = HashAlgorithmFactory.Create("foo");
            Assert.Null(algorithm);

            Assert.Throws <ArgumentException>(() => { HashAlgorithmFactory.Create(""); });
        }
Example #12
0
        public void UninitializedTest()
        {
            try
            {
                var target = new HashAlgorithmFactory();

                target.Create();
            }
            finally
            {
                CleanupTest();
            }
        }
Example #13
0
    public BitcoinTemplate()
    {
        coinbaseHasherValue = new Lazy <IHashAlgorithm>(() =>
                                                        HashAlgorithmFactory.GetHash(ComponentContext, CoinbaseHasher));

        headerHasherValue = new Lazy <IHashAlgorithm>(() =>
                                                      HashAlgorithmFactory.GetHash(ComponentContext, HeaderHasher));

        blockHasherValue = new Lazy <IHashAlgorithm>(() =>
                                                     HashAlgorithmFactory.GetHash(ComponentContext, BlockHasher));

        posBlockHasherValue = new Lazy <IHashAlgorithm>(() =>
                                                        HashAlgorithmFactory.GetHash(ComponentContext, PoSBlockHasher));
    }
Example #14
0
        public void InitializedWithBadNameTest()
        {
            try
            {
                InitializeHashNameTest("MD5");

                var target = new HashAlgorithmFactory();

                target.Initialize("SHA123");
            }
            finally
            {
                CleanupTest();
            }
        }
Example #15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HostKeyEventArgs"/> class.
        /// </summary>
        /// <param name="host">The host.</param>
        public HostKeyEventArgs(KeyHostAlgorithm host)
        {
            CanTrust = true;   //  Set default value

            HostKey = host.Data;

            HostKeyName = host.Name;

            KeyLength = host.Key.KeyLength;

            using (var md5 = HashAlgorithmFactory.CreateMD5())
            {
                FingerPrint = md5.ComputeHash(host.Data);
            }
        }
Example #16
0
        public void ShouldThrowArgumentNullExceptionWhenDataIsNull()
        {
            const byte[] data = null;

            try
            {
                HashAlgorithmFactory.GenerateRandom(data);
                Assert.Fail();
            }
            catch (ArgumentNullException ex)
            {
                Assert.IsNull(ex.InnerException);
                Assert.AreEqual("data", ex.ParamName);
            }
        }
        public async Task EnsureHeader(HttpRequestMessage request, SigningSettings signingSettings, DateTimeOffset timeOfSigning)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }
            if (signingSettings == null)
            {
                throw new ArgumentNullException(nameof(signingSettings));
            }

            if (!request.Method.SupportsBody())
            {
                return;
            }
            if (string.IsNullOrEmpty(signingSettings.DigestHashAlgorithm.Name))
            {
                return;
            }
            if (request.Headers.Contains("Digest"))
            {
                return;
            }

            if (request.Content == null)
            {
                request.Headers.Add("Digest", string.Empty);
                return;
            }

            var bodyBytes = await request.Content.ReadAsByteArrayAsync().ConfigureAwait(false);

            using (var hashAlgorithm = HashAlgorithmFactory.Create(signingSettings.DigestHashAlgorithm)) {
                if (hashAlgorithm == null)
                {
                    throw new NotSupportedException($"The specified hash algorithm ({signingSettings.DigestHashAlgorithm.Name}) for digest is currently not supported.");
                }
                var payloadBytes        = hashAlgorithm.ComputeHash(bodyBytes);
                var digest              = _base64Converter.ToBase64(payloadBytes);
                var digestAlgorithmName = Constants.DigestHashAlgorithmNames[signingSettings.DigestHashAlgorithm.Name];
                request.Headers.Add("Digest", $"{digestAlgorithmName}={digest}");
            }
        }
Example #18
0
        public BitcoinTemplate()
        {
            coinbaseHasherValue = new Lazy <IHashAlgorithm>(() =>
            {
                if (CoinbaseHasher == null)
                {
                    return(null);
                }

                return(HashAlgorithmFactory.GetHash(ComponentContext, CoinbaseHasher));
            });

            headerHasherValue = new Lazy <IHashAlgorithm>(() =>
            {
                if (HeaderHasher == null)
                {
                    return(null);
                }

                return(HashAlgorithmFactory.GetHash(ComponentContext, HeaderHasher));
            });

            blockHasherValue = new Lazy <IHashAlgorithm>(() =>
            {
                if (BlockHasher == null)
                {
                    return(null);
                }

                return(HashAlgorithmFactory.GetHash(ComponentContext, BlockHasher));
            });

            posBlockHasherValue = new Lazy <IHashAlgorithm>(() =>
            {
                if (PoSBlockHasher == null)
                {
                    return(null);
                }

                return(HashAlgorithmFactory.GetHash(ComponentContext, PoSBlockHasher));
            });
        }
Example #19
0
        public void InitializedWithGoodNameTest()
        {
            try
            {
                InitializeHashNameTest("MD5");

                var target = new HashAlgorithmFactory();

                target.Initialize("SHA1");
                var hasher1 = target.Create();

                Assert.IsNotNull(hasher1);
                Assert.AreEqual("SHA1", target.HashAlgorithmName);

                var hasher2 = target.Create();

                Assert.IsNotNull(hasher2);
                Assert.AreNotEqual(hasher1, hasher2);
            }
            finally
            {
                CleanupTest();
            }
        }
Example #20
0
 new static public Bkdr Create(string hashName)
 {
     return((Bkdr)HashAlgorithmFactory.Create(hashName));
 }
Example #21
0
        internal byte[] GetPacket(byte paddingMultiplier, Compressor compressor)
        {
            const int outboundPacketSequenceSize = 4;

            var messageLength = BufferCapacity;

            SshDataStream sshDataStream;

            if (messageLength == -1 || compressor != null)
            {
                sshDataStream = new SshDataStream(DefaultCapacity);

                // skip:
                // * 4 bytes for the outbound packet sequence
                // * 4 bytes for the packet data length
                // * one byte for the packet padding length
                sshDataStream.Seek(outboundPacketSequenceSize + 4 + 1, SeekOrigin.Begin);

                if (compressor != null)
                {
                    // obtain uncompressed message payload
                    var uncompressedDataStream = new SshDataStream(messageLength != -1 ? messageLength : DefaultCapacity);
                    WriteBytes(uncompressedDataStream);

                    // compress message payload
                    var compressedMessageData = compressor.Compress(uncompressedDataStream.ToArray());

                    // add compressed message payload
                    sshDataStream.Write(compressedMessageData, 0, compressedMessageData.Length);
                }
                else
                {
                    // add message payload
                    WriteBytes(sshDataStream);
                }

                messageLength = (int)sshDataStream.Length - (outboundPacketSequenceSize + 4 + 1);

                var packetLength = messageLength + 4 + 1;

                // determine the padding length
                var paddingLength = GetPaddingLength(paddingMultiplier, packetLength);

                // add padding bytes
                var paddingBytes = new byte[paddingLength];
                HashAlgorithmFactory.GenerateRandom(paddingBytes);
                sshDataStream.Write(paddingBytes, 0, paddingLength);

                var packetDataLength = GetPacketDataLength(messageLength, paddingLength);

                // skip bytes for outbound packet sequence
                sshDataStream.Seek(outboundPacketSequenceSize, SeekOrigin.Begin);

                // add packet data length
                sshDataStream.Write(packetDataLength.GetBytes(), 0, 4);

                //  add packet padding length
                sshDataStream.WriteByte(paddingLength);
            }
            else
            {
                var packetLength = messageLength + 4 + 1;

                // determine the padding length
                var paddingLength = GetPaddingLength(paddingMultiplier, packetLength);

                var packetDataLength = GetPacketDataLength(messageLength, paddingLength);

                // lets construct an SSH data stream of the exact size required
                sshDataStream = new SshDataStream(packetLength + paddingLength + outboundPacketSequenceSize);

                // skip bytes for outbound packet sequenceSize
                sshDataStream.Seek(outboundPacketSequenceSize, SeekOrigin.Begin);

                // add packet data length
                sshDataStream.Write(packetDataLength.GetBytes(), 0, 4);

                //  add packet padding length
                sshDataStream.WriteByte(paddingLength);

                // add message payload
                WriteBytes(sshDataStream);

                // add padding bytes
                var paddingBytes = new byte[paddingLength];
                HashAlgorithmFactory.GenerateRandom(paddingBytes);
                sshDataStream.Write(paddingBytes, 0, paddingLength);
            }

            return(sshDataStream.ToArray());
        }
Example #22
0
        public override SignatureVerificationFailure VerifySync(HttpRequestForSigning signedRequest, Signature signature, Client client)
        {
            if (signature.Headers.Contains(HeaderName.PredefinedHeaderNames.Digest) &&
                !signedRequest.Headers.Contains(HeaderName.PredefinedHeaderNames.Digest))
            {
                return(SignatureVerificationFailure.HeaderMissing($"The {HeaderName.PredefinedHeaderNames.Digest} header is indicated as part of the signature, but it is not included in the request."));
            }

            if (!signedRequest.Headers.Contains(HeaderName.PredefinedHeaderNames.Digest))
            {
                _logger?.LogDebug("{0} header verification is not required, because it is not present in the request to verify.", HeaderName.PredefinedHeaderNames.Digest);
                return(null);
            }

            if (signedRequest.Body == null)
            {
                return(SignatureVerificationFailure.InvalidDigestHeader($"The {HeaderName.PredefinedHeaderNames.Digest} header verification failed. The request has no body."));
            }

            var digestHeaderValue = signedRequest.Headers.GetValues(HeaderName.PredefinedHeaderNames.Digest).FirstOrDefault();
            var digestParams      = new List <string>();

            if (!string.IsNullOrEmpty(digestHeaderValue))
            {
                var separatorIndex = digestHeaderValue.IndexOf('=');
                if (separatorIndex < 0 || separatorIndex >= digestHeaderValue.Length - 1)
                {
                    digestParams.Add(digestHeaderValue);
                }
                else
                {
                    digestParams.Add(digestHeaderValue.Substring(0, separatorIndex));
                    digestParams.Add(digestHeaderValue.Substring(separatorIndex + 1));
                }
            }

            if (digestParams.Count < 2)
            {
                return(SignatureVerificationFailure.InvalidDigestHeader($"The {HeaderName.PredefinedHeaderNames.Digest} request header is invalid."));
            }

            if (!Constants.DigestHashAlgorithms.TryGetValue(digestParams[0], out var digestAlgorithmName))
            {
                return(SignatureVerificationFailure.InvalidDigestHeader($"The {HeaderName.PredefinedHeaderNames.Digest} algorithm name ({digestParams[0] ?? "[null]"}) is invalid."));
            }

            using (var hashAlgorithm = HashAlgorithmFactory.Create(new HashAlgorithmName(digestAlgorithmName))) {
                if (hashAlgorithm == null)
                {
                    return(SignatureVerificationFailure.InvalidDigestHeader($"The {HeaderName.PredefinedHeaderNames.Digest} algorithm name ({digestParams[0] ?? "[null]"}) is currently not supported."));
                }

                var payloadBytes     = hashAlgorithm.ComputeHash(signedRequest.Body);
                var calculatedDigest = _base64Converter.ToBase64(payloadBytes);
                var receivedDigest   = digestParams[1];

                if (calculatedDigest != receivedDigest)
                {
                    return(SignatureVerificationFailure.InvalidDigestHeader("The digest header verification failed."));
                }
            }

            return(null);
        }
Example #23
0
        public void Test_HMac_Sha256_96_Connection()
        {
            var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);

            connectionInfo.HmacAlgorithms.Clear();
            connectionInfo.HmacAlgorithms.Add("hmac-sha2-256-96", new HashInfo(32 * 8, (key) => HashAlgorithmFactory.CreateHMACSHA256(key, 96)));

            using (var client = new SshClient(connectionInfo))
            {
                client.Connect();
                client.Disconnect();
            }
        }
Example #24
0
 new static public APHash Create(string hashName)
 {
     return((APHash)HashAlgorithmFactory.Create(hashName));
 }
Example #25
0
 public static new Fnv1a64 Create(string hashName)
 {
     return((Fnv1a64)HashAlgorithmFactory.Create(hashName));
 }
Example #26
0
 public static new Joaat Create(string hashName)
 {
     return((Joaat)HashAlgorithmFactory.Create(hashName));
 }
Example #27
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ConnectionInfo" /> class.
        /// </summary>
        /// <param name="host">Connection host.</param>
        /// <param name="port">Connection port.</param>
        /// <param name="username">Connection username.</param>
        /// <param name="proxyType">Type of the proxy.</param>
        /// <param name="proxyHost">The proxy host.</param>
        /// <param name="proxyPort">The proxy port.</param>
        /// <param name="proxyUsername">The proxy username.</param>
        /// <param name="proxyPassword">The proxy password.</param>
        /// <param name="authenticationMethods">The authentication methods.</param>
        /// <exception cref="ArgumentNullException"><paramref name="host"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException"><paramref name="username" /> is null, a zero-length string or contains only whitespace characters.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="port" /> is not within <see cref="F:System.Net.IPEndPoint.MinPort" /> and <see cref="F:System.Net.IPEndPoint.MaxPort" />.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="proxyType"/> is not <see cref="ProxyTypes.None"/> and <paramref name="proxyHost" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="proxyType"/> is not <see cref="ProxyTypes.None"/> and <paramref name="proxyPort" /> is not within <see cref="F:System.Net.IPEndPoint.MinPort" /> and <see cref="F:System.Net.IPEndPoint.MaxPort" />.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="authenticationMethods"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">No <paramref name="authenticationMethods"/> specified.</exception>
        public ConnectionInfo(string host, int port, string username, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername, string proxyPassword, params AuthenticationMethod[] authenticationMethods)
        {
            if (host == null)
            {
                throw new ArgumentNullException("host");
            }
            port.ValidatePort("port");

            if (username == null)
            {
                throw new ArgumentNullException("username");
            }
            if (username.All(char.IsWhiteSpace))
            {
                throw new ArgumentException("Cannot be empty or contain only whitespace.", "username");
            }

            if (proxyType != ProxyTypes.None)
            {
                if (proxyHost == null)
                {
                    throw new ArgumentNullException("proxyHost");
                }
                proxyPort.ValidatePort("proxyPort");
            }

            if (authenticationMethods == null)
            {
                throw new ArgumentNullException("authenticationMethods");
            }
            if (authenticationMethods.Length == 0)
            {
                throw new ArgumentException("At least one authentication method should be specified.", "authenticationMethods");
            }

            //  Set default connection values
            Timeout       = TimeSpan.FromSeconds(30);
            RetryAttempts = 10;
            MaxSessions   = 10;
            Encoding      = Encoding.UTF8;

            KeyExchangeAlgorithms = new Dictionary <string, Type>
            {
                { "diffie-hellman-group-exchange-sha256", typeof(KeyExchangeDiffieHellmanGroupExchangeSha256) },
                { "diffie-hellman-group-exchange-sha1", typeof(KeyExchangeDiffieHellmanGroupExchangeSha1) },
                { "diffie-hellman-group14-sha1", typeof(KeyExchangeDiffieHellmanGroup14Sha1) },
                { "diffie-hellman-group1-sha1", typeof(KeyExchangeDiffieHellmanGroup1Sha1) },
                //{"ecdh-sha2-nistp256", typeof(KeyExchangeEllipticCurveDiffieHellman)},
                //{"ecdh-sha2-nistp256", typeof(...)},
                //{"ecdh-sha2-nistp384", typeof(...)},
                //{"ecdh-sha2-nistp521", typeof(...)},
                //"gss-group1-sha1-toWM5Slw5Ew8Mqkay+al2g==" - WinSSHD
                //"gss-gex-sha1-toWM5Slw5Ew8Mqkay+al2g==" - WinSSHD
            };

            Encryptions = new Dictionary <string, CipherInfo>
            {
                { "aes256-ctr", new CipherInfo(256, (key, iv) => new AesCipher(key, new CtrCipherMode(iv), null)) },
                { "3des-cbc", new CipherInfo(192, (key, iv) => new TripleDesCipher(key, new CbcCipherMode(iv), null)) },
                { "aes128-cbc", new CipherInfo(128, (key, iv) => new AesCipher(key, new CbcCipherMode(iv), null)) },
                { "aes192-cbc", new CipherInfo(192, (key, iv) => new AesCipher(key, new CbcCipherMode(iv), null)) },
                { "aes256-cbc", new CipherInfo(256, (key, iv) => new AesCipher(key, new CbcCipherMode(iv), null)) },
                { "blowfish-cbc", new CipherInfo(128, (key, iv) => new BlowfishCipher(key, new CbcCipherMode(iv), null)) },
                { "twofish-cbc", new CipherInfo(256, (key, iv) => new TwofishCipher(key, new CbcCipherMode(iv), null)) },
                { "twofish192-cbc", new CipherInfo(192, (key, iv) => new TwofishCipher(key, new CbcCipherMode(iv), null)) },
                { "twofish128-cbc", new CipherInfo(128, (key, iv) => new TwofishCipher(key, new CbcCipherMode(iv), null)) },
                { "twofish256-cbc", new CipherInfo(256, (key, iv) => new TwofishCipher(key, new CbcCipherMode(iv), null)) },
                ////{"serpent256-cbc", typeof(CipherSerpent256CBC)},
                ////{"serpent192-cbc", typeof(...)},
                ////{"serpent128-cbc", typeof(...)},
                { "arcfour", new CipherInfo(128, (key, iv) => new Arc4Cipher(key, false)) },
                { "arcfour128", new CipherInfo(128, (key, iv) => new Arc4Cipher(key, true)) },
                { "arcfour256", new CipherInfo(256, (key, iv) => new Arc4Cipher(key, true)) },
                ////{"idea-cbc", typeof(...)},
                { "cast128-cbc", new CipherInfo(128, (key, iv) => new CastCipher(key, new CbcCipherMode(iv), null)) },
                ////{"*****@*****.**", typeof(...)},
                { "aes128-ctr", new CipherInfo(128, (key, iv) => new AesCipher(key, new CtrCipherMode(iv), null)) },
                { "aes192-ctr", new CipherInfo(192, (key, iv) => new AesCipher(key, new CtrCipherMode(iv), null)) },
            };

            HmacAlgorithms = new Dictionary <string, HashInfo>
            {
                { "hmac-md5", new HashInfo(16 * 8, HashAlgorithmFactory.CreateHMACMD5) },
                { "hmac-md5-96", new HashInfo(16 * 8, key => HashAlgorithmFactory.CreateHMACMD5(key, 96)) },
                { "hmac-sha1", new HashInfo(20 * 8, HashAlgorithmFactory.CreateHMACSHA1) },
                { "hmac-sha1-96", new HashInfo(20 * 8, key => HashAlgorithmFactory.CreateHMACSHA1(key, 96)) },
                { "hmac-sha2-256", new HashInfo(32 * 8, HashAlgorithmFactory.CreateHMACSHA256) },
                { "hmac-sha2-256-96", new HashInfo(32 * 8, key => HashAlgorithmFactory.CreateHMACSHA256(key, 96)) },
                { "hmac-sha2-512", new HashInfo(64 * 8, HashAlgorithmFactory.CreateHMACSHA512) },
                { "hmac-sha2-512-96", new HashInfo(64 * 8, key => HashAlgorithmFactory.CreateHMACSHA512(key, 96)) },
                //{"*****@*****.**", typeof(HMacSha1)},
                { "hmac-ripemd160", new HashInfo(160, HashAlgorithmFactory.CreateHMACRIPEMD160) },
                { "*****@*****.**", new HashInfo(160, HashAlgorithmFactory.CreateHMACRIPEMD160) },
                //{"none", typeof(...)},
            };

            HostKeyAlgorithms = new Dictionary <string, Func <byte[], KeyHostAlgorithm> >
            {
                { "ssh-rsa", data => new KeyHostAlgorithm("ssh-rsa", new RsaKey(), data) },
                { "ssh-dss", data => new KeyHostAlgorithm("ssh-dss", new DsaKey(), data) },
                //{"ecdsa-sha2-nistp256 "}
                //{"x509v3-sign-rsa", () => { ... },
                //{"x509v3-sign-dss", () => { ... },
                //{"spki-sign-rsa", () => { ... },
                //{"spki-sign-dss", () => { ... },
                //{"pgp-sign-rsa", () => { ... },
                //{"pgp-sign-dss", () => { ... },
            };

            CompressionAlgorithms = new Dictionary <string, Type>
            {
                //{"*****@*****.**", typeof(ZlibOpenSsh)},
                //{"zlib", typeof(Zlib)},
                { "none", null },
            };

            ChannelRequests = new Dictionary <string, RequestInfo>
            {
                { EnvironmentVariableRequestInfo.Name, new EnvironmentVariableRequestInfo() },
                { ExecRequestInfo.Name, new ExecRequestInfo() },
                { ExitSignalRequestInfo.Name, new ExitSignalRequestInfo() },
                { ExitStatusRequestInfo.Name, new ExitStatusRequestInfo() },
                { PseudoTerminalRequestInfo.Name, new PseudoTerminalRequestInfo() },
                { ShellRequestInfo.Name, new ShellRequestInfo() },
                { SignalRequestInfo.Name, new SignalRequestInfo() },
                { SubsystemRequestInfo.Name, new SubsystemRequestInfo() },
                { WindowChangeRequestInfo.Name, new WindowChangeRequestInfo() },
                { X11ForwardingRequestInfo.Name, new X11ForwardingRequestInfo() },
                { XonXoffRequestInfo.Name, new XonXoffRequestInfo() },
                { EndOfWriteRequestInfo.Name, new EndOfWriteRequestInfo() },
                { KeepAliveRequestInfo.Name, new KeepAliveRequestInfo() },
            };

            Host     = host;
            Port     = port;
            Username = username;

            ProxyType     = proxyType;
            ProxyHost     = proxyHost;
            ProxyPort     = proxyPort;
            ProxyUsername = proxyUsername;
            ProxyPassword = proxyPassword;

            AuthenticationMethods = authenticationMethods;
        }
Example #28
0
 new static public Dek Create(string hashName)
 {
     return((Dek)HashAlgorithmFactory.Create(hashName));
 }
Example #29
0
 public static new Sdbm Create(string hashName)
 {
     return((Sdbm)HashAlgorithmFactory.Create(hashName));
 }
Example #30
0
 public static new Adler32 Create(string hashName)
 {
     return((Adler32)HashAlgorithmFactory.Create(hashName));
 }