diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-02-14 19:10:46 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-02-14 19:10:46 +0700 |
commit | a443719f81481e83760aeb7b9a64589f62ef140d (patch) | |
tree | 344d1f13e87ed418aaf2d0c7984997323ab69a40 /crypto/src/cms/KeyAgreeRecipientInfoGenerator.cs | |
parent | Update WrapperUtilities algorithms (diff) | |
download | BouncyCastle.NET-ed25519-a443719f81481e83760aeb7b9a64589f62ef140d.tar.xz |
Avoid unnecessary recoding
Diffstat (limited to 'crypto/src/cms/KeyAgreeRecipientInfoGenerator.cs')
-rw-r--r-- | crypto/src/cms/KeyAgreeRecipientInfoGenerator.cs | 16 |
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)) |