From 7610f647360313aa86d89884c45ce6d334876b73 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Sat, 4 Feb 2023 02:17:04 +0700 Subject: Misc. refactoring after bc-fips-csharp updates --- crypto/src/asn1/esf/CertificateValues.cs | 23 +++++++++++------------ crypto/src/asn1/esf/CrlIdentifier.cs | 16 +++++++--------- 2 files changed, 18 insertions(+), 21 deletions(-) (limited to 'crypto/src/asn1/esf') diff --git a/crypto/src/asn1/esf/CertificateValues.cs b/crypto/src/asn1/esf/CertificateValues.cs index 8329e45f8..96088209f 100644 --- a/crypto/src/asn1/esf/CertificateValues.cs +++ b/crypto/src/asn1/esf/CertificateValues.cs @@ -19,20 +19,19 @@ namespace Org.BouncyCastle.Asn1.Esf public static CertificateValues GetInstance(object obj) { - if (obj == null) - return null; - - if (obj is CertificateValues certificateValues) - return certificateValues; - - if (obj is Asn1Sequence asn1Sequence) - return new CertificateValues(asn1Sequence); - - throw new ArgumentException("Unknown object in 'CertificateValues' factory: " + Platform.GetTypeName(obj), - nameof(obj)); + if (obj == null) + return null; + if (obj is CertificateValues certificateValues) + return certificateValues; + return new CertificateValues(Asn1Sequence.GetInstance(obj)); } - private CertificateValues(Asn1Sequence seq) + public static CertificateValues GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit) + { + return GetInstance(Asn1Sequence.GetInstance(taggedObject, declaredExplicit)); + } + + private CertificateValues(Asn1Sequence seq) { if (seq == null) throw new ArgumentNullException(nameof(seq)); diff --git a/crypto/src/asn1/esf/CrlIdentifier.cs b/crypto/src/asn1/esf/CrlIdentifier.cs index 29003260a..7d6225c63 100644 --- a/crypto/src/asn1/esf/CrlIdentifier.cs +++ b/crypto/src/asn1/esf/CrlIdentifier.cs @@ -2,7 +2,6 @@ using System; using Org.BouncyCastle.Asn1.X509; using Org.BouncyCastle.Math; -using Org.BouncyCastle.Utilities; namespace Org.BouncyCastle.Asn1.Esf { @@ -28,18 +27,17 @@ namespace Org.BouncyCastle.Asn1.Esf { if (obj == null) return null; - if (obj is CrlIdentifier crlIdentifier) return crlIdentifier; - - if (obj is Asn1Sequence asn1Sequence) - return new CrlIdentifier(asn1Sequence); - - throw new ArgumentException("Unknown object in 'CrlIdentifier' factory: " + Platform.GetTypeName(obj), - nameof(obj)); + return new CrlIdentifier(Asn1Sequence.GetInstance(obj)); } - private CrlIdentifier(Asn1Sequence seq) + public static CrlIdentifier GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit) + { + return GetInstance(Asn1Sequence.GetInstance(taggedObject, declaredExplicit)); + } + + private CrlIdentifier(Asn1Sequence seq) { if (seq == null) throw new ArgumentNullException(nameof(seq)); -- cgit 1.4.1