コード例 #1
0
 public SchemeParameters(
     KasAlgoAttributes kasAlgoAttributes,
     KeyAgreementRole keyAgreementRole,
     KasMode kasMode,
     KeyConfirmationRole keyConfirmationRole,
     KeyConfirmationDirection keyConfirmationDirection,
     KasAssurance kasAssurances,
     BitString thisPartyId
     ) : base(kasAlgoAttributes, keyAgreementRole, kasMode, keyConfirmationRole, keyConfirmationDirection, kasAssurances, thisPartyId)
 {
     KasAlgorithm = KasEnumMapping.GetSchemeRequirements(
         kasAlgoAttributes.KasScheme,
         kasMode,
         keyAgreementRole,
         keyConfirmationRole,
         keyConfirmationDirection).kasAlgo;
 }
コード例 #2
0
        private void ValidateConsistentAlgorithm(KasAlgorithm schemeRequirementsKasAlgo, SchemeKeyNonceGenRequirement schemeRequirementsRequirments, IDsaDomainParameters domainParameters, IDsaKeyPair ephemeralKey, IDsaKeyPair staticKey)
        {
            switch (schemeRequirementsKasAlgo)
            {
            case KasAlgorithm.Ffc:
                if (domainParameters.GetType() != typeof(FfcDomainParameters))
                {
                    throw new ArgumentException($"{nameof(domainParameters)} expected type {typeof(FfcDomainParameters)} got {domainParameters.GetType()}");
                }

                if (ephemeralKey != null && ephemeralKey.GetType() != typeof(FfcKeyPair))
                {
                    throw new ArgumentException($"{nameof(ephemeralKey)} expected type {typeof(FfcKeyPair)} got {ephemeralKey.GetType()}");
                }

                if (staticKey != null && staticKey.GetType() != typeof(FfcKeyPair))
                {
                    throw new ArgumentException($"{nameof(staticKey)} expected type {typeof(FfcKeyPair)} got {staticKey.GetType()}");
                }
                break;

            case KasAlgorithm.Ecc:
                if (domainParameters.GetType() != typeof(EccDomainParameters))
                {
                    throw new ArgumentException($"{nameof(domainParameters)} expected type {typeof(EccDomainParameters)} got {domainParameters.GetType()}");
                }

                if (ephemeralKey != null && ephemeralKey.GetType() != typeof(EccKeyPair))
                {
                    throw new ArgumentException($"{nameof(ephemeralKey)} expected type {typeof(EccKeyPair)} got {ephemeralKey.GetType()}");
                }

                if (staticKey != null && staticKey.GetType() != typeof(EccKeyPair))
                {
                    throw new ArgumentException($"{nameof(staticKey)} expected type {typeof(EccKeyPair)} got {staticKey.GetType()}");
                }
                break;

            default:
                throw new ArgumentException(nameof(schemeRequirementsKasAlgo));
            }
        }