Ejemplo n.º 1
0
        public static void TestExecution()
        {
            TheBallEKE bobInstance = new TheBallEKE();
            bobInstance.InitiateCurrentSymmetricFromSecret("testsecret2");
            EKEBob bob = new EKEBob(ekeContext: bobInstance);

            TheBallEKE aliceInstance = new TheBallEKE();
            aliceInstance.InitiateCurrentSymmetricFromSecret("testsecret2");
            EKEAlice alice = new EKEAlice(ekeContext: aliceInstance);
            // Hook message senders
            alice.SendMessageToOtherParty = msg =>
                {
                    bob.LatestMessageFromOtherParty = msg;
                };
            bob.SendMessageToOtherParty = msg =>
                {
                    alice.LatestMessageFromOtherParty = msg;
                };
            bool ekeInProgress = true;
            while (ekeInProgress)
            {
                alice.PerformNextAction();
                bob.PerformNextAction();
                ekeInProgress = alice.IsDoneWithProtocol == false || bob.IsDoneWithProtocol == false;
            }
        }
Ejemplo n.º 2
0
            public EKEAlice(TheBallEKE ekeContext, bool isAsync = false)
            {
                EKEContext = ekeContext;
                AlicesActions = new NegotiationAction[]
                    {
                        Alice1_1_GenerateKeyPair, Alice1_2_EncryptPublicKeyWithS, Alice1_3_SendEncryptedPublicKeyToBob,

                        Alice3_0_GetEncryptedSessionKeyFromBob, Alice3_1_DecryptSessionKey,
                        Alice3_2_GenerateAliceRandomValue,
                        Alice3_3_EncryptAliceRandomValueWithSessionKey, Alice3_4_SendEncryptedAliceRandomToBob,

                        Alice5_0_GetAlicesRandomWithBobsRandomEncryptedFromBob, Alice5_1_DecryptBothRandoms,
                        Alice5_2_VerifyAliceRandomInCombinedRandom,
                        Alice5_3_ExtractBobsRandom, Alice5_4_EncryptBobsRandom, Alice5_5_SendEncryptedBobsRandomToBob,

                        AliceX_DoneWithEKE
                    };
#if ASYNC
                AlicesActionsAsync = new NegotiationActionAsync[]
                    {
                        Alice1_1_GenerateKeyPairAsync, Alice1_2_EncryptPublicKeyWithSAsync, Alice1_3_SendEncryptedPublicKeyToBobAsync,

                        Alice3_0_GetEncryptedSessionKeyFromBobAsync, Alice3_1_DecryptSessionKeyAsync,
                        Alice3_2_GenerateAliceRandomValueAsync,
                        Alice3_3_EncryptAliceRandomValueWithSessionKeyAsync, Alice3_4_SendEncryptedAliceRandomToBobAsync,

                        Alice5_0_GetAlicesRandomWithBobsRandomEncryptedFromBobAsync, Alice5_1_DecryptBothRandomsAsync,
                        Alice5_2_VerifyAliceRandomInCombinedRandomAsync,
                        Alice5_3_ExtractBobsRandomAsync, Alice5_4_EncryptBobsRandomAsync, Alice5_5_SendEncryptedBobsRandomToBobAsync,

                        AliceX_DoneWithEKEAsync
                    };
#endif
                CurrentActionIndex = 0;
                WaitForOtherParty = false;
                IsAsync = isAsync;
            }
Ejemplo n.º 3
0
            public EKEBob(TheBallEKE ekeContext, bool isAsync = false)
            {
                EKEContext = ekeContext;
                BobsActions = new NegotiationAction[]
                    {
                        Bob2_0_GetAlicesEncryptedPublicKeyFromAlice, Bob2_1_DecryptAlicesEncryptedPublicKey,
                        Bob2_2_GenerateRandomSessionKeyWithIV, Bob2_3_EncryptSessionKey,
                        Bob2_4_SendEncryptedSessionKeyToAlice,

                        Bob4_0_GetAlicesRandomEncryptedFromAlice, Bob4_1_DecryptAlicesEncryptedRandom,
                        Bob4_2_GenerateBobsRandomAndCombineWithAlicesRandom, Bob4_3_SendBothRandomsEncryptedToAlice,

                        Bob6_0_GetBobsRandomEncryptedFromAlice, Bob6_1_DecryptBobsRandomFromAlice,
                        Bob6_2_VerifyBobsRandom,

                        BobX_DoneWithEKE
                    };
#if ASYNC
                BobsActionsAsync = new NegotiationActionAsync[]
                    {
                        Bob2_0_GetAlicesEncryptedPublicKeyFromAliceAsync, Bob2_1_DecryptAlicesEncryptedPublicKeyAsync,
                        Bob2_2_GenerateRandomSessionKeyWithIVAsync, Bob2_3_EncryptSessionKeyAsync,
                        Bob2_4_SendEncryptedSessionKeyToAliceAsync,

                        Bob4_0_GetAlicesRandomEncryptedFromAliceAsync, Bob4_1_DecryptAlicesEncryptedRandomAsync,
                        Bob4_2_GenerateBobsRandomAndCombineWithAlicesRandomAsync, Bob4_3_SendBothRandomsEncryptedToAliceAsync,

                        Bob6_0_GetBobsRandomEncryptedFromAliceAsync, Bob6_1_DecryptBobsRandomFromAliceAsync,
                        Bob6_2_VerifyBobsRandomAsync,

                        BobX_DoneWithEKEAsync
                    };
#endif
                CurrentActionIndex = 0;
                WaitForOtherParty = true;
                IsAsync = isAsync;
            }