コード例 #1
0
ファイル: Program.cs プロジェクト: jango2015/Ironclad
        static void AdvanceCounter(UdpClient client, RSACryptoServiceProvider ironclad_public_key, byte[] message,
                                   bool new_counter_value_known, ref UInt32 new_counter_value)
        {
            AdvanceCounterRequest advanceCounterRequest = new AdvanceCounterRequest(message);
            byte[] request = advanceCounterRequest.GetPacket();
            byte[] response = CommonRoutines.SendRequest(client, request, "AdvanceCounter");
            AdvanceCounterResponse advanceCounterResponse = new AdvanceCounterResponse(response, ironclad_public_key);

            if (new_counter_value_known && advanceCounterResponse.NewCounterValue != new_counter_value)
            {
                throw new Exception("New counter value in AdvanceCounterResponse did not match expected counter value");
            }
            new_counter_value = advanceCounterResponse.NewCounterValue;

            if (!advanceCounterResponse.Message.SequenceEqual(message))
            {
                throw new Exception("Message in AdvanceCounterResponse did not match expected message");
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: vmkc/research-environment
        static void AdvanceCounter(UdpClient client, RSACryptoServiceProvider ironclad_public_key, byte[] message,
                                   bool new_counter_value_known, ref UInt32 new_counter_value)
        {
            AdvanceCounterRequest advanceCounterRequest = new AdvanceCounterRequest(message);

            byte[] request  = advanceCounterRequest.GetPacket();
            byte[] response = CommonRoutines.SendRequest(client, request, "AdvanceCounter");
            AdvanceCounterResponse advanceCounterResponse = new AdvanceCounterResponse(response, ironclad_public_key);

            if (new_counter_value_known && advanceCounterResponse.NewCounterValue != new_counter_value)
            {
                throw new Exception("New counter value in AdvanceCounterResponse did not match expected counter value");
            }
            new_counter_value = advanceCounterResponse.NewCounterValue;

            if (!advanceCounterResponse.Message.SequenceEqual(message))
            {
                throw new Exception("Message in AdvanceCounterResponse did not match expected message");
            }
        }