diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-02-04 02:17:04 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-02-04 02:17:04 +0700 |
commit | 7610f647360313aa86d89884c45ce6d334876b73 (patch) | |
tree | b01a0b682c5064cae4b5e1f075089410edfbfdbe /crypto/src/asn1 | |
parent | Update IPAddress from bc-java (diff) | |
download | BouncyCastle.NET-ed25519-7610f647360313aa86d89884c45ce6d334876b73.tar.xz |
Misc. refactoring after bc-fips-csharp updates
Diffstat (limited to 'crypto/src/asn1')
-rw-r--r-- | crypto/src/asn1/esf/CertificateValues.cs | 23 | ||||
-rw-r--r-- | crypto/src/asn1/esf/CrlIdentifier.cs | 16 |
2 files changed, 18 insertions, 21 deletions
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)); |