Ejemplo n.º 1
0
        public void TestValidateParticipantsIdsEqual()
        {
            JPakeUtilities.ValidateParticipantIdsEqual("a", "a");

            try
            {
                JPakeUtilities.ValidateParticipantIdsEqual("a", "b");

                Fail("validate participant ids equal not throwing exception for different participant ids");
            }
            catch (CryptoException)
            {
                // expected
            }
        }
 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;
    }