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; } bool ekeSuccess = true; }
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; } }
public static void TestExecution() { TheBallEKE instance = new TheBallEKE(); instance.InitiateCurrentSymmetricFromSecret("testsecret"); EKEAlice alice = new EKEAlice(ekeContext: instance); EKEBob bob = new EKEBob(ekeContext: instance); // Hook message senders alice.SendMessageToBob = msg => { bob.LatestMessageFromAlice = msg; bob.WaitForAlice = false; }; bob.SendMessageToAlice = msg => { alice.LatestMessageFromBob = msg; alice.WaitForBob = false; }; bool ekeInProgress = true; int aliceActionIX = 0; int bobActionIX = 0; while (ekeInProgress) { bool alicesTurn = alice.IsDoneWithEKE == false && alice.WaitForBob == false; bool bobsTurn = !alicesTurn; if (alicesTurn) { do { alice.AlicesActions[aliceActionIX++](); } while (alice.IsDoneWithEKE == false && alice.WaitForBob == false); } else { do { bob.BobsActions[bobActionIX++](); } while (bob.IsDoneWithEKE == false && bob.WaitForAlice == false); } ekeInProgress = alice.IsDoneWithEKE == false || bob.IsDoneWithEKE == false; } bool ekeSuccess = true; #if never instance.Alice1_1_GenerateKeyPair(); instance.Alice1_2_EncryptPublicKeyWithS(); instance.Alice1_3_SendEncryptedPublicKeyToBob(msgToBob => { instance.Bob.AlicesEncryptedPublicKey = msgToBob; }); instance.Bob2_1_DecryptAlicesEncryptedPublicKey(); instance.Bob2_2_GenerateRandomSessionKeyWithIV(); instance.Bob2_3_EncryptSessionKey(); instance.Bob2_4_SendEncryptedSessionKeyToAlice(msgToAlice => { instance.Alice.EncryptedSessionKey = msgToAlice; }); instance.Alice3_1_DecryptSessionKey(); instance.Alice3_2_GenerateAliceRandomValue(); instance.Alice3_3_EncryptAliceRandomValueWithSessionKey(); instance.Alice3_4_SendEncryptedAliceRandomToBob(msgToBob => { instance.Bob.AlicesEncryptedRandom = msgToBob; }); instance.Bob4_1_DecryptAlicesEncryptedRandom(); instance.Bob4_2_GenerateBobsRandomAndCombineWithAlicesRandom(); instance.Bob4_3_SendBothRandomsEncryptedToAlice(msgToAlice => { instance.Alice.AlicesRandomWithBobsRandomEncrypted = msgToAlice; }); instance.Alice5_1_DecryptBothRandoms(); instance.Alice5_2_VerifyAliceRandomInCombinedRandom(); instance.Alice5_3_ExtractBobsRandom(); instance.Alice5_4_EncryptBobsRandom(); instance.Alice5_5_SendEncryptedBobsRandomToBob(msgToBob => { instance.Bob.BobsRandomFromAliceEncrypted = msgToBob; }); instance.Bob6_1_DecryptBobsRandomFromAlice(); instance.Bob6_2_VerifyBobsRandom(); #endif }