public IIfcSecretKeyingMaterial Build(IfcScheme scheme, KasMode kasMode, KeyAgreementRole thisPartyKeyAgreementRole,
                                              KeyConfirmationRole keyConfirmationRole, KeyConfirmationDirection keyConfirmationDirection,
                                              bool shouldValidateContributions = true)
        {
            if (shouldValidateContributions)
            {
                var generationRequirements = KeyGenerationRequirementsHelper.GetKeyGenerationOptionsForSchemeAndRole(
                    scheme, kasMode, thisPartyKeyAgreementRole, keyConfirmationRole, keyConfirmationDirection);

                ValidateNonce(generationRequirements);
                ValidateKey(generationRequirements);
                ValidatePartyId(generationRequirements);
                ValidateK(generationRequirements, scheme);
            }

            return(new IfcSecretKeyingMaterial()
            {
                C = _c,
                DkmNonce = _dkmNonce,
                K = _k,
                Key = _key,
                PartyId = _partyId,
                Z = _z,
            });
        }
        /// <summary>
        /// Validates the "k" is provided when party U for KTS scheme.
        /// </summary>
        /// <param name="generationRequirements">The generation requirements for this party and scheme.</param>
        /// <param name="scheme">The scheme utilized for the KAS/KTS.</param>
        /// <exception cref="ArgumentNullException">Throw when required value is not provided.</exception>
        private void ValidateK(SchemeKeyNonceGenRequirement generationRequirements, IfcScheme scheme)
        {
            var ktsSchemes = new[] { IfcScheme.Kts_oaep_basic, IfcScheme.Kts_oaep_partyV_keyConfirmation };

            if (generationRequirements.ThisPartyKasRole == KeyAgreementRole.InitiatorPartyU && ktsSchemes.Contains(scheme) && _k?.BitLength == 0)
            {
                throw new ArgumentNullException($"{nameof(_key.PubKey)} cannot be null for this party and scheme.");
            }
        }
 public KasAlgoAttributesIfc(IfcScheme scheme, int modulo, int l)
 {
     Scheme = scheme;
     Modulo = modulo;
     L      = l;
 }