Brunet.Security.PeerSec.PeerSecOverlord.HandleControlCookieResponse C# (CSharp) Метод

HandleControlCookieResponse() защищенный Метод

2a) Receive a CookieResponse that contains a list of CAs, if you have a Certificate that supports one of the CAs send it along with a DHE and a list of your supported CAs in a DHEWithCertificateAndCAs.
protected HandleControlCookieResponse ( PeerSecAssociation sa, SecurityControlMessage scm, SecurityControlMessage scm_reply, ISender return_path, ISender low_level_sender ) : void
sa PeerSecAssociation A security association that we wish to perform the /// specified control operation on.
scm SecurityControlMessage The received SecurityControlMessage.
scm_reply SecurityControlMessage A prepared reply message (with headers and such.
return_path ISender Where to send the result.
low_level_sender ISender We expect the return_path to not be an edge or /// some other type of "low level" sender, so this contains the parsed out value.
Результат void
    protected void HandleControlCookieResponse(PeerSecAssociation sa,
        SecurityControlMessage scm, SecurityControlMessage scm_reply,
        ISender return_path, ISender low_level_sender)
    {
      ProtocolLog.WriteIf(ProtocolLog.Security, GetHashCode() + " Received CookieResponse from: " + low_level_sender);
      if(sa == null) {
        throw new Exception("No valid SA!");
      }
      // This seems like unnecessary code
      scm_reply.Type = SecurityControlMessage.MessageType.CookieResponse;
      X509Certificate lcert = null;
      if(SecurityPolicy.GetPolicy(scm.SPI).PreExchangedKeys) {
        lcert = _ch.DefaultCertificate;
      } else {
        lcert = _ch.FindCertificate(scm.CAs);
      }

      sa.RemoteCookie.Value = scm.LocalCookie;
      sa.LocalCertificate = lcert;
      scm_reply.Certificate = lcert.RawData;

      scm_reply.DHE = sa.LDHE;
      scm_reply.LocalCookie = scm.RemoteCookie;
      scm_reply.RemoteCookie = scm.LocalCookie;
      scm_reply.Type = SecurityControlMessage.MessageType.DHEWithCertificateAndCAs;
      if(SecurityPolicy.GetPolicy(scm.SPI).PreExchangedKeys) {
        scm_reply.CAs = new List<MemBlock>(0);
      } else {
        scm_reply.CAs = _ch.SupportedCAs;
      }
      HashAlgorithm sha1 = new SHA1CryptoServiceProvider();
      lock(_private_key_lock) {
        scm_reply.Sign(_private_key, sha1);
      }

      sa.DHEWithCertificateAndCAsOutHash.Value = sha1.ComputeHash((byte[]) scm_reply.Packet);
      ICopyable to_send = new CopyList(Security, SecureControl, scm_reply.Packet);
      _rrman.SendRequest(return_path, ReqrepManager.ReqrepType.Request,
          to_send, this, sa);
      ProtocolLog.WriteIf(ProtocolLog.Security, GetHashCode() + " Successful CookieResponse from: " + low_level_sender);
    }