diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-07-14 15:07:49 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-07-14 15:07:49 +0700 |
commit | dc8b86c13c769e6de9a5c38e3c67921b034a2394 (patch) | |
tree | b79eb20bc7ed797e7624ccb5ceb8293ed429751e /crypto/src/asn1/crmf | |
parent | Refactor using MapElements (diff) | |
download | BouncyCastle.NET-ed25519-dc8b86c13c769e6de9a5c38e3c67921b034a2394.tar.xz |
Refactoring in Asn1
Diffstat (limited to 'crypto/src/asn1/crmf')
-rw-r--r-- | crypto/src/asn1/crmf/PKIArchiveOptions.cs | 8 | ||||
-rw-r--r-- | crypto/src/asn1/crmf/PopoSigningKey.cs | 11 | ||||
-rw-r--r-- | crypto/src/asn1/crmf/PopoSigningKeyInput.cs | 8 | ||||
-rw-r--r-- | crypto/src/asn1/crmf/ProofOfPossession.cs | 8 |
4 files changed, 16 insertions, 19 deletions
diff --git a/crypto/src/asn1/crmf/PKIArchiveOptions.cs b/crypto/src/asn1/crmf/PKIArchiveOptions.cs index 1813d87a7..e546fb3bb 100644 --- a/crypto/src/asn1/crmf/PKIArchiveOptions.cs +++ b/crypto/src/asn1/crmf/PKIArchiveOptions.cs @@ -15,11 +15,11 @@ namespace Org.BouncyCastle.Asn1.Crmf public static PkiArchiveOptions GetInstance(object obj) { - if (obj is PkiArchiveOptions) - return (PkiArchiveOptions)obj; + if (obj is PkiArchiveOptions pkiArchiveOptions) + return pkiArchiveOptions; - if (obj is Asn1TaggedObject) - return new PkiArchiveOptions((Asn1TaggedObject)obj); + if (obj is Asn1TaggedObject taggedObject) + return new PkiArchiveOptions(taggedObject); throw new ArgumentException("Invalid object: " + Platform.GetTypeName(obj), "obj"); } diff --git a/crypto/src/asn1/crmf/PopoSigningKey.cs b/crypto/src/asn1/crmf/PopoSigningKey.cs index 93e14e30d..caa226b56 100644 --- a/crypto/src/asn1/crmf/PopoSigningKey.cs +++ b/crypto/src/asn1/crmf/PopoSigningKey.cs @@ -16,14 +16,13 @@ namespace Org.BouncyCastle.Asn1.Crmf { int index = 0; - if (seq[index] is Asn1TaggedObject) + if (seq[index] is Asn1TaggedObject tagObj) { - Asn1TaggedObject tagObj - = (Asn1TaggedObject) seq[index++]; + index++; + if (tagObj.TagNo != 0) - { - throw new ArgumentException( "Unknown PopoSigningKeyInput tag: " + tagObj.TagNo, "seq"); - } + throw new ArgumentException( "Unknown PopoSigningKeyInput tag: " + tagObj.TagNo, nameof(seq)); + poposkInput = PopoSigningKeyInput.GetInstance(tagObj.GetObject()); } algorithmIdentifier = AlgorithmIdentifier.GetInstance(seq[index++]); diff --git a/crypto/src/asn1/crmf/PopoSigningKeyInput.cs b/crypto/src/asn1/crmf/PopoSigningKeyInput.cs index 30d017475..f2517aa57 100644 --- a/crypto/src/asn1/crmf/PopoSigningKeyInput.cs +++ b/crypto/src/asn1/crmf/PopoSigningKeyInput.cs @@ -16,13 +16,11 @@ namespace Org.BouncyCastle.Asn1.Crmf { Asn1Encodable authInfo = (Asn1Encodable)seq[0]; - if (authInfo is Asn1TaggedObject) + if (authInfo is Asn1TaggedObject tagObj) { - Asn1TaggedObject tagObj = (Asn1TaggedObject)authInfo; if (tagObj.TagNo != 0) - { - throw new ArgumentException("Unknown authInfo tag: " + tagObj.TagNo, "seq"); - } + throw new ArgumentException("Unknown authInfo tag: " + tagObj.TagNo, nameof(seq)); + sender = GeneralName.GetInstance(tagObj.GetObject()); } else diff --git a/crypto/src/asn1/crmf/ProofOfPossession.cs b/crypto/src/asn1/crmf/ProofOfPossession.cs index 7ba7251a1..6ef62efda 100644 --- a/crypto/src/asn1/crmf/ProofOfPossession.cs +++ b/crypto/src/asn1/crmf/ProofOfPossession.cs @@ -38,11 +38,11 @@ namespace Org.BouncyCastle.Asn1.Crmf public static ProofOfPossession GetInstance(object obj) { - if (obj is ProofOfPossession) - return (ProofOfPossession)obj; + if (obj is ProofOfPossession proofOfPossession) + return proofOfPossession; - if (obj is Asn1TaggedObject) - return new ProofOfPossession((Asn1TaggedObject)obj); + if (obj is Asn1TaggedObject taggedObject) + return new ProofOfPossession(taggedObject); throw new ArgumentException("Invalid object: " + Platform.GetTypeName(obj), "obj"); } |