Пример #1
0
        /// <inheritdoc />
        protected override bool KeyValidityChecks(OtherPartySharedInformation <FfcDomainParameters, FfcKeyPair> otherPartyInformation)
        {
            try
            {
                // When KeyPairGen or FullVal, check the static public key
                if (SchemeParameters.KasAssurances.HasFlag(KasAssurance.KeyPairGen) ||
                    SchemeParameters.KasAssurances.HasFlag(KasAssurance.FullVal) &&
                    StaticKeyPair != null)
                {
                    KeyValidationHelper.PerformFfcPublicKeyValidation(
                        DomainParameters.P,
                        DomainParameters.Q,
                        StaticKeyPair.PublicKeyY,
                        true
                        );
                }

                // When fullval, and the other party provides a static public key
                if (SchemeParameters.KasAssurances.HasFlag(KasAssurance.FullVal) &&
                    otherPartyInformation.StaticPublicKey != null)
                {
                    KeyValidationHelper.PerformFfcPublicKeyValidation(
                        DomainParameters.P,
                        DomainParameters.Q,
                        otherPartyInformation.StaticPublicKey.PublicKeyY,
                        true
                        );
                }

                // When fullval, and the other party provides a ephemeral public key
                if (SchemeParameters.KasAssurances.HasFlag(KasAssurance.FullVal) &&
                    otherPartyInformation.EphemeralPublicKey != null)
                {
                    KeyValidationHelper.PerformFfcPublicKeyValidation(
                        DomainParameters.P,
                        DomainParameters.Q,
                        otherPartyInformation.EphemeralPublicKey.PublicKeyY,
                        true
                        );
                }

                // When using DpVal or KeyRegen, with a static key,
                // perform private static key validation
                if ((SchemeParameters.KasAssurances.HasFlag(KasAssurance.DpVal) ||
                     SchemeParameters.KasAssurances.HasFlag(KasAssurance.KeyRegen)) &&
                    StaticKeyPair != null)
                {
                    if (!Dsa.ValidateKeyPair(DomainParameters, StaticKeyPair).Success)
                    {
                        return(false);
                    }
                }
            }
            catch (Exception)
            {
                return(false);
            }

            return(true);
        }
        public void ShouldReturnExpectedValidationResultEcc(string label, Curve curveEnum, EccPoint publicKey, bool shouldPassValidation)
        {
            var curve = new EccCurveFactory().GetCurve(curveEnum);

            var result = KeyValidationHelper.PerformEccPublicKeyValidation(curve, publicKey, false);

            Assert.AreEqual(shouldPassValidation, result);
        }