summary refs log tree commit diff
path: root/crypto/src/cms
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@gmail.com>2022-06-22 23:29:08 +0700
committerPeter Dettman <peter.dettman@gmail.com>2022-06-22 23:29:08 +0700
commit9a6df113d3192c4246832388299a4b45b3668d6c (patch)
treeb2513fd29bb03935220761e1608f3aeb238b81f2 /crypto/src/cms
parentCode cleanup (diff)
downloadBouncyCastle.NET-ed25519-9a6df113d3192c4246832388299a4b45b3668d6c.tar.xz
Warnings cleanup
Diffstat (limited to 'crypto/src/cms')
-rw-r--r--crypto/src/cms/KeyTransRecipientInfoGenerator.cs47
1 files changed, 16 insertions, 31 deletions
diff --git a/crypto/src/cms/KeyTransRecipientInfoGenerator.cs b/crypto/src/cms/KeyTransRecipientInfoGenerator.cs
index 6ee3af6b6..9a2cbc5b0 100644
--- a/crypto/src/cms/KeyTransRecipientInfoGenerator.cs
+++ b/crypto/src/cms/KeyTransRecipientInfoGenerator.cs
@@ -1,5 +1,4 @@
 using System;
-using System.IO;
 
 using Org.BouncyCastle.Asn1;
 using Org.BouncyCastle.Asn1.Cms;
@@ -11,52 +10,45 @@ using Org.BouncyCastle.X509;
 
 namespace Org.BouncyCastle.Cms
 {
-    public class KeyTransRecipientInfoGenerator : RecipientInfoGenerator
+    public class KeyTransRecipientInfoGenerator
+        : RecipientInfoGenerator
     {
-        private static readonly CmsEnvelopedHelper Helper = CmsEnvelopedHelper.Instance;
+        private readonly IKeyWrapper m_keyWrapper;
 
-        private Asn1OctetString subjectKeyIdentifier;
-        private IKeyWrapper keyWrapper;
-
-        // Derived fields
-        private SubjectPublicKeyInfo info;
-        private IssuerAndSerialNumber issuerAndSerialNumber;
-        private SecureRandom random;
-       
+        private IssuerAndSerialNumber m_issuerAndSerialNumber;
+        private Asn1OctetString m_subjectKeyIdentifier;
 
         public KeyTransRecipientInfoGenerator(X509Certificate recipCert, IKeyWrapper keyWrapper)
-            : this(new Asn1.Cms.IssuerAndSerialNumber(recipCert.IssuerDN, new DerInteger(recipCert.SerialNumber)), keyWrapper)
+            : this(new IssuerAndSerialNumber(recipCert.IssuerDN, new DerInteger(recipCert.SerialNumber)), keyWrapper)
         {
         }
 
         public KeyTransRecipientInfoGenerator(IssuerAndSerialNumber issuerAndSerial, IKeyWrapper keyWrapper)
         {
-            this.issuerAndSerialNumber = issuerAndSerial;
-            this.keyWrapper = keyWrapper;
+            m_issuerAndSerialNumber = issuerAndSerial;
+            m_keyWrapper = keyWrapper;
         }
 
         public KeyTransRecipientInfoGenerator(byte[] subjectKeyID, IKeyWrapper keyWrapper)
         {
-            this.subjectKeyIdentifier = new DerOctetString(subjectKeyID);
-            this.keyWrapper = keyWrapper;
+            m_subjectKeyIdentifier = new DerOctetString(subjectKeyID);
+            m_keyWrapper = keyWrapper;
         }
 
         public RecipientInfo Generate(KeyParameter contentEncryptionKey, SecureRandom random)
         {
-            AlgorithmIdentifier keyEncryptionAlgorithm = this.AlgorithmDetails;
-
-            this.random = random;
+            AlgorithmIdentifier keyEncryptionAlgorithm = AlgorithmDetails;
 
             byte[] encryptedKeyBytes = GenerateWrappedKey(contentEncryptionKey);
 
             RecipientIdentifier recipId;
-            if (issuerAndSerialNumber != null)
+            if (m_issuerAndSerialNumber != null)
             {
-                recipId = new RecipientIdentifier(issuerAndSerialNumber);
+                recipId = new RecipientIdentifier(m_issuerAndSerialNumber);
             }
             else
             {
-                recipId = new RecipientIdentifier(subjectKeyIdentifier);
+                recipId = new RecipientIdentifier(m_subjectKeyIdentifier);
             }
 
             return new RecipientInfo(new KeyTransRecipientInfo(recipId, keyEncryptionAlgorithm,
@@ -65,19 +57,12 @@ namespace Org.BouncyCastle.Cms
 
         protected virtual AlgorithmIdentifier AlgorithmDetails
         {
-            get
-            {
-                if (this.keyWrapper != null)
-                {
-                    return (AlgorithmIdentifier)keyWrapper.AlgorithmDetails;
-                }
-                return info.AlgorithmID;
-            }
+            get { return (AlgorithmIdentifier)m_keyWrapper.AlgorithmDetails; }
         }
 
         protected virtual byte[] GenerateWrappedKey(KeyParameter contentEncryptionKey)
         {
-            return keyWrapper.Wrap(contentEncryptionKey.GetKey()).Collect();
+            return m_keyWrapper.Wrap(contentEncryptionKey.GetKey()).Collect();
         }
     }
 }