summary refs log tree commit diff
path: root/crypto/src/pkcs/Pkcs10CertificationRequestDelaySigned.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2024-03-12 17:00:28 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2024-03-12 17:00:28 +0700
commitb243cd4ff1d6e8049ee58ec971771c92139db70b (patch)
tree27ebad743538d7386c2aae94f0992c834e333a48 /crypto/src/pkcs/Pkcs10CertificationRequestDelaySigned.cs
parentASN.1: Limit OID contents to 4096 bytes (diff)
downloadBouncyCastle.NET-ed25519-b243cd4ff1d6e8049ee58ec971771c92139db70b.tar.xz
Use TryFromID to check for OID string
Diffstat (limited to '')
-rw-r--r--crypto/src/pkcs/Pkcs10CertificationRequestDelaySigned.cs18
1 files changed, 6 insertions, 12 deletions
diff --git a/crypto/src/pkcs/Pkcs10CertificationRequestDelaySigned.cs b/crypto/src/pkcs/Pkcs10CertificationRequestDelaySigned.cs
index e3a710f37..f95cf826c 100644
--- a/crypto/src/pkcs/Pkcs10CertificationRequestDelaySigned.cs
+++ b/crypto/src/pkcs/Pkcs10CertificationRequestDelaySigned.cs
@@ -95,18 +95,12 @@ namespace Org.BouncyCastle.Pkcs
 			if (publicKey.IsPrivate)
 				throw new ArgumentException("expected public key", "publicKey");
 
-			DerObjectIdentifier sigOid = CollectionUtilities.GetValueOrNull(m_algorithms, signatureAlgorithm);
-			if (sigOid == null)
-			{
-				try
-				{
-					sigOid = new DerObjectIdentifier(signatureAlgorithm);
-				}
-				catch (Exception e)
-				{
-					throw new ArgumentException("Unknown signature type requested", e);
-				}
-			}
+            if (!m_algorithms.TryGetValue(signatureAlgorithm, out var sigOid) &&
+                !DerObjectIdentifier.TryFromID(signatureAlgorithm, out sigOid))
+            {
+                throw new ArgumentException("Unknown signature type requested");
+            }
+
 			if (m_noParams.Contains(sigOid))
 			{
 				this.sigAlgId = new AlgorithmIdentifier(sigOid);