public void TestValidateParticipantIdsDiffer()
        {
            JPakeUtilities.ValidateParticipantIdsDiffer("a", "b");
            JPakeUtilities.ValidateParticipantIdsDiffer("a", "A");

            try
            {
                JPakeUtilities.ValidateParticipantIdsDiffer("a", "a");

                Fail("validate participant ids differ not throwing exception for equal participant ids");
            }
            catch (CryptoException)
            {
                // expected
            }
        }
 public virtual void ValidateRound1PayloadReceived(JPakeRound1Payload round1PayloadReceived)
 {
     if (state >= STATE_ROUND_1_VALIDATED)
     {
         throw new InvalidOperationException("Validation already attempted for round 1 payload for " + participantId);
     }
     partnerParticipantId = round1PayloadReceived.ParticipantId;
     gx3 = round1PayloadReceived.Gx1;
     gx4 = round1PayloadReceived.Gx2;
     BigInteger[] knowledgeProofForX  = round1PayloadReceived.KnowledgeProofForX1;
     BigInteger[] knowledgeProofForX2 = round1PayloadReceived.KnowledgeProofForX2;
     JPakeUtilities.ValidateParticipantIdsDiffer(participantId, round1PayloadReceived.ParticipantId);
     JPakeUtilities.ValidateGx4(gx4);
     JPakeUtilities.ValidateZeroKnowledgeProof(p, q, g, gx3, knowledgeProofForX, round1PayloadReceived.ParticipantId, digest);
     JPakeUtilities.ValidateZeroKnowledgeProof(p, q, g, gx4, knowledgeProofForX2, round1PayloadReceived.ParticipantId, digest);
     state = STATE_ROUND_1_VALIDATED;
 }
 public virtual void ValidateRound3PayloadReceived(JPakeRound3Payload round3PayloadReceived, BigInteger keyingMaterial)
 {
     if (state >= STATE_ROUND_3_VALIDATED)
     {
         throw new InvalidOperationException("Validation already attempted for round 3 payload for " + participantId);
     }
     if (state < STATE_KEY_CALCULATED)
     {
         throw new InvalidOperationException("Keying material must be calculated prior to validating round 3 payload for " + participantId);
     }
     JPakeUtilities.ValidateParticipantIdsDiffer(participantId, round3PayloadReceived.ParticipantId);
     JPakeUtilities.ValidateParticipantIdsEqual(partnerParticipantId, round3PayloadReceived.ParticipantId);
     JPakeUtilities.ValidateMacTag(participantId, partnerParticipantId, gx1, gx2, gx3, gx4, keyingMaterial, digest, round3PayloadReceived.MacTag);
     gx1   = null;
     gx2   = null;
     gx3   = null;
     gx4   = null;
     state = STATE_ROUND_3_VALIDATED;
 }
    public virtual void ValidateRound2PayloadReceived(JPakeRound2Payload round2PayloadReceived)
    {
        if (state >= STATE_ROUND_2_VALIDATED)
        {
            throw new InvalidOperationException("Validation already attempted for round 2 payload for " + participantId);
        }
        if (state < STATE_ROUND_1_VALIDATED)
        {
            throw new InvalidOperationException("Round 1 payload must be validated prior to validation round 2 payload for " + participantId);
        }
        BigInteger ga = JPakeUtilities.CalculateGA(p, gx3, gx1, gx2);

        b = round2PayloadReceived.A;
        BigInteger[] knowledgeProofForX2s = round2PayloadReceived.KnowledgeProofForX2s;
        JPakeUtilities.ValidateParticipantIdsDiffer(participantId, round2PayloadReceived.ParticipantId);
        JPakeUtilities.ValidateParticipantIdsEqual(partnerParticipantId, round2PayloadReceived.ParticipantId);
        JPakeUtilities.ValidateGa(ga);
        JPakeUtilities.ValidateZeroKnowledgeProof(p, q, ga, b, knowledgeProofForX2s, round2PayloadReceived.ParticipantId, digest);
        state = STATE_ROUND_2_VALIDATED;
    }