AaltoTLS.RecordLayer.RecordHandler.ChangeRemoteState C# (CSharp) Метод

ChangeRemoteState() публичный Метод

public ChangeRemoteState ( ) : void
Результат void
        public void ChangeRemoteState()
        {
            _inputCipherSuite = _nextCipherSuite;
            _inputKeyBlock = _nextKeyBlock;
            _inputSequenceNumber = 0;
            _inputEpoch++;

            if (_isClient) {
                _inputHasher = _inputCipherSuite.MACAlgorithm.CreateHasher(_inputKeyBlock.ServerWriteMACKey);
                _decryptor = _inputCipherSuite.BulkCipherAlgorithm.CreateDecryptor(_inputKeyBlock.ServerWriteKey,
                                                                                   _inputKeyBlock.ServerWriteIV);

                _inputKey = _inputKeyBlock.ServerWriteKey;
                _inputFixedIV = _inputKeyBlock.ServerWriteIV;
            } else {
                _inputHasher = _inputCipherSuite.MACAlgorithm.CreateHasher(_inputKeyBlock.ClientWriteMACKey);
                _decryptor = _inputCipherSuite.BulkCipherAlgorithm.CreateDecryptor(_inputKeyBlock.ClientWriteKey,
                                                                                   _inputKeyBlock.ClientWriteIV);

                _inputKey = _inputKeyBlock.ClientWriteKey;
                _inputFixedIV = _inputKeyBlock.ClientWriteIV;
            }
        }

Usage Example

Пример #1
0
        public void PaddingTest()
        {
            CipherSuitePluginManager pluginManager = GetPluginManager();
            CipherSuite cipherSuite;

            RecordHandler clientHandler = new RecordHandler(ProtocolVersion.SSL3_0, true);
            RecordHandler serverHandler = new RecordHandler(ProtocolVersion.SSL3_0, false);

            cipherSuite = pluginManager.GetCipherSuite(ProtocolVersion.SSL3_0, 0x002f);
            Assert.IsNotNull(cipherSuite);

            ConnectionState connectionState = new ConnectionState(new byte[32], new byte[32], new byte[48]);

            clientHandler.SetCipherSuite(cipherSuite, connectionState);
            serverHandler.SetCipherSuite(cipherSuite, connectionState);
            clientHandler.ChangeLocalState();
            serverHandler.ChangeRemoteState();

            Record record = new Record(22, ProtocolVersion.SSL3_0);
            int blockSize = cipherSuite.BulkCipherAlgorithm.BlockSize;
            for (int i=0; i<blockSize*2; i++) {
                byte[] data = new byte[i];
                record.Fragment = (byte[])data.Clone();
                clientHandler.ProcessOutputRecord(record);
                Assert.AreEqual(0, record.Fragment.Length%blockSize);
                serverHandler.ProcessInputRecord(record);
                Assert.AreEqual(data, record.Fragment);
            }

            cipherSuite = pluginManager.GetCipherSuite(ProtocolVersion.TLS1_0, 0x002f);
            Assert.IsNotNull(cipherSuite);

            clientHandler.SetCipherSuite(cipherSuite, connectionState);
            serverHandler.SetCipherSuite(cipherSuite, connectionState);
            clientHandler.ChangeLocalState();
            serverHandler.ChangeRemoteState();

            record = new Record(22, ProtocolVersion.TLS1_0);
            for (int i=0; i<blockSize*2; i++) {
                byte[] data = new byte[i];
                record.Fragment = (byte[])data.Clone();
                clientHandler.ProcessOutputRecord(record);
                Assert.AreEqual(0, record.Fragment.Length%blockSize);
                serverHandler.ProcessInputRecord(record);
                Assert.AreEqual(data, record.Fragment);
            }

            cipherSuite = pluginManager.GetCipherSuite(ProtocolVersion.TLS1_2, 0x00a3);
            Assert.IsNotNull(cipherSuite);

            clientHandler.SetCipherSuite(cipherSuite, connectionState);
            serverHandler.SetCipherSuite(cipherSuite, connectionState);
            clientHandler.ChangeLocalState();
            serverHandler.ChangeRemoteState();

            record = new Record(22, ProtocolVersion.TLS1_2);
            for (int i=0; i<blockSize*2; i++) {
                byte[] data = new byte[i];
                record.Fragment = (byte[])data.Clone();
                clientHandler.ProcessOutputRecord(record);
                Assert.AreEqual(8+data.Length+16, record.Fragment.Length);
                serverHandler.ProcessInputRecord(record);
                Assert.AreEqual(data, record.Fragment);
            }
        }
All Usage Examples Of AaltoTLS.RecordLayer.RecordHandler::ChangeRemoteState