This class is used to make signing certificates easier. The other method is to use the OpenSSL stack, which this has been verified to work with.
Inheritance: Certificate
Example #1
0
    public Simulator(Parameters parameters, bool do_not_start)
    {
      _parameters = parameters;
      StartingNetworkSize = parameters.Size;
      CurrentNetworkSize = 0;
      Nodes = new SortedList<Address, NodeMapping>();
      TakenIDs = new SortedList<int, NodeMapping>();
      SimBroadcastHandler = new SimpleFilter();

      if(parameters.Seed != -1) {
        _rand = new Random(parameters.Seed);
      } else {
        _rand = new Random();
      }

      BrunetNamespace = "testing" + _rand.Next();
      _broken = parameters.Broken;
      _secure_edges = parameters.SecureEdges;
      _secure_senders = parameters.SecureSenders;
      _pathing = parameters.Pathing;
      _dtls = parameters.Dtls;
      if(_secure_edges || _secure_senders) {
        _se_key = new RSACryptoServiceProvider();
        byte[] blob = _se_key.ExportCspBlob(false);
        RSACryptoServiceProvider rsa_pub = new RSACryptoServiceProvider();
        rsa_pub.ImportCspBlob(blob);
        CertificateMaker cm = new CertificateMaker("United States", "UFL", 
            "ACIS", "David Wolinsky", "[email protected]", rsa_pub,
            "brunet:node:abcdefghijklmnopqrs");
        Certificate cert = cm.Sign(cm, _se_key);
        _ca_cert = cert;
      }

      if(parameters.LatencyMap != null) {
        SimulationEdgeListener.LatencyMap = parameters.LatencyMap;
      }

      _start = parameters.Evaluation;
      if(!do_not_start) {
        Start();
      }
      _start = false;
    }
Example #2
0
    protected virtual StructuredNode PrepareNode(int id, AHAddress address)
    {
      if(TakenIDs.ContainsKey(id)) {
        throw new Exception("ID already taken");
      }

      StructuredNode node = new StructuredNode(address, BrunetNamespace);

      NodeMapping nm = new NodeMapping();
      nm.ID = id;
      TakenIDs[id] = nm;
      nm.Node = node;
      Nodes.Add((Address) address, nm);

      EdgeListener el = CreateEdgeListener(nm.ID);

      if(_secure_edges || _secure_senders) {
        byte[] blob = _se_key.ExportCspBlob(true);
        RSACryptoServiceProvider rsa_copy = new RSACryptoServiceProvider();
        rsa_copy.ImportCspBlob(blob);

        string username = address.ToString().Replace('=', '0');
        CertificateMaker cm = new CertificateMaker("United States", "UFL", 
          "ACIS", username, "[email protected]", rsa_copy,
          address.ToString());
        Certificate cert = cm.Sign(_ca_cert, _se_key);

        CertificateHandler ch = null;
        if(_dtls) {
          ch = new OpenSslCertificateHandler();
        } else {
          ch = new CertificateHandler();
        }
        ch.AddCACertificate(_ca_cert.X509);
        ch.AddSignedCertificate(cert.X509);

        if(_dtls) {
          nm.SO = new DtlsOverlord(rsa_copy, ch, PeerSecOverlord.Security);
        } else {
          nm.Sso = new SymphonySecurityOverlord(node, rsa_copy, ch, node.Rrm);
          nm.SO = nm.Sso;
        }

        var brh = new BroadcastRevocationHandler(_ca_cert, nm.SO);
        node.GetTypeSource(BroadcastRevocationHandler.PType).Subscribe(brh, null);
        ch.AddCertificateVerification(brh);
        nm.SO.Subscribe(node, null);
        node.GetTypeSource(PeerSecOverlord.Security).Subscribe(nm.SO, null);
      }

      if(_pathing) {
        nm.PathEM = new PathELManager(el, nm.Node);
        nm.PathEM.Start();
        el = nm.PathEM.CreatePath();
        PType path_p = PType.Protocol.Pathing;
        nm.Node.DemuxHandler.GetTypeSource(path_p).Subscribe(nm.PathEM, path_p);
      }

      if(_secure_edges) {
        node.EdgeVerifyMethod = EdgeVerify.AddressInSubjectAltName;
        el = new SecureEdgeListener(el, nm.SO);
      }

      node.AddEdgeListener(el);

      if(!_start) {
        node.RemoteTAs = GetRemoteTAs();
      }

      IRelayOverlap ito = null;
      if(NCEnable) {
        nm.NCService = new NCService(node, new Point());
// My evaluations show that when this is enabled the system sucks
//        (node as StructuredNode).Sco.TargetSelector = new VivaldiTargetSelector(node, ncservice);
        ito = new NCRelayOverlap(nm.NCService);
      } else {
        ito = new SimpleRelayOverlap();
      }

      if(_broken != 0) {
        el = new Relay.RelayEdgeListener(node, ito);
        if(_secure_edges) {
          el = new SecureEdgeListener(el, nm.SO);
        }
        node.AddEdgeListener(el);
      }

      BroadcastHandler bhandler = new BroadcastHandler(node as StructuredNode);
      node.DemuxHandler.GetTypeSource(BroadcastSender.PType).Subscribe(bhandler, null);
      node.DemuxHandler.GetTypeSource(SimBroadcastPType).Subscribe(SimBroadcastHandler, null);

      // Enables Dht data store
      new TableServer(node);
      nm.Dht = new Dht(node, 3, 20);
      nm.DhtProxy = new RpcDhtProxy(nm.Dht, node);
      return node;
    }
