summary refs log tree commit diff
path: root/crypto/src/asn1/ocsp
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2023-07-14 15:07:49 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2023-07-14 15:07:49 +0700
commitdc8b86c13c769e6de9a5c38e3c67921b034a2394 (patch)
treeb79eb20bc7ed797e7624ccb5ceb8293ed429751e /crypto/src/asn1/ocsp
parentRefactor using MapElements (diff)
downloadBouncyCastle.NET-ed25519-dc8b86c13c769e6de9a5c38e3c67921b034a2394.tar.xz
Refactoring in Asn1
Diffstat (limited to 'crypto/src/asn1/ocsp')
-rw-r--r--crypto/src/asn1/ocsp/CertStatus.cs20
-rw-r--r--crypto/src/asn1/ocsp/TBSRequest.cs9
2 files changed, 13 insertions, 16 deletions
diff --git a/crypto/src/asn1/ocsp/CertStatus.cs b/crypto/src/asn1/ocsp/CertStatus.cs
index 8a4d2242d..65f11fc7f 100644
--- a/crypto/src/asn1/ocsp/CertStatus.cs
+++ b/crypto/src/asn1/ocsp/CertStatus.cs
@@ -54,23 +54,21 @@ namespace Org.BouncyCastle.Asn1.Ocsp
             }
         }
 
-		public static CertStatus GetInstance(
-            object obj)
+        public static CertStatus GetInstance(object obj)
         {
-            if (obj == null || obj is CertStatus)
-            {
-                return (CertStatus)obj;
-            }
+            if (obj == null)
+                return null;
 
-			if (obj is Asn1TaggedObject)
-            {
-                return new CertStatus((Asn1TaggedObject)obj);
-            }
+            if (obj is CertStatus certStatus)
+                return certStatus;
+
+            if (obj is Asn1TaggedObject taggedObject)
+                return new CertStatus(taggedObject);
 
             throw new ArgumentException("unknown object in factory: " + Platform.GetTypeName(obj), "obj");
         }
 
-		public int TagNo
+        public int TagNo
 		{
 			get { return tagNo; }
 		}
diff --git a/crypto/src/asn1/ocsp/TBSRequest.cs b/crypto/src/asn1/ocsp/TBSRequest.cs
index fd5f153d7..8e3373f87 100644
--- a/crypto/src/asn1/ocsp/TBSRequest.cs
+++ b/crypto/src/asn1/ocsp/TBSRequest.cs
@@ -57,10 +57,8 @@ namespace Org.BouncyCastle.Asn1.Ocsp
             int index = 0;
 
 			Asn1Encodable enc = seq[0];
-			if (enc is Asn1TaggedObject)
+			if (enc is Asn1TaggedObject o)
             {
-                Asn1TaggedObject o = (Asn1TaggedObject) enc;
-
 				if (o.TagNo == 0)
                 {
 					versionSet = true;
@@ -77,9 +75,10 @@ namespace Org.BouncyCastle.Asn1.Ocsp
                 version = V1;
             }
 
-			if (seq[index] is Asn1TaggedObject)
+			if (seq[index] is Asn1TaggedObject taggedObject)
             {
-                requestorName = GeneralName.GetInstance((Asn1TaggedObject) seq[index++], true);
+                index++;
+                requestorName = GeneralName.GetInstance(taggedObject, true);
             }
 
 			requestList = (Asn1Sequence) seq[index++];