Ejemplo n.º 1
0
        public void dual()
        {
            Key alicePrivate = new Key("alice private");
            Key alicePublic = alicePrivate.PublicKeyFor(KeyScheme.Sha1Dual);
            Key bobPrivate = new Key("bob private");
            Key bobPublic = bobPrivate.PublicKeyFor(KeyScheme.Sha1Dual);

            Keys aliceNtfnKeys = new Keys();
            aliceNtfnKeys.Add(KeyScheme.Sha1Dual, DualKeyScheme.Subset.Consumer, bobPublic);
            aliceNtfnKeys.Add(KeyScheme.Sha1Dual, DualKeyScheme.Subset.Producer, alicePrivate);

            Keys bobSubKeys = new Keys();
            bobSubKeys.Add(KeyScheme.Sha1Dual, DualKeyScheme.Subset.Consumer, bobPrivate);
            bobSubKeys.Add(KeyScheme.Sha1Dual, DualKeyScheme.Subset.Producer, alicePublic);

            Keys eveSubKeys = new Keys();
            Key randomPrivate = new Key("Not bob's key");
            eveSubKeys.Add(KeyScheme.Sha1Dual, DualKeyScheme.Subset.Consumer, randomPrivate);
            eveSubKeys.Add(KeyScheme.Sha1Dual, DualKeyScheme.Subset.Producer, randomPrivate.PublicKeyFor(KeyScheme.Sha1Dual));

            Assert.IsTrue(bobSubKeys.Match(aliceNtfnKeys));
            Assert.IsFalse(aliceNtfnKeys.Match(bobSubKeys));
            Assert.IsFalse(eveSubKeys.Match(aliceNtfnKeys));
        }
Ejemplo n.º 2
0
        public void producer()
        {
            Key alicePrivate = new Key("alice private");
            Key alicePublic = alicePrivate.PublicKeyFor(KeyScheme.Sha1Producer);

            Keys aliceNtfnKeys = new Keys();
            aliceNtfnKeys.Add(KeyScheme.Sha1Producer, alicePrivate);

            Keys bobSubKeys = new Keys();
            bobSubKeys.Add(KeyScheme.Sha1Producer, alicePublic);

            Keys eveSubKeys = new Keys();
            eveSubKeys.Add(KeyScheme.Sha1Producer, new Key("Not alice's key").PublicKeyFor(KeyScheme.Sha1Producer));

            Assert.IsTrue(bobSubKeys.Match(aliceNtfnKeys));
            Assert.IsFalse(eveSubKeys.Match(aliceNtfnKeys));
        }
Ejemplo n.º 3
0
        public void consumer()
        {
            Key bobPrivate = new Key("bob private");
            Key bobPublic = bobPrivate.PublicKeyFor(KeyScheme.Sha1Consumer);

            Keys aliceNtfnKeys = new Keys();
            aliceNtfnKeys.Add(KeyScheme.Sha1Consumer, bobPublic);

            Keys bobSubKeys = new Keys();
            bobSubKeys.Add(KeyScheme.Sha1Consumer, bobPrivate);

            Keys eveSubKeys = new Keys();
            eveSubKeys.Add(KeyScheme.Sha1Consumer, new Key("Not bob's key"));

            Assert.IsTrue(bobSubKeys.Match(aliceNtfnKeys));
            Assert.IsFalse(eveSubKeys.Match(aliceNtfnKeys));
        }