summary refs log tree commit diff
path: root/crypto/src/cms/KeyAgreeRecipientInfoGenerator.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/cms/KeyAgreeRecipientInfoGenerator.cs')
-rw-r--r--crypto/src/cms/KeyAgreeRecipientInfoGenerator.cs16
1 files changed, 2 insertions, 14 deletions
diff --git a/crypto/src/cms/KeyAgreeRecipientInfoGenerator.cs b/crypto/src/cms/KeyAgreeRecipientInfoGenerator.cs
index 7686ee422..c7c7f563f 100644
--- a/crypto/src/cms/KeyAgreeRecipientInfoGenerator.cs
+++ b/crypto/src/cms/KeyAgreeRecipientInfoGenerator.cs
@@ -109,21 +109,9 @@ namespace Org.BouncyCastle.Cms
 			Asn1EncodableVector recipientEncryptedKeys = new Asn1EncodableVector();
 			foreach (X509Certificate recipientCert in recipientCerts)
 			{
-				TbsCertificateStructure tbsCert;
-				try
-				{
-					tbsCert = TbsCertificateStructure.GetInstance(
-						Asn1Object.FromByteArray(recipientCert.GetTbsCertificate()));
-				}
-				catch (Exception)
-				{
-					throw new ArgumentException("can't extract TBS structure from certificate");
-				}
-
 				// TODO Should there be a SubjectKeyIdentifier-based alternative?
-				IssuerAndSerialNumber issuerSerial = new IssuerAndSerialNumber(
-					tbsCert.Issuer, tbsCert.SerialNumber.Value);
-				KeyAgreeRecipientIdentifier karid = new KeyAgreeRecipientIdentifier(issuerSerial);
+                KeyAgreeRecipientIdentifier karid = new KeyAgreeRecipientIdentifier(
+					CmsUtilities.GetIssuerAndSerialNumber(recipientCert));
 
 				ICipherParameters recipientPublicParams = recipientCert.GetPublicKey();
 				if (keyAgreementOID.Id.Equals(CmsEnvelopedGenerator.ECMqvSha1Kdf))