summary refs log tree commit diff
path: root/crypto/src/asn1/ess
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2023-07-14 14:32:40 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2023-07-14 14:32:40 +0700
commiteb89e9957f34982f75f36ef237166ccbc2042768 (patch)
tree3166947175b520554f5a8363f75f92ba43794b8f /crypto/src/asn1/ess
parent(D)TLS: Refactoring around CertificateType support (diff)
downloadBouncyCastle.NET-ed25519-eb89e9957f34982f75f36ef237166ccbc2042768.tar.xz
Refactor using MapElements
Diffstat (limited to 'crypto/src/asn1/ess')
-rw-r--r--crypto/src/asn1/ess/SigningCertificate.cs39
-rw-r--r--crypto/src/asn1/ess/SigningCertificateV2.cs17
2 files changed, 12 insertions, 44 deletions
diff --git a/crypto/src/asn1/ess/SigningCertificate.cs b/crypto/src/asn1/ess/SigningCertificate.cs
index 6b8deee8b..ae263428e 100644
--- a/crypto/src/asn1/ess/SigningCertificate.cs
+++ b/crypto/src/asn1/ess/SigningCertificate.cs
@@ -53,36 +53,17 @@ namespace Org.BouncyCastle.Asn1.Ess
 			certs = new DerSequence(essCertID);
 		}
 
-		public EssCertID[] GetCerts()
-		{
-			EssCertID[] cs = new EssCertID[certs.Count];
-
-			for (int i = 0; i != certs.Count; i++)
-			{
-				cs[i] = EssCertID.GetInstance(certs[i]);
-			}
-
-			return cs;
-		}
-
-		public PolicyInformation[] GetPolicies()
-		{
-			if (policies == null)
-			{
-				return null;
-			}
-
-			PolicyInformation[] ps = new PolicyInformation[policies.Count];
-
-			for (int i = 0; i != policies.Count; i++)
-			{
-				ps[i] = PolicyInformation.GetInstance(policies[i]);
-			}
+        public EssCertID[] GetCerts()
+        {
+            return certs.MapElements(EssCertID.GetInstance);
+        }
 
-			return ps;
-		}
+        public PolicyInformation[] GetPolicies()
+        {
+            return policies?.MapElements(PolicyInformation.GetInstance);
+        }
 
-		/**
+        /**
 		 * The definition of SigningCertificate is
 		 * <pre>
 		 * SigningCertificate ::=  SEQUENCE {
@@ -94,7 +75,7 @@ namespace Org.BouncyCastle.Asn1.Ess
 		 *  member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs9(9)
 		 *  smime(16) id-aa(2) 12 }
 		 */
-		public override Asn1Object ToAsn1Object()
+        public override Asn1Object ToAsn1Object()
 		{
 			Asn1EncodableVector v = new Asn1EncodableVector(certs);
             v.AddOptional(policies);
diff --git a/crypto/src/asn1/ess/SigningCertificateV2.cs b/crypto/src/asn1/ess/SigningCertificateV2.cs
index 4694098dd..557bede9c 100644
--- a/crypto/src/asn1/ess/SigningCertificateV2.cs
+++ b/crypto/src/asn1/ess/SigningCertificateV2.cs
@@ -65,25 +65,12 @@ namespace Org.BouncyCastle.Asn1.Ess
 
         public EssCertIDv2[] GetCerts()
         {
-            EssCertIDv2[] certIds = new EssCertIDv2[certs.Count];
-            for (int i = 0; i != certs.Count; i++)
-            {
-                certIds[i] = EssCertIDv2.GetInstance(certs[i]);
-            }
-            return certIds;
+            return certs.MapElements(EssCertIDv2.GetInstance);
         }
 
         public PolicyInformation[] GetPolicies()
         {
-            if (policies == null)
-                return null;
-
-            PolicyInformation[] policyInformations = new PolicyInformation[policies.Count];
-            for (int i = 0; i != policies.Count; i++)
-            {
-                policyInformations[i] = PolicyInformation.GetInstance(policies[i]);
-            }
-            return policyInformations;
+            return policies?.MapElements(PolicyInformation.GetInstance);
         }
 
         /**