diff options
author | David Hook <dgh@bouncycastle.org> | 2021-05-24 13:06:31 +1000 |
---|---|---|
committer | David Hook <dgh@bouncycastle.org> | 2021-05-24 13:06:31 +1000 |
commit | 01238566c1d4b2a606e4859a75ad05ca79db4ffb (patch) | |
tree | ee7d1057d41cd25c3f0383b5d1ca2e213a976feb /crypto/src/cms/CMSEnvelopedGenerator.cs | |
parent | github#54 test for mixed mode definition (diff) | |
download | BouncyCastle.NET-ed25519-01238566c1d4b2a606e4859a75ad05ca79db4ffb.tar.xz |
github #222 addressed OAEP parameter setting, refactored KeyTransRecipientInfoGenerator to allow deprecation of sub class
Diffstat (limited to 'crypto/src/cms/CMSEnvelopedGenerator.cs')
-rw-r--r-- | crypto/src/cms/CMSEnvelopedGenerator.cs | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/crypto/src/cms/CMSEnvelopedGenerator.cs b/crypto/src/cms/CMSEnvelopedGenerator.cs index ed7e1edee..d7d3e4bbf 100644 --- a/crypto/src/cms/CMSEnvelopedGenerator.cs +++ b/crypto/src/cms/CMSEnvelopedGenerator.cs @@ -10,6 +10,7 @@ using Org.BouncyCastle.Asn1.Pkcs; using Org.BouncyCastle.Asn1.X509; using Org.BouncyCastle.Asn1.X9; using Org.BouncyCastle.Crypto; +using Org.BouncyCastle.Crypto.Operators; using Org.BouncyCastle.Crypto.Parameters; using Org.BouncyCastle.Security; using Org.BouncyCastle.Utilities; @@ -132,10 +133,9 @@ namespace Org.BouncyCastle.Cms public void AddKeyTransRecipient( X509Certificate cert) { - KeyTransRecipientInfoGenerator ktrig = new KeyTransRecipientInfoGenerator(); - ktrig.RecipientCert = cert; - - recipientInfoGenerators.Add(ktrig); + TbsCertificateStructure recipientTbsCert = CmsUtilities.GetTbsCertificateStructure(cert); + SubjectPublicKeyInfo info = recipientTbsCert.SubjectPublicKeyInfo; + this.AddRecipientInfoGenerator(new KeyTransRecipientInfoGenerator(cert, new Asn1KeyWrapper(info.AlgorithmID.Algorithm, info.AlgorithmID.Parameters, cert))); } /** @@ -149,11 +149,8 @@ namespace Org.BouncyCastle.Cms AsymmetricKeyParameter pubKey, byte[] subKeyId) { - KeyTransRecipientInfoGenerator ktrig = new KeyTransRecipientInfoGenerator(); - ktrig.RecipientPublicKey = pubKey; - ktrig.SubjectKeyIdentifier = new DerOctetString(subKeyId); - - recipientInfoGenerators.Add(ktrig); + SubjectPublicKeyInfo info = SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo(pubKey); + this.AddRecipientInfoGenerator(new KeyTransRecipientInfoGenerator(subKeyId, new Asn1KeyWrapper(info.AlgorithmID.Algorithm, info.AlgorithmID.Parameters, pubKey))); } /** |