A revocation message creator and parser.
Stores the user's name, a current time stamp, and a random number hashed together using SHA1 and signed by an RSA key.
Inheritance: ICopyable
        public void TestParse()
        {
            RSACryptoServiceProvider key = new RSACryptoServiceProvider();
            CertificateMaker         cm  = new CertificateMaker("United States", "UFL",
                                                                "ACIS", "David Wolinsky", "*****@*****.**", 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");
        }
Ejemplo n.º 2
0
    /// <summary>Parses an incoming revocation and updates the revoked users
    /// hashtable if successful.</summary>
    public void HandleData(MemBlock data, ISender ret, object state)
    {
      UserRevocationMessage urm = null;
      try {
        urm = new UserRevocationMessage(_ca_cert, data);
      } catch(Exception e) {
        ProtocolLog.WriteIf(ProtocolLog.SecurityExceptions, e.ToString());
        return;
      }


      lock(_revoked_users) {
        if(_revoked_users.Contains(urm.Username)) {
          return;
        }
        _revoked_users[urm.Username] = true;
      }

      _so.VerifySAs();
    }
        /// <summary>Parses an incoming revocation and updates the revoked users
        /// hashtable if successful.</summary>
        public void HandleData(MemBlock data, ISender ret, object state)
        {
            UserRevocationMessage urm = null;

            try {
                urm = new UserRevocationMessage(_ca_cert, data);
            } catch (Exception e) {
                ProtocolLog.WriteIf(ProtocolLog.SecurityExceptions, e.ToString());
                return;
            }


            lock (_revoked_users) {
                if (_revoked_users.Contains(urm.Username))
                {
                    return;
                }
                _revoked_users[urm.Username] = true;
            }

            _so.VerifySAs();
        }
Ejemplo n.º 4
0
    /// <summary>Revoke a random node from a random node.</summary>
    public NodeMapping Revoke(bool log)
    {
      NodeMapping revoked = Nodes.Values[_rand.Next(0, Nodes.Count)];
      NodeMapping revoker = Nodes.Values[_rand.Next(0, Nodes.Count)];
      while(revoked != revoker) {
        revoker = Nodes.Values[_rand.Next(0, Nodes.Count)];
      }
 
      string username = revoked.Node.Address.ToString().Replace('=', '0');
      UserRevocationMessage urm = new UserRevocationMessage(_se_key, username);
      BroadcastSender bs = new BroadcastSender(revoker.Node as StructuredNode);
      bs.Send(new CopyList(BroadcastRevocationHandler.PType, urm));
      if(log) {
        Console.WriteLine("Revoked: " + revoked.Node.Address);
      }
      return revoked;
    }
Ejemplo n.º 5
0
 public void TestParse()
 {
   RSACryptoServiceProvider key = new RSACryptoServiceProvider();
   CertificateMaker cm = new CertificateMaker("United States", "UFL",
       "ACIS", "David Wolinsky", "*****@*****.**", 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");
 }