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

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

3a) Receive a DHEWithCertificate, verify the certificate and DHE and send a Confirm that you are ready to Verify the stack and start the system.
protected HandleControlDHEWithCertificate ( 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 HandleControlDHEWithCertificate(PeerSecAssociation sa,
        SecurityControlMessage scm, SecurityControlMessage scm_reply,
        ISender return_path, ISender low_level_sender)
    {
      ProtocolLog.WriteIf(ProtocolLog.Security, GetHashCode() + " Received DHEWithCertificate from: " + low_level_sender);
      if(sa == null) {
        throw new Exception("No valid SA!");
      }
      byte[] cert = new byte[scm.Certificate.Length];
      scm.Certificate.CopyTo(cert, 0);
      X509Certificate rcert = new X509Certificate(cert);
      HashAlgorithm sha1 = new SHA1CryptoServiceProvider();
      scm.Verify((RSACryptoServiceProvider) rcert.RSA, sha1);
      _ch.Verify(rcert, low_level_sender);

      sa.RemoteCertificate = rcert;
      sa.RDHE.Value = scm.DHE;

      scm_reply.LocalCookie = scm.RemoteCookie;
      scm_reply.RemoteCookie = scm.LocalCookie;
      scm_reply.Hash = MemBlock.Reference(sha1.ComputeHash((byte[]) scm.Packet));
      scm_reply.Type = SecurityControlMessage.MessageType.Confirm;
      lock(_private_key_lock) {
        scm_reply.Sign(_private_key, sha1);
      }

      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 DHEWithCertificate from: " + low_level_sender);
    }