public void Process(SenderKeyName senderKeyName, SenderKeyDistributionMessage senderKeyDistributionMessage)
        {
            lock (GroupCipher.LOCK)
            {
                var senderKeyRecord = _senderKeyStore.LoadSenderKey(senderKeyName);
                senderKeyRecord.AddSenderKeyState(senderKeyDistributionMessage.Id,
                                                  senderKeyDistributionMessage.Iteration,
                                                  senderKeyDistributionMessage.ChainKey,
                                                  senderKeyDistributionMessage.SignatureKey);

                _senderKeyStore.StoreSenderKey(senderKeyName, senderKeyRecord);
            }
        }
Example #2
0
        public void TestNoSession()
        {
            var aliceStore = new InMemorySenderKeyStore();
            var bobStore   = new InMemorySenderKeyStore();

            var aliceSessionBuilder = new GroupSessionBuilder(aliceStore);
            var bobSessionBuilder   = new GroupSessionBuilder(bobStore);

            var aliceGroupCipher = new GroupCipher(aliceStore, GROUP_SENDER);
            var bobGroupCipher   = new GroupCipher(bobStore, GROUP_SENDER);

            var sentAliceDistributionMessage     = aliceSessionBuilder.Create(GROUP_SENDER);
            var receivedAliceDistributionMessage = new SenderKeyDistributionMessage(sentAliceDistributionMessage.Serialize());

            bobSessionBuilder.Process(GROUP_SENDER, receivedAliceDistributionMessage);

            var ciphertextFromAlice = aliceGroupCipher.Encrypt (Encoding.UTF8.GetBytes ("smert ze smert"));
            try {
                var plaintextFromAlice  = bobGroupCipher.Decrypt(ciphertextFromAlice);
                throw new InvalidOperationException("Should be no session!");
            } catch (NoSessionException e) {
                Assert.Pass ();
            }
        }