Exemplo n.º 1
0
            public byte[] GetProtocolRawData()
            {
                byte[] nowVersion           = new byte[] { 0x03, 0x03 };
                byte[] nowRandom            = Random.CreatRandom();
                byte[] nowSessionID         = SessionID.CreatSessionID(28);
                byte[] nowCipherSuites      = CipherSuites.CreatCipherSuites();
                byte[] nowCompressionMethod = CompressionMethod.CreatCompressionMethod();
                byte[] nowExtention         = Extensions.CreatExtensions(hostName);
                //nowExtention = MyBytes.HexStringToByte("014c0000001c001a00001764617461756e696f6e2e62616977616e6469616e2e636e000500050100000000000a00080006001d00170018000b00020100000d00140012060106030401050102010403050302030202002300d0826acd16d68307143347c574ad11aabec8fb5237460655dfcbb28505c7941a0b80ee75db6b339ab2033e991c5cdb8a39748f313c0dfb08467646007170577fd9f395ff621fbf59cb1aea78081121e0f626d625aab620a760a44b18a14e6eb91dcea5356fdbf2d2f9afa0984ed00e356761ac5693b127b7e0824380eb1968d1a0c6a85ce8d4f532c895e0456a9d56820e57abdd86925d629ef86b75e5f9cea098750d789f5e47e7ec5dcd8bafca47b7709b47fd7ca1e0f258f9d16394923def423aa57cd72149edd10406d1cecc2b31ce0010000e000c02683208687474702f312e310017000000180006000a03020100ff01000100",
                //HexaDecimal.hex16, ShowHexMode.@null);

                byte[] nowClientHello = MyCommonHelper.MyBytes.GroupByteList(new List <byte[]> {
                    nowVersion, nowRandom, nowSessionID, nowCipherSuites, nowCompressionMethod, nowExtention
                });
                base.length = nowClientHello.Length;

                byte[] nowRawData = new byte[nowClientHello.Length + 4];
                nowRawData[0] = (byte)base.handshakeType;
                nowRawData[3] = BitConverter.GetBytes(base.length)[0];
                nowRawData[2] = BitConverter.GetBytes(base.length)[1];
                nowRawData[1] = BitConverter.GetBytes(base.length)[2];
                Array.Copy(nowClientHello, 0, nowRawData, 4, base.length);

                return(nowRawData);
            }
Exemplo n.º 2
0
        /* utility methods */
        public byte[] GetBytes()
        {
            byte[] result = new byte[this.GetLength()];
            int    offset = 0;

            System.Buffer.BlockCopy(version.GetBytes(), 0, result, offset, version.Length);
            offset += version.Length;

            System.Buffer.BlockCopy(random.GetBytes(), 0, result, offset, RandomUnit.Length);
            offset += RandomUnit.Length;

            System.Buffer.BlockCopy(sid.ToBytes(), 0, result, offset, sid.Length == 0 ? 1 : 0);
            offset += sid.Length == 0 ? 1 : 0;

            byte[] length = BitConverter.GetBytes((ushort)(2 * CipherSuites.Length));
            if (BitConverter.IsLittleEndian)
            {
                Array.Reverse(length);
            }

            System.Buffer.BlockCopy(length, 0, result, offset, 2);
            offset += 2;

            System.Buffer.BlockCopy(CipherSuites.GetSupportedSuitesInBytes(), 0, result, offset, (CipherSuites.Length * 2));
            offset += CipherSuites.Length * 2;

            System.Buffer.BlockCopy(CompressionList.ToBytes(), 0, result, offset, 1 + CompressionList.Length);
            offset += 1 + CompressionList.Length;

            return(result);
        }
Exemplo n.º 3
0
        public void ProcessServerHello(SessionID sid,
                                       byte[] serverRandom, ProtocolVersion serverVersion,
                                       TlsCipherSuite chosenSuite, TlsCompressionMethod chosenCompMethod)
        {
            if (m_HandshakePhase != HandshakeDataType.ClientHello)
            {
                throw new SslAlertException(AlertLevel.Fatal, AlertDescription.UnexpectedMessage);
            }

            m_Session.Id = sid;
            m_Session.CompressionMethod = chosenCompMethod;
            m_Session.IsResumable       = false;

            if (CipherSuites.IsSupported(chosenSuite))
            {
                m_Session.CipherSuite            = chosenSuite;
                m_SecurityParameters.CipherSuite = chosenSuite;
            }
            else
            {
                throw new SslAlertException(AlertLevel.Fatal, AlertDescription.HandshakeFailure);
            }

            /* TODO: Check for wrong version */
            if (serverVersion.Major != 3 || serverVersion.Minor != 1)
            {
                throw new SslAlertException(AlertLevel.Fatal, AlertDescription.HandshakeFailure);
            }

            m_SecurityParameters.ServerRandom = serverRandom;
            m_HandshakePhase = HandshakeDataType.ServerHello;
        }
Exemplo n.º 4
0
 private void _read()
 {
     _version            = new Version(m_io, this, m_root);
     _random             = new Random(m_io, this, m_root);
     _sessionId          = new SessionId(m_io, this, m_root);
     _cipherSuites       = new CipherSuites(m_io, this, m_root);
     _compressionMethods = new CompressionMethods(m_io, this, m_root);
     if (M_Io.IsEof == false)
     {
         _extensions = new Extensions(m_io, this, m_root);
     }
 }
