Because X509Certificates provided by Mono do not have value based hashcodes, we had to implement this special class that compares the Raw Data of a certificate. This class is thread-safe.
Example #1
0
        public void Reset()
        {
            lock (_sync) {
                _last_update = DateTime.UtcNow;
                _last_called_request_update = DateTime.UtcNow;

                _local_cert  = new WriteOnceX509();
                _remote_cert = new WriteOnceX509();
                DHEWithCertificateAndCAsInHash  = new WriteOnceIdempotent <MemBlock>();
                DHEWithCertificateAndCAsOutHash = new WriteOnceIdempotent <MemBlock>();
                DHEWithCertificateHash          = new WriteOnceIdempotent <MemBlock>();
                RDHE           = new WriteOnceIdempotent <MemBlock>();
                RemoteCookie   = new WriteOnceIdempotent <MemBlock>();
                _ldhe          = null;
                _hash_verified = false;
                _called_enable = 0;
                _receiving     = true;
                _sending       = true;
            }

            UpdateState(States.Active, States.Updating);
        }
Example #2
0
        ///<summary>This is called when we want to reset the state of the SA after
        ///an equivalent time of two timeouts has occurred.</summary>
        public bool Reset()
        {
            lock (_sync) {
                DateTime now = DateTime.UtcNow;
                // State is not reset if:
                // - It has been done within the past 120 seconds
                // - This is closed
                // - A packet has been received since the last SA check
                if ((_last_update != DateTime.MinValue &&
                     _last_update.AddSeconds(120) > now &&
                     State != States.Active) ||
                    _closed == 1 ||
                    (_receiving && State == States.Active))
                {
                    return(false);
                }

                _last_update = DateTime.UtcNow;
                _last_called_request_update = DateTime.UtcNow;

                _local_cert  = new WriteOnceX509();
                _remote_cert = new WriteOnceX509();
                DHEWithCertificateAndCAsInHash  = new WriteOnceIdempotent <MemBlock>();
                DHEWithCertificateAndCAsOutHash = new WriteOnceIdempotent <MemBlock>();
                DHEWithCertificateHash          = new WriteOnceIdempotent <MemBlock>();
                RDHE           = new WriteOnceIdempotent <MemBlock>();
                RemoteCookie   = new WriteOnceIdempotent <MemBlock>();
                _ldhe          = null;
                _hash_verified = false;
                _called_enable = 0;
                _receiving     = true;
                _sending       = true;
                _just_created  = true;
            }

            UpdateState(States.Active, States.Updating);
            return(true);
        }