Пример #1
0
        private void SendKeyExchange()
        {
            var keyExchange = _cipherSuitesProvider.ResolveKeyExchange(_cipherSuiteConfig.CipherSuite);

            var messages = keyExchange.GenerateClientHandshakeMessages();

            foreach (var message in messages)
            {
                _writer.Write(message);
            }
        }
Пример #2
0
        public IState Run()
        {
            _versionConfig.Version = TLSVersion.TLS1_2;
            _randomConfig.Client   = GenerateClientRandom();

            var cipherSuites = _cipherSuitesProvider
                               .GetAllSupportedSuites(_cipherSuitesRegistry)
                               .ToArray();
            var compressionMethods = new[] { CompressionMethod.Null };

            var extensions      = _serviceProvider.ResolveAllExtensions();
            var extensionHellos = extensions.SelectMany(x => x.GenerateHelloExtensions()).ToArray();

            //TODO session id is not supported
            _sessionConfig.Id = new byte[0];

            var message = new ClientHelloMessage(
                version: _versionConfig.Version,
                randomBytes: _randomConfig.Client,
                sessionId: _sessionConfig.Id,
                extensions: extensionHellos,
                cipherSuites: cipherSuites,
                compressionMethods: compressionMethods);

            _writer.Write(message);

            return(_serviceProvider.GetRequiredService <WaitingForServerHelloState>());
        }
        public IState Run()
        {
            foreach (var message in CreateMessages())
            {
                _writer.Write(message);
            }

            return(_serviceProvider.GetRequiredService <SentServerHelloState>());
        }
Пример #4
0
        public IState Run()
        {
            SecurityAssert.Assert(_handshakeFinishedService.Verify(_handshake));

            _connection.WriteRecord(new Record(RecordType.ChangeCipherSpec, _versionConfig.Version, new byte[] { 1 }));
            _connection.RecordWriterStrategy = _cipherSuitesProvider.GetRecordWriterStrategy(_serviceProvider, _cipherSuiteConfig.CipherSuite);

            _writer.Write(_handshakeFinishedService.Generate());

            return(_serviceProvider.GetRequiredService <ActiveState>());
        }