Example #1
0
        private async Task SendClientChangeCipherSpec(CancellationToken token)
        {
            logger?.Debug("Sending change cipher spec to server...");

            // Create the change cipher spec protocol packet
            // NOTE: this has to be before recordHandler.ChangeLocalState since it uses the old state
            var record = new Record(
                RecordType.ChangeCipherSpec,
                _handshakeSession.NegotiatedVersion,
                new byte[] { 0x01 });

            _recordHandler.ProcessOutputRecord(record);

            // NOTE: keep this before recordHandler.ChangeLocalState since it may generate masterSecret
            _handshakeSession.LocalChangeCipherSpec();

            // Change cipher suite in record handler and handle it in handshake session
            _recordHandler.SetCipherSuite(_handshakeSession.CipherSuite, _handshakeSession.ConnectionState);
            _recordHandler.ChangeLocalState();

            // Send the change cipher spec protocol packet
            await _recordStream.SendAsync(new[] { record }, token);
        }
Example #2
0
        private void ProcessSendChangeCipherSpec(AsyncHandshakeResult asyncHandshakeResult)
        {
            // Create the change cipher spec protocol packet
            // NOTE: this has to be before recordHandler.ChangeLocalState since it uses the old state
            Record record = new Record(RecordType.ChangeCipherSpec,
                                       _handshakeSession.NegotiatedVersion,
                                       new byte[] { 0x01 });

            _recordHandler.ProcessOutputRecord(record);

            // NOTE: keep this before recordHandler.ChangeLocalState since it may generate masterSecret
            _handshakeSession.LocalChangeCipherSpec();

            // Change cipher suite in record handler and handle it in handshake session
            _recordHandler.SetCipherSuite(_handshakeSession.CipherSuite, _handshakeSession.ConnectionState);
            _recordHandler.ChangeLocalState();

            // Send the change cipher spec protocol packet
            _recordStream.BeginSend(new Record[] { record }, new AsyncCallback(SendHandshakeCallback), asyncHandshakeResult);
        }