Ejemplo n.º 1
0
        static void AdvanceCounter(UdpClient client, RSACryptoServiceProvider ironclad_public_key,
                                   RSACryptoServiceProvider counter_key_pair, SHA256Managed hasher, UInt32 counter_index,
                                   byte[] message, UInt32 old_counter_value, UInt32 new_counter_value)
        {
            AdvanceCounterRequest advanceCounterRequest =
                new AdvanceCounterRequest(counter_index, new_counter_value, message, counter_key_pair);
            byte[] request = advanceCounterRequest.GetPacket(hasher);
            byte[] response = CommonRoutines.SendRequest(client, request, "AdvanceCounter");
            AdvanceCounterResponse advanceCounterResponse = new AdvanceCounterResponse(response, ironclad_public_key);

            if (advanceCounterResponse.OldCounterValue != old_counter_value)
            {
                throw new Exception("AdvanceCounter statement had wrong old counter value");
            }
            if (advanceCounterResponse.NewCounterValue != new_counter_value)
            {
                throw new Exception("AdvanceCounter statement had wrong new counter value");
            }
            if (!advanceCounterResponse.Message.SequenceEqual(message))
            {
                throw new Exception("AdvanceCounter statement had wrong message");
            }
        }
Ejemplo n.º 2
0
        static void AdvanceCounter(UdpClient client, RSACryptoServiceProvider ironclad_public_key,
                                   RSACryptoServiceProvider counter_key_pair, SHA256Managed hasher, UInt32 counter_index,
                                   byte[] message, UInt32 old_counter_value, UInt32 new_counter_value)
        {
            AdvanceCounterRequest advanceCounterRequest =
                new AdvanceCounterRequest(counter_index, new_counter_value, message, counter_key_pair);

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

            if (advanceCounterResponse.OldCounterValue != old_counter_value)
            {
                throw new Exception("AdvanceCounter statement had wrong old counter value");
            }
            if (advanceCounterResponse.NewCounterValue != new_counter_value)
            {
                throw new Exception("AdvanceCounter statement had wrong new counter value");
            }
            if (!advanceCounterResponse.Message.SequenceEqual(message))
            {
                throw new Exception("AdvanceCounter statement had wrong message");
            }
        }