Example #3
0
 public void SecureStartup()
 {
   if(SEKey != null) {
     return;
   }
   SEKey = new RSACryptoServiceProvider();
   byte[] blob = SEKey.ExportCspBlob(false);
   RSACryptoServiceProvider rsa_pub = new RSACryptoServiceProvider();
   rsa_pub.ImportCspBlob(blob);
   CertificateMaker cm = new CertificateMaker("United States", "UFL", 
       "ACIS", "David Wolinsky", "[email protected]", rsa_pub,
       "brunet:node:abcdefghijklmnopqrs");
   Certificate cert = cm.Sign(cm, SEKey);
   CACert = cert;
 }
Example #4
0
 public void TestParse()
 {
   RSACryptoServiceProvider key = new RSACryptoServiceProvider();
   CertificateMaker cm = new CertificateMaker("United States", "UFL",
       "ACIS", "David Wolinsky", "[email protected]", key,
       "brunet:node:abcdefghijklmnopqrs");
   Certificate cert = cm.Sign(cm, key);
   UserRevocationMessage urm = new UserRevocationMessage(key, "David Wolinsky");
   UserRevocationMessage urm0 = new UserRevocationMessage(cert, MemBlock.Copy(urm));
   Assert.AreEqual(urm.Signature, urm0.Signature, "Signature");
   Assert.AreEqual(urm.Username, urm0.Username, "Username");
   Assert.AreEqual(urm.Hash, urm0.Hash, "Hash");
 }
Example #5
0
    protected virtual StructuredNode PrepareNode(int id, AHAddress address)
    {
      if(TakenIDs.Contains(id)) {
        throw new Exception("ID already taken");
      }

      StructuredNode node = new StructuredNode(address, BrunetNamespace);

      NodeMapping nm = new NodeMapping();
      TakenIDs[id] = nm.ID = id;
      nm.Node = node;
      Nodes.Add((Address) address, nm);

      EdgeListener el = CreateEdgeListener(nm.ID);

      if(SecureEdges || SecureSenders) {
        byte[] blob = SEKey.ExportCspBlob(true);
        RSACryptoServiceProvider rsa_copy = new RSACryptoServiceProvider();
        rsa_copy.ImportCspBlob(blob);

        CertificateMaker cm = new CertificateMaker("United States", "UFL", 
          "ACIS", "David Wolinsky", "[email protected]", rsa_copy,
          address.ToString());
        Certificate cert = cm.Sign(CACert, SEKey);

        CertificateHandler ch = new CertificateHandler();
        ch.AddCACertificate(CACert.X509);
        ch.AddSignedCertificate(cert.X509);

        ProtocolSecurityOverlord so = new ProtocolSecurityOverlord(node, rsa_copy, node.Rrm, ch);
        so.Subscribe(node, null);
        node.GetTypeSource(SecurityOverlord.Security).Subscribe(so, null);
        nm.BSO = so;
        node.HeartBeatEvent += so.Heartbeat;
      }

      if(SecureEdges) {
        node.EdgeVerifyMethod = EdgeVerify.AddressInSubjectAltName;
        el = new SecureEdgeListener(el, nm.BSO);
      }

      node.AddEdgeListener(el);

      node.RemoteTAs = GetRemoteTAs();

      ITunnelOverlap ito = null;
      if(NCEnable) {
        nm.NCService = new NCService(node, new Point());
// My evaluations show that when this is enabled the system sucks
//        (node as StructuredNode).Sco.TargetSelector = new VivaldiTargetSelector(node, ncservice);
        ito = new NCTunnelOverlap(nm.NCService);
      } else {
        ito = new SimpleTunnelOverlap();
      }

      if(Broken != 0) {
        el = new Tunnel.TunnelEdgeListener(node, ito);
        node.AddEdgeListener(el);
      }
      // Enables Dht data store
      new TableServer(node);
      return node;
    }