protected override void GenerateKasKeyNonceInformation() { if (DomainParameters == null) { GenerateDomainParameters(); } StaticKeyPair = Dsa.GenerateKeyPair(DomainParameters).KeyPair; // DKM Nonce required when party U and KdfNoKc or KdfKc if (SchemeParameters.KeyAgreementRole == KeyAgreementRole.InitiatorPartyU && SchemeParameters.KasMode != KasMode.NoKdfNoKc) { try { DkmNonce = EntropyProvider.GetEntropy(new BitString(DomainParameters.Q).BitLength / 2); } catch (Exception e) { Console.WriteLine(e); throw; } } // When party V, KC, Bilateral, generate ephemeral nonce // When party V, KC, Unilateral, and the recipient of key confirmation, ephemeral nonce // Otherwise, no ephemeral nonce. if (SchemeParameters.KeyAgreementRole == KeyAgreementRole.ResponderPartyV && SchemeParameters.KasMode == KasMode.KdfKc) { if (SchemeParameters.KeyConfirmationDirection == KeyConfirmationDirection.Bilateral || ( SchemeParameters.KeyConfirmationDirection == KeyConfirmationDirection.Unilateral && SchemeParameters.KeyConfirmationRole == KeyConfirmationRole.Recipient ) ) { EphemeralNonce = EntropyProvider.GetEntropy(new BitString(DomainParameters.P).BitLength); } } // when party U and KdfNoKc, a NoKeyConfirmationNonce is needed. if (SchemeParameters.KeyAgreementRole == KeyAgreementRole.InitiatorPartyU && SchemeParameters.KasMode == KasMode.KdfNoKc) { NoKeyConfirmationNonce = EntropyProvider.GetEntropy(128); } }
protected override void GenerateKasKeyNonceInformation() { if (DomainParameters == null) { GenerateDomainParameters(); } EphemeralKeyPair = Dsa.GenerateKeyPair(DomainParameters).KeyPair; // when party U and KdfNoKc, a NoKeyConfirmationNonce is needed. if (SchemeParameters.KeyAgreementRole == KeyAgreementRole.InitiatorPartyU && SchemeParameters.KasMode == KasMode.KdfNoKc) { NoKeyConfirmationNonce = EntropyProvider.GetEntropy(128); } }
protected override void GenerateKasKeyNonceInformation() { if (DomainParameters == null) { GenerateDomainParameters(); } StaticKeyPair = Dsa.GenerateKeyPair(DomainParameters).KeyPair; var curveAttributes = CurveAttributesHelper.GetCurveAttribute(DomainParameters.CurveE.CurveName); // DKM Nonce required when party U and KdfNoKc/KdfKc if (SchemeParameters.KeyAgreementRole == KeyAgreementRole.InitiatorPartyU && SchemeParameters.KasMode != KasMode.NoKdfNoKc) { DkmNonce = EntropyProvider.GetEntropy(curveAttributes.DegreeOfPolynomial.ValueToMod(BitString.BITSINBYTE)); } // When party V, KC, Bilateral, generate ephemeral nonce // When party V, KC, Unilateral, and the recipient of key confirmation, ephemeral nonce // Otherwise, no ephemeral nonce. if (SchemeParameters.KeyAgreementRole == KeyAgreementRole.ResponderPartyV && SchemeParameters.KasMode == KasMode.KdfKc) { if (SchemeParameters.KeyConfirmationDirection == KeyConfirmationDirection.Bilateral || ( SchemeParameters.KeyConfirmationDirection == KeyConfirmationDirection.Unilateral && SchemeParameters.KeyConfirmationRole == KeyConfirmationRole.Recipient ) ) { EphemeralNonce = EntropyProvider.GetEntropy(curveAttributes.DegreeOfPolynomial.ValueToMod(BitString.BITSINBYTE)); } } // when party U and KdfNoKc, a NoKeyConfirmationNonce is needed. if (SchemeParameters.KeyAgreementRole == KeyAgreementRole.InitiatorPartyU && SchemeParameters.KasMode == KasMode.KdfNoKc) { NoKeyConfirmationNonce = EntropyProvider.GetEntropy(128); } }
protected override void GenerateKasKeyNonceInformation() { if (DomainParameters == null) { GenerateDomainParameters(); } StaticKeyPair = Dsa.GenerateKeyPair(DomainParameters).KeyPair; // Only party U generates an ephemeral key if (SchemeParameters.KeyAgreementRole == KeyAgreementRole.InitiatorPartyU) { EphemeralKeyPair = Dsa.GenerateKeyPair(DomainParameters).KeyPair; } // When party V, KC, Bilateral, generate ephemeral nonce // When party V, KC, Unilateral, and the recipient of key confirmation, ephemeral nonce // Otherwise, no ephemeral nonce. if (SchemeParameters.KeyAgreementRole == KeyAgreementRole.ResponderPartyV && SchemeParameters.KasMode == KasMode.KdfKc) { if (SchemeParameters.KeyConfirmationDirection == KeyConfirmationDirection.Bilateral || ( SchemeParameters.KeyConfirmationDirection == KeyConfirmationDirection.Unilateral && SchemeParameters.KeyConfirmationRole == KeyConfirmationRole.Recipient ) ) { EphemeralNonce = EntropyProvider.GetEntropy(new BitString(DomainParameters.P).BitLength); } } // when party U and KdfNoKc, a NoKeyConfirmationNonce is needed. if (SchemeParameters.KeyAgreementRole == KeyAgreementRole.InitiatorPartyU && SchemeParameters.KasMode == KasMode.KdfNoKc) { NoKeyConfirmationNonce = EntropyProvider.GetEntropy(128); } }