Example #1
0
        /// <summary>
        /// Dispose of any contained resources.
        /// </summary>
        public void Dispose()
        {
            if (m_rng != null)
            {
                m_rng.Dispose();
                m_rng = null;
            }

            if (m_remoteHash != null)
            {
                m_remoteHash.Dispose();
                m_remoteHash = null;
            }

            if (m_localHash != null)
            {
                m_localHash.Dispose();
                m_localHash = null;
            }

            if (m_prf != null)
            {
                m_prf.Dispose();
                m_prf = null;
            }
        }
Example #2
0
        public void Dispose()
        {
            if (m_decryptionBulkAlgorithm != null)
            {
                m_decryptionBulkAlgorithm.Dispose();
                m_decryptionBulkAlgorithm = null;
            }

            if (m_encryptionBulkAlgorithm != null)
            {
                m_encryptionBulkAlgorithm.Dispose();
                m_encryptionBulkAlgorithm = null;
            }

            if (m_decryptionHMAC != null)
            {
                m_decryptionHMAC.Dispose();
                m_decryptionHMAC = null;
            }

            if (m_encryptionHMAC != null)
            {
                m_encryptionHMAC.Dispose();
                m_encryptionHMAC = null;
            }

            if (PRF != null)
            {
                PRF.Dispose();
                PRF = null;
            }
        }
Example #3
0
        /// <summary>
        /// Dispose of all contained resources.
        /// </summary>
        public void Dispose()
        {
            if (m_decryptionBulkAlgorithm != null)
            {
#if NET40
                m_decryptionBulkAlgorithm.Dispose();
#else
                m_decryptionBulkAlgorithm.Clear();
#endif
                m_decryptionBulkAlgorithm = null;
            }

            if (m_encryptionBulkAlgorithm != null)
            {
#if NET40
                m_encryptionBulkAlgorithm.Dispose();
#else
                m_encryptionBulkAlgorithm.Clear();
#endif
                m_encryptionBulkAlgorithm = null;
            }

            if (m_decryptionHMAC != null)
            {
#if NET40
                m_decryptionHMAC.Dispose();
#else
                m_decryptionHMAC.Clear();
#endif
                m_decryptionHMAC = null;
            }

            if (m_encryptionHMAC != null)
            {
#if NET40
                m_encryptionHMAC.Dispose();
#else
                m_encryptionHMAC.Clear();
#endif
                m_encryptionHMAC = null;
            }

            if (PRF != null)
            {
                PRF.Dispose();
                PRF = null;
            }
        }
Example #4
0
        public void SetCipherSuite(CipherSuite suite, AsymmetricAlgorithm signAlgo)
        {
            CipherSuiteInfo info = SupportedCipherSuites.GetSuiteInfo(suite);

            if (info == null)
            {
                throw new NotSupportedException();
            }

            _bulk_cipher      = info.BulkCipherAlgorithm;
            _cipherType       = info.CipherType;
            _enc_key_length   = info.EncKeyLength;
            _block_length     = info.BlockLength;
            _fixed_iv_length  = info.FixedIVLength;
            _record_iv_length = info.RecordIVLength;
            _mac            = info.MACAlgorithm;
            _mac_length     = info.MACLength;
            _mac_key_length = info.MACKeyLength;
            _keyExchange    = info.KeyExchangeAlgorithm;

            // TODO: TLS1.2spec ?
            switch (_prfType)
            {
            case PRFAlgorithm.MD5_AND_SHA1: _prf = new MD5_AND_SHA1(); break;

            case PRFAlgorithm.SSL3: _prf = new SSL3_PRF(this); break;

            default: throw new NotSupportedException();
            }

            switch (_keyExchange)
            {
            case KeyExchangeAlgorithm.ECDHE_ECDSA:
                _keyExchanger = new ECDHE_ECDSA((openCrypto.EllipticCurve.Signature.ECDSA)signAlgo);
                break;

            case KeyExchangeAlgorithm.DHE_DSS:
                _keyExchanger = new DHE_DSS((DSACryptoServiceProvider)signAlgo);
                break;

            case KeyExchangeAlgorithm.RSA:
                _keyExchanger = new KeyExchange.RSA((RSACryptoServiceProvider)signAlgo);
                break;

            default:
                throw new NotImplementedException();
            }
        }
Example #5
0
        public void Dispose()
        {
            if (m_rng != null)
            {
                m_rng.Dispose();
                m_rng = null;
            }

            if (m_remoteHash != null)
            {
                m_remoteHash.Dispose();
                m_remoteHash = null;
            }

            if (m_localHash != null)
            {
                m_localHash.Dispose();
                m_localHash = null;
            }

            if(m_prf != null)
            {
                m_prf.Dispose();
                m_prf = null;
            }
        }
        public void SetCipherSuite(CipherSuite suite, AsymmetricAlgorithm signAlgo)
        {
            CipherSuiteInfo info = SupportedCipherSuites.GetSuiteInfo (suite);
            if (info == null)
                throw new NotSupportedException ();

            _bulk_cipher = info.BulkCipherAlgorithm;
            _cipherType = info.CipherType;
            _enc_key_length = info.EncKeyLength;
            _block_length = info.BlockLength;
            _fixed_iv_length = info.FixedIVLength;
            _record_iv_length = info.RecordIVLength;
            _mac = info.MACAlgorithm;
            _mac_length = info.MACLength;
            _mac_key_length = info.MACKeyLength;
            _keyExchange = info.KeyExchangeAlgorithm;

            // TODO: TLS1.2spec ?
            switch (_prfType) {
                case PRFAlgorithm.MD5_AND_SHA1: _prf = new MD5_AND_SHA1 (); break;
                case PRFAlgorithm.SSL3: _prf = new SSL3_PRF (this); break;
                default: throw new NotSupportedException ();
            }

            switch (_keyExchange) {
                case KeyExchangeAlgorithm.ECDHE_ECDSA:
                    _keyExchanger = new ECDHE_ECDSA ((openCrypto.EllipticCurve.Signature.ECDSA)signAlgo);
                    break;
                case KeyExchangeAlgorithm.DHE_DSS:
                    _keyExchanger = new DHE_DSS ((DSACryptoServiceProvider)signAlgo);
                    break;
                case KeyExchangeAlgorithm.RSA:
                    _keyExchanger = new KeyExchange.RSA ((RSACryptoServiceProvider)signAlgo);
                    break;
                default:
                    throw new NotImplementedException ();
            }
        }
Example #7
0
        /// <summary>
        /// Dispose of all contained resources.
        /// </summary>
        public void Dispose()
        {
            if (m_decryptionBulkAlgorithm != null)
            {
                m_decryptionBulkAlgorithm.Dispose();
                m_decryptionBulkAlgorithm = null;
            }

            if (m_encryptionBulkAlgorithm != null)
            {
                m_encryptionBulkAlgorithm.Dispose();
                m_encryptionBulkAlgorithm = null;
            }

            if (m_decryptionHMAC != null)
            {
                m_decryptionHMAC.Dispose();
                m_decryptionHMAC = null;
            }

            if (m_encryptionHMAC != null)
            {
                m_encryptionHMAC.Dispose();
                m_encryptionHMAC = null;
            }

            if (PRF != null)
            {
                PRF.Dispose();
                PRF = null;
            }
        }