summary refs log tree commit diff
path: root/crypto/src/asn1/cmp/GenRepContent.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-09-20 14:07:11 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-09-20 14:07:11 +0700
commitc17e29d769cf8a87402ff4d819d334389a7faca4 (patch)
treee60811ecfc45b6c229ce2e87d8b4a6db6d9f2da9 /crypto/src/asn1/cmp/GenRepContent.cs
parentadded randomized signing (diff)
downloadBouncyCastle.NET-ed25519-c17e29d769cf8a87402ff4d819d334389a7faca4.tar.xz
Update Asn1.Cmp from bc-java
Diffstat (limited to 'crypto/src/asn1/cmp/GenRepContent.cs')
-rw-r--r--crypto/src/asn1/cmp/GenRepContent.cs46
1 files changed, 21 insertions, 25 deletions
diff --git a/crypto/src/asn1/cmp/GenRepContent.cs b/crypto/src/asn1/cmp/GenRepContent.cs
index 3c3573e37..38f91061c 100644
--- a/crypto/src/asn1/cmp/GenRepContent.cs
+++ b/crypto/src/asn1/cmp/GenRepContent.cs
@@ -1,43 +1,39 @@
-using System;
-
-using Org.BouncyCastle.Utilities;
-
 namespace Org.BouncyCastle.Asn1.Cmp
 {
 	public class GenRepContent
 		: Asn1Encodable
 	{
-		private readonly Asn1Sequence content;
+        public static GenRepContent GetInstance(object obj)
+        {
+            if (obj is GenRepContent genRepContent)
+                return genRepContent;
 
-		private GenRepContent(Asn1Sequence seq)
-		{
-			content = seq;
-		}
+            if (obj != null)
+                return new GenRepContent(Asn1Sequence.GetInstance(obj));
 
-		public static GenRepContent GetInstance(object obj)
-		{
-			if (obj is GenRepContent)
-				return (GenRepContent)obj;
+            return null;
+        }
 
-			if (obj is Asn1Sequence)
-				return new GenRepContent((Asn1Sequence)obj);
+        private readonly Asn1Sequence m_content;
 
-            throw new ArgumentException("Invalid object: " + Platform.GetTypeName(obj), "obj");
+		private GenRepContent(Asn1Sequence seq)
+		{
+			m_content = seq;
 		}
 
-		public GenRepContent(params InfoTypeAndValue[] itv)
+        public GenRepContent(InfoTypeAndValue itv)
+        {
+            m_content = new DerSequence(itv);
+        }
+
+        public GenRepContent(params InfoTypeAndValue[] itvs)
 		{
-			content = new DerSequence(itv);
+			m_content = new DerSequence(itvs);
 		}
 
 		public virtual InfoTypeAndValue[] ToInfoTypeAndValueArray()
 		{
-			InfoTypeAndValue[] result = new InfoTypeAndValue[content.Count];
-			for (int i = 0; i != result.Length; ++i)
-			{
-				result[i] = InfoTypeAndValue.GetInstance(content[i]);
-			}
-			return result;
+            return m_content.MapElements(InfoTypeAndValue.GetInstance);
 		}
 
 		/**
@@ -48,7 +44,7 @@ namespace Org.BouncyCastle.Asn1.Cmp
 		 */
 		public override Asn1Object ToAsn1Object()
 		{
-			return content;
+			return m_content;
 		}
 	}
 }