summary refs log tree commit diff
path: root/crypto/src/cms
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/cms')
-rw-r--r--crypto/src/cms/CMSUtils.cs2
-rw-r--r--crypto/src/cms/KeyAgreeRecipientInfoGenerator.cs16
2 files changed, 3 insertions, 15 deletions
diff --git a/crypto/src/cms/CMSUtils.cs b/crypto/src/cms/CMSUtils.cs
index 99258c995..aa25870e6 100644
--- a/crypto/src/cms/CMSUtils.cs
+++ b/crypto/src/cms/CMSUtils.cs
@@ -178,7 +178,7 @@ namespace Org.BouncyCastle.Cms
 
 		internal static TbsCertificateStructure GetTbsCertificateStructure(X509Certificate cert)
 		{
-			return TbsCertificateStructure.GetInstance(Asn1Object.FromByteArray(cert.GetTbsCertificate()));
+			return cert.CertificateStructure.TbsCertificate;
 		}
 
 		internal static IssuerAndSerialNumber GetIssuerAndSerialNumber(X509Certificate cert)
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))