AaltoTLS.RecordLayer.RecordHandlerTest.TLSv10Test C# (CSharp) Method

TLSv10Test() private method

private TLSv10Test ( ) : void
return void
        public void TLSv10Test()
        {
            byte[] finished1eb1 = new byte[] {
                0x16, 0x03, 0x01, 0x00, 0x30, 0x78, 0x02, 0x93,
                0x89, 0x26, 0x70, 0xDD, 0x57, 0x12, 0xD5, 0x47,
                0xC5, 0xE3, 0x9E, 0xE7, 0x03, 0x2A, 0x41, 0x35,
                0x46, 0xE3, 0x13, 0x06, 0xBB, 0x4F, 0x21, 0xEB,
                0x3D, 0x5F, 0x42, 0xF6, 0xBF, 0x89, 0x4B, 0x43,
                0x8C, 0x77, 0x29, 0xF9, 0x54, 0xDC, 0xCB, 0x0E,
                0xE6, 0xA4, 0xA0, 0x13, 0xF8
            };
            byte[] finished1eb2 = new byte[] {
                0x16, 0x03, 0x01, 0x00, 0x40, 0x78, 0x02, 0x93,
                0x89, 0x26, 0x70, 0xdd, 0x57, 0x12, 0xd5, 0x47,
                0xc5, 0xe3, 0x9e, 0xe7, 0x03, 0x2a, 0x41, 0x35,
                0x46, 0xe3, 0x13, 0x06, 0xbb, 0x4f, 0x21, 0xeb,
                0x3d, 0x5f, 0x42, 0xf6, 0xbf, 0x1f, 0x91, 0x7c,
                0xf3, 0xf5, 0x07, 0x84, 0xc4, 0x51, 0x89, 0x73,
                0xbb, 0xb1, 0x88, 0x35, 0xcd, 0x21, 0xa9, 0x2a,
                0x1a, 0x08, 0xfc, 0x23, 0x4b, 0x9f, 0x9b, 0x0a,
                0x83, 0x47, 0x2c, 0x2e, 0x81
            };
            byte[] finished2eb = new byte[] {
                0x16, 0x03, 0x01, 0x00, 0x30, 0xde, 0x54, 0x89,
                0x2f, 0x60, 0x2f, 0x3e, 0x88, 0x6f, 0x78, 0xac,
                0xed, 0xf9, 0xf8, 0x56, 0x31, 0xbd, 0x55, 0x3f,
                0x7f, 0x82, 0x41, 0xfa, 0x49, 0x4c, 0x16, 0x01,
                0x13, 0x91, 0xcb, 0xcc, 0x78, 0x3f, 0x89, 0x86,
                0xaa, 0x58, 0xd1, 0x73, 0x76, 0xb3, 0xa2, 0x82,
                0x99, 0x02, 0x07, 0x95, 0x56
            };
            byte[] finished1db = new byte[] {
                0x16, 0x03, 0x01, 0x00, 0x10, 0x14, 0x00, 0x00,
                0x0C, 0x21, 0x39, 0xB0, 0xD0, 0x3F, 0x12, 0x1F,
                0x3B, 0x76, 0x1A, 0xE7, 0x71
            };
            byte[] finished2db = new byte[] {
                0x16, 0x03, 0x01, 0x00, 0x10, 0x14, 0x00, 0x00,
                0x0C, 0xDE, 0x0C, 0x18, 0x26, 0x54, 0x99, 0x6F,
                0x29, 0xA2, 0x72, 0x91, 0xC4
            };
            byte[] crandom = new byte[] {
                0x4e, 0x60, 0xe1, 0xed, 0x13, 0x2c, 0x19, 0xe5,
                0x44, 0xaf, 0xb2, 0xe1, 0x1d, 0x97, 0x67, 0x47,
                0xaf, 0x5a, 0xb8, 0xf4, 0x7e, 0xcb, 0xbe, 0x42,
                0x4f, 0x3b, 0x24, 0x9e, 0xff, 0x0f, 0x5d, 0x87
            };
            byte[] srandom = new byte[] {
                0x4e, 0x60, 0xe2, 0xa4, 0x9e, 0x37, 0xea, 0x2a,
                0xc1, 0xbe, 0xe9, 0x3d, 0x05, 0x04, 0xb9, 0x83,
                0x57, 0x2a, 0x03, 0xf0, 0x1a, 0x6a, 0xe5, 0x53,
                0x08, 0xa9, 0x01, 0xb0, 0x06, 0x2a, 0x9a, 0x79
            };
            byte[] master = new byte[] {
                0xB2, 0xEC, 0xD1, 0x59, 0x9C, 0x97, 0x49, 0x58,
                0xFB, 0x86, 0x9A, 0x65, 0xEB, 0x8F, 0x91, 0x31,
                0x54, 0xAC, 0x41, 0xCD, 0xF8, 0x12, 0x8F, 0xCA,
                0x25, 0xF0, 0x06, 0x91, 0xFE, 0xF3, 0x09, 0x7F,
                0x04, 0x6F, 0x9D, 0x75, 0x24, 0x52, 0xCD, 0xC5,
                0x69, 0xE2, 0x0C, 0xB2, 0xB3, 0xCD, 0xA0, 0x02
            };

            Record finished1 = GetRecord(finished1db);
            Record finished2 = GetRecord(finished2eb);

            CipherSuitePluginManager pluginManager = GetPluginManager();
            RecordHandler recordHandler = new RecordHandler(ProtocolVersion.SSL3_0, true);

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

            // Set correct cipher suite
            ConnectionState connectionState = new ConnectionState(crandom, srandom, master);
            recordHandler.SetCipherSuite(cipherSuite, connectionState);

            // Test that initial state doesn't modify records
            recordHandler.ProcessOutputRecord(finished1);
            recordHandler.ProcessInputRecord(finished2);
            Assert.AreEqual(finished1db, finished1.GetBytes());
            Assert.AreEqual(finished2eb, finished2.GetBytes());

            recordHandler.ChangeLocalState();
            recordHandler.ProcessOutputRecord(finished1);
            recordHandler.ChangeRemoteState();
            recordHandler.ProcessInputRecord(finished2);

            if (finished1.GetBytes().Length == finished1eb1.Length) {
                Assert.AreEqual(finished1eb1, finished1.GetBytes());
            } else {
                Assert.AreEqual(finished1eb2, finished1.GetBytes());
            }
            Assert.AreEqual(finished2db, finished2.GetBytes());
        }