Beispiel #1
0
        protected override void BuildKeyingMaterialThisParty(IIfcSecretKeyingMaterialBuilder thisPartyKeyingMaterialBuilder,
                                                             IIfcSecretKeyingMaterial otherPartyKeyingMaterial)
        {
            switch (SchemeParameters.KeyAgreementRole)
            {
            case KeyAgreementRole.InitiatorPartyU:
                // Create a key of L length, wrap it with the other parties public key.
                var keyToEncodeEncrypt = EntropyProvider.GetEntropy(SchemeParameters.KasAlgoAttributes.L);
                var kts = _ktsFactory.Get(_ktsParameter.KtsHashAlg);

                BitString fixedInfo = null;
                if (!string.IsNullOrEmpty(_ktsParameter.AssociatedDataPattern))
                {
                    ThisPartyKeyingMaterial = _thisPartyKeyingMaterialBuilder.Build(
                        SchemeParameters.KasAlgoAttributes.Scheme,
                        SchemeParameters.KasMode,
                        SchemeParameters.KeyAgreementRole,
                        SchemeParameters.KeyConfirmationRole,
                        SchemeParameters.KeyConfirmationDirection
                        );

                    fixedInfo = GetFixedInfo(otherPartyKeyingMaterial);
                }

                var c = kts.Encrypt(otherPartyKeyingMaterial.Key.PubKey, keyToEncodeEncrypt, fixedInfo).SharedSecretZ;

                thisPartyKeyingMaterialBuilder.WithK(keyToEncodeEncrypt);
                thisPartyKeyingMaterialBuilder.WithC(c);
                break;

            case KeyAgreementRole.ResponderPartyV:
                // Key should have been set outside the scope of the kas instance
                break;

            default:
                throw new ArgumentException($"Invalid {nameof(SchemeParameters.KeyAgreementRole)}");
            }
        }
Beispiel #2
0
        public IRsaOaep Get(KasHashAlg hashAlg)
        {
            var kts = _ktsFactory.Get(hashAlg);

            return(new FakeKts_BadZ(kts, _random));
        }