Exemplo n.º 5
0
 private void _checkBoxTlsOld_CheckedChanged(object sender, EventArgs e)
 {
     _listViewCipherSuites.ListViewToCipherSuites(CipherSuites, _initializing);
     if (_checkBoxTlsOld.Checked)
     {
         CipherSuites.AddOldCipherSuites();
     }
     else
     {
         CipherSuites.RemoveOldCipherSuites();
     }
     _listViewCipherSuites.UpdateCipherSuitesListView(CipherSuites);
     _listViewCipherSuites.Focus();
 }
Exemplo n.º 6
0
        private void OptionsDialog_Load(object sender, EventArgs e)
        {
            _initializing = true;

            radioButtonIpv4.Checked     = (IpType == DicomNetIpTypeFlags.Ipv4);
            radioButtonIpv6.Checked     = (IpType == DicomNetIpTypeFlags.Ipv6);
            radioButtonIpv4Ipv6.Checked = (IpType == DicomNetIpTypeFlags.Ipv4OrIpv6);

            _listViewCipherSuites.InitializeCipherListView(CipherSuites, imageListCiphers);
            _checkBoxTlsOld.Checked = CipherSuites.ContainsOldCipherSuites();

            _initializing = false;
            EnableDialogItems();
        }
Exemplo n.º 7
0
        private void OptionsDialog_Load(object sender, EventArgs e)
        {
            _initializing                            = true;
            _textBoxClientAE.Text                    = ClientAE;
            _textBoxClientCertificate.Text           = ClientCertificate;
            _textBoxPrivateKey.Text                  = PrivateKey;
            _textBoxKeyPassword.Text                 = PrivateKeyPassword;
            _checkBoxLogLowLevel.Checked             = LogLowLevel;
            _checkBoxGroupLengthDataElements.Checked = GroupLengthDataElements;

            _listViewCipherSuites.InitializeCipherListView(CipherSuites, imageListCiphers);
            _checkBoxTlsOld.Checked = CipherSuites.ContainsOldCipherSuites();

            _initializing = false;
            EnableDialogItems();
        }
Exemplo n.º 8
0
 private void _read()
 {
     _version                  = m_io.ReadU2be();
     _random                   = new Random(m_io, this, m_root);
     _sessionId                = new SessionId(m_io, this, m_root);
     _cipherSuites             = new CipherSuites(m_io, this, m_root);
     _compressionMethodsLength = m_io.ReadU1();
     _compressionMethods       = new List <CompressionMethods>((int)(CompressionMethodsLength));
     for (var i = 0; i < CompressionMethodsLength; i++)
     {
         _compressionMethods.Add(((TlsPacket.CompressionMethods)m_io.ReadU1()));
     }
     if (M_Io.Size > M_Io.Pos)
     {
         _extensions = new TlsExtensions(m_io, this, m_root);
     }
 }
Exemplo n.º 9
0
            private void _read()
            {
                _version                  = new TlsVersion(m_io, this, m_root);
                _random                   = new Random(m_io, this, m_root);
                _sessionId                = new SessionId(m_io, this, m_root);
                _cipherSuites             = new CipherSuites(m_io, this, m_root);
                _compressionMethodsLength = m_io.ReadU1();
                _compressionMethods       = new List <CompressionMethods>((int)(CompressionMethodsLength));
                for (var i = 0; i < CompressionMethodsLength; i++)
                {
                    _compressionMethods.Add(((TlsPacket.CompressionMethods)m_io.ReadU1()));
                }
                _extensionsLength = m_io.ReadU2be();
                __raw_extensions  = m_io.ReadBytes(ExtensionsLength);
                var io___raw_extensions = new KaitaiStream(__raw_extensions);

                _extensions = new TlsExtensions(io___raw_extensions, this, m_root);
            }
Exemplo n.º 10
0
        private void OptionsDialog_Load(object sender, EventArgs e)
        {
            _initializing                            = true;
            _textBoxClientAE.Text                    = ClientAE;
            _textBoxClientPort.Text                  = ClientPort.ToString();
            _textBoxClientCertificate.Text           = ClientCertificate;
            _textBoxPrivateKey.Text                  = PrivateKey;
            _textBoxKeyPassword.Text                 = PrivateKeyPassword;
            _checkBoxLogLowLevel.Checked             = LogLowLevel;
            _checkBoxGroupLengthDataElements.Checked = GroupLengthDataElements;
            _radioButtonWaitForResults.Checked       = StorageCommitResultsOnSameAssociation;
            _radioButtonNoWaitForResults.Checked     = !StorageCommitResultsOnSameAssociation;
            switch (_compression)
            {
            case Leadtools.Dicom.Scu.Common.Compression.Native:
                _radioButtonCompressionNative.Checked = true;
                break;

            case Leadtools.Dicom.Scu.Common.Compression.Lossy:
                _radioButtonCompressionLossy.Checked = true;
                break;

            case Leadtools.Dicom.Scu.Common.Compression.Lossless:
                _radioButtonCompressionLossless.Checked = true;
                break;
            }
#if !LEADTOOLS_V19_OR_LATER
            _groupBoxStorageCommit.Visible   = false;
            this._groupMiscellaneous.Visible = false;
#endif

            _listViewCipherSuites.InitializeCipherListView(CipherSuites, imageListCiphers);
            _checkBoxTlsOld.Checked = CipherSuites.ContainsOldCipherSuites();

            _initializing = false;
            EnableDialogItems();
        }