diff options
Diffstat (limited to 'crypto')
26 files changed, 52 insertions, 78 deletions
diff --git a/crypto/src/asn1/Asn1GeneralizedTime.cs b/crypto/src/asn1/Asn1GeneralizedTime.cs index 704b6a8bc..4fe5561a0 100644 --- a/crypto/src/asn1/Asn1GeneralizedTime.cs +++ b/crypto/src/asn1/Asn1GeneralizedTime.cs @@ -31,10 +31,9 @@ namespace Org.BouncyCastle.Asn1 if (obj is Asn1GeneralizedTime asn1GeneralizedTime) return asn1GeneralizedTime; - if (obj is IAsn1Convertible asn1Convertible && !(obj is Asn1Object)) + if (obj is IAsn1Convertible asn1Convertible) { - Asn1Object asn1Object = asn1Convertible.ToAsn1Object(); - if (asn1Object is Asn1GeneralizedTime converted) + if (!(obj is Asn1Object) && asn1Convertible.ToAsn1Object() is Asn1GeneralizedTime converted) return converted; } else if (obj is byte[] bytes) diff --git a/crypto/src/asn1/Asn1Null.cs b/crypto/src/asn1/Asn1Null.cs index 99f5a530c..992cd09aa 100644 --- a/crypto/src/asn1/Asn1Null.cs +++ b/crypto/src/asn1/Asn1Null.cs @@ -31,10 +31,9 @@ namespace Org.BouncyCastle.Asn1 if (obj is Asn1Null asn1Null) return asn1Null; - if (obj is IAsn1Convertible asn1Convertible && !(obj is Asn1Object)) + if (obj is IAsn1Convertible asn1Convertible) { - Asn1Object asn1Object = asn1Convertible.ToAsn1Object(); - if (asn1Object is Asn1Null converted) + if (!(obj is Asn1Object) && asn1Convertible.ToAsn1Object() is Asn1Null converted) return converted; } else if (obj is byte[] bytes) diff --git a/crypto/src/asn1/Asn1ObjectDescriptor.cs b/crypto/src/asn1/Asn1ObjectDescriptor.cs index c4b27ca8c..8d41fa4e4 100644 --- a/crypto/src/asn1/Asn1ObjectDescriptor.cs +++ b/crypto/src/asn1/Asn1ObjectDescriptor.cs @@ -42,10 +42,9 @@ namespace Org.BouncyCastle.Asn1 if (obj is Asn1ObjectDescriptor asn1ObjectDescriptor) return asn1ObjectDescriptor; - if (obj is IAsn1Convertible asn1Convertible && !(obj is Asn1Object)) + if (obj is IAsn1Convertible asn1Convertible) { - Asn1Object asn1Object = asn1Convertible.ToAsn1Object(); - if (asn1Object is Asn1ObjectDescriptor converted) + if (!(obj is Asn1Object) && asn1Convertible.ToAsn1Object() is Asn1ObjectDescriptor converted) return converted; } else if (obj is byte[] bytes) diff --git a/crypto/src/asn1/Asn1OctetString.cs b/crypto/src/asn1/Asn1OctetString.cs index 02f27cd9b..1713012f5 100644 --- a/crypto/src/asn1/Asn1OctetString.cs +++ b/crypto/src/asn1/Asn1OctetString.cs @@ -42,10 +42,9 @@ namespace Org.BouncyCastle.Asn1 if (obj is Asn1OctetString asn1OctetString) return asn1OctetString; - if (obj is IAsn1Convertible asn1Convertible && !(obj is Asn1Object)) + if (obj is IAsn1Convertible asn1Convertible) { - Asn1Object asn1Object = asn1Convertible.ToAsn1Object(); - if (asn1Object is Asn1OctetString converted) + if (!(obj is Asn1Object) && asn1Convertible.ToAsn1Object() is Asn1OctetString converted) return converted; } else if (obj is byte[] bytes) diff --git a/crypto/src/asn1/Asn1RelativeOid.cs b/crypto/src/asn1/Asn1RelativeOid.cs index 9aa57b650..4a84369c7 100644 --- a/crypto/src/asn1/Asn1RelativeOid.cs +++ b/crypto/src/asn1/Asn1RelativeOid.cs @@ -49,10 +49,9 @@ namespace Org.BouncyCastle.Asn1 if (obj is Asn1RelativeOid asn1RelativeOid) return asn1RelativeOid; - if (obj is IAsn1Convertible asn1Convertible && !(obj is Asn1Object)) + if (obj is IAsn1Convertible asn1Convertible) { - Asn1Object asn1Object = asn1Convertible.ToAsn1Object(); - if (asn1Object is Asn1RelativeOid converted) + if (!(obj is Asn1Object) && asn1Convertible.ToAsn1Object() is Asn1RelativeOid converted) return converted; } else if (obj is byte[] bytes) diff --git a/crypto/src/asn1/Asn1Sequence.cs b/crypto/src/asn1/Asn1Sequence.cs index d9562fa00..c23b82ef5 100644 --- a/crypto/src/asn1/Asn1Sequence.cs +++ b/crypto/src/asn1/Asn1Sequence.cs @@ -37,10 +37,9 @@ namespace Org.BouncyCastle.Asn1 if (obj is Asn1Sequence asn1Sequence) return asn1Sequence; - if (obj is IAsn1Convertible asn1Convertible && !(obj is Asn1Object)) + if (obj is IAsn1Convertible asn1Convertible) { - Asn1Object asn1Object = asn1Convertible.ToAsn1Object(); - if (asn1Object is Asn1Sequence converted) + if (!(obj is Asn1Object) && asn1Convertible.ToAsn1Object() is Asn1Sequence converted) return converted; } else if (obj is byte[] bytes) diff --git a/crypto/src/asn1/Asn1Set.cs b/crypto/src/asn1/Asn1Set.cs index 5f8fc389c..6ba0bb413 100644 --- a/crypto/src/asn1/Asn1Set.cs +++ b/crypto/src/asn1/Asn1Set.cs @@ -37,10 +37,9 @@ namespace Org.BouncyCastle.Asn1 if (obj is Asn1Set asn1Set) return asn1Set; - if (obj is IAsn1Convertible asn1Convertible && !(obj is Asn1Object)) + if (obj is IAsn1Convertible asn1Convertible) { - Asn1Object asn1Object = asn1Convertible.ToAsn1Object(); - if (asn1Object is Asn1Set converted) + if (!(obj is Asn1Object) && asn1Convertible.ToAsn1Object() is Asn1Set converted) return converted; } else if (obj is byte[] bytes) diff --git a/crypto/src/asn1/Asn1TaggedObject.cs b/crypto/src/asn1/Asn1TaggedObject.cs index 3a53d7852..0045ad448 100644 --- a/crypto/src/asn1/Asn1TaggedObject.cs +++ b/crypto/src/asn1/Asn1TaggedObject.cs @@ -27,10 +27,9 @@ namespace Org.BouncyCastle.Asn1 if (obj is Asn1TaggedObject asn1TaggedObject) return asn1TaggedObject; - if (obj is IAsn1Convertible asn1Convertible && !(obj is Asn1Object)) + if (obj is IAsn1Convertible asn1Convertible) { - Asn1Object asn1Object = asn1Convertible.ToAsn1Object(); - if (asn1Object is Asn1TaggedObject converted) + if (!(obj is Asn1Object) && asn1Convertible.ToAsn1Object() is Asn1TaggedObject converted) return converted; } else if (obj is byte[] bytes) diff --git a/crypto/src/asn1/Asn1UtcTime.cs b/crypto/src/asn1/Asn1UtcTime.cs index 836481833..42704f996 100644 --- a/crypto/src/asn1/Asn1UtcTime.cs +++ b/crypto/src/asn1/Asn1UtcTime.cs @@ -37,10 +37,9 @@ namespace Org.BouncyCastle.Asn1 if (obj is Asn1UtcTime asn1UtcTime) return asn1UtcTime; - if (obj is IAsn1Convertible asn1Convertible && !(obj is Asn1Object)) + if (obj is IAsn1Convertible asn1Convertible) { - Asn1Object asn1Object = asn1Convertible.ToAsn1Object(); - if (asn1Object is Asn1UtcTime converted) + if (!(obj is Asn1Object) && asn1Convertible.ToAsn1Object() is Asn1UtcTime converted) return converted; } else if (obj is byte[] bytes) diff --git a/crypto/src/asn1/DERExternal.cs b/crypto/src/asn1/DERExternal.cs index b36bf9623..c89fa8ec7 100644 --- a/crypto/src/asn1/DERExternal.cs +++ b/crypto/src/asn1/DERExternal.cs @@ -31,10 +31,9 @@ namespace Org.BouncyCastle.Asn1 if (obj is DerExternal derExternal) return derExternal; - if (obj is IAsn1Convertible asn1Convertible && !(obj is Asn1Object)) + if (obj is IAsn1Convertible asn1Convertible) { - Asn1Object asn1Object = asn1Convertible.ToAsn1Object(); - if (asn1Object is DerExternal converted) + if (!(obj is Asn1Object) && asn1Convertible.ToAsn1Object() is DerExternal converted) return converted; } else if (obj is byte[] bytes) diff --git a/crypto/src/asn1/DerBMPString.cs b/crypto/src/asn1/DerBMPString.cs index 5712dde6d..fcada7ad4 100644 --- a/crypto/src/asn1/DerBMPString.cs +++ b/crypto/src/asn1/DerBMPString.cs @@ -40,10 +40,9 @@ namespace Org.BouncyCastle.Asn1 if (obj is DerBmpString derBmpString) return derBmpString; - if (obj is IAsn1Convertible asn1Convertible && !(obj is Asn1Object)) + if (obj is IAsn1Convertible asn1Convertible) { - Asn1Object asn1Object = asn1Convertible.ToAsn1Object(); - if (asn1Object is DerBmpString converted) + if (!(obj is Asn1Object) && asn1Convertible.ToAsn1Object() is DerBmpString converted) return converted; } else if (obj is byte[] bytes) diff --git a/crypto/src/asn1/DerBitString.cs b/crypto/src/asn1/DerBitString.cs index 13955f4d5..d8b8be27f 100644 --- a/crypto/src/asn1/DerBitString.cs +++ b/crypto/src/asn1/DerBitString.cs @@ -39,10 +39,9 @@ namespace Org.BouncyCastle.Asn1 if (obj is DerBitString derBitString) return derBitString; - if (obj is IAsn1Convertible asn1Convertible && !(obj is Asn1Object)) + if (obj is IAsn1Convertible asn1Convertible) { - Asn1Object asn1Object = asn1Convertible.ToAsn1Object(); - if (asn1Object is DerBitString converted) + if (!(obj is Asn1Object) && asn1Convertible.ToAsn1Object() is DerBitString converted) return converted; } else if (obj is byte[] bytes) diff --git a/crypto/src/asn1/DerBoolean.cs b/crypto/src/asn1/DerBoolean.cs index a92346044..0f9388363 100644 --- a/crypto/src/asn1/DerBoolean.cs +++ b/crypto/src/asn1/DerBoolean.cs @@ -36,10 +36,9 @@ namespace Org.BouncyCastle.Asn1 if (obj is DerBoolean derBoolean) return derBoolean; - if (obj is IAsn1Convertible asn1Convertible && !(obj is Asn1Object)) + if (obj is IAsn1Convertible asn1Convertible) { - Asn1Object asn1Object = asn1Convertible.ToAsn1Object(); - if (asn1Object is DerBoolean converted) + if (!(obj is Asn1Object) && asn1Convertible.ToAsn1Object() is DerBoolean converted) return converted; } else if (obj is byte[] bytes) diff --git a/crypto/src/asn1/DerEnumerated.cs b/crypto/src/asn1/DerEnumerated.cs index 02f3fdd47..d46e1153d 100644 --- a/crypto/src/asn1/DerEnumerated.cs +++ b/crypto/src/asn1/DerEnumerated.cs @@ -34,10 +34,9 @@ namespace Org.BouncyCastle.Asn1 if (obj is DerEnumerated derEnumerated) return derEnumerated; - if (obj is IAsn1Convertible asn1Convertible && !(obj is Asn1Object)) + if (obj is IAsn1Convertible asn1Convertible) { - Asn1Object asn1Object = asn1Convertible.ToAsn1Object(); - if (asn1Object is DerEnumerated converted) + if (!(obj is Asn1Object) && asn1Convertible.ToAsn1Object() is DerEnumerated converted) return converted; } else if (obj is byte[] bytes) diff --git a/crypto/src/asn1/DerGeneralString.cs b/crypto/src/asn1/DerGeneralString.cs index 146703b81..db99b0328 100644 --- a/crypto/src/asn1/DerGeneralString.cs +++ b/crypto/src/asn1/DerGeneralString.cs @@ -28,10 +28,9 @@ namespace Org.BouncyCastle.Asn1 if (obj is DerGeneralString derGeneralString) return derGeneralString; - if (obj is IAsn1Convertible asn1Convertible && !(obj is Asn1Object)) + if (obj is IAsn1Convertible asn1Convertible) { - Asn1Object asn1Object = asn1Convertible.ToAsn1Object(); - if (asn1Object is DerGeneralString converted) + if (!(obj is Asn1Object) && asn1Convertible.ToAsn1Object() is DerGeneralString converted) return converted; } else if (obj is byte[] bytes) diff --git a/crypto/src/asn1/DerGraphicString.cs b/crypto/src/asn1/DerGraphicString.cs index e741c2ad2..8aa7456f7 100644 --- a/crypto/src/asn1/DerGraphicString.cs +++ b/crypto/src/asn1/DerGraphicString.cs @@ -35,10 +35,9 @@ namespace Org.BouncyCastle.Asn1 if (obj is DerGraphicString derGraphicString) return derGraphicString; - if (obj is IAsn1Convertible asn1Convertible && !(obj is Asn1Object)) + if (obj is IAsn1Convertible asn1Convertible) { - Asn1Object asn1Object = asn1Convertible.ToAsn1Object(); - if (asn1Object is DerGraphicString converted) + if (!(obj is Asn1Object) && asn1Convertible.ToAsn1Object() is DerGraphicString converted) return converted; } else if (obj is byte[] bytes) diff --git a/crypto/src/asn1/DerIA5String.cs b/crypto/src/asn1/DerIA5String.cs index 176ea061a..abb8be852 100644 --- a/crypto/src/asn1/DerIA5String.cs +++ b/crypto/src/asn1/DerIA5String.cs @@ -36,10 +36,9 @@ namespace Org.BouncyCastle.Asn1 if (obj is DerIA5String derIA5String) return derIA5String; - if (obj is IAsn1Convertible asn1Convertible && !(obj is Asn1Object)) + if (obj is IAsn1Convertible asn1Convertible) { - Asn1Object asn1Object = asn1Convertible.ToAsn1Object(); - if (asn1Object is DerIA5String converted) + if (!(obj is Asn1Object) && asn1Convertible.ToAsn1Object() is DerIA5String converted) return converted; } else if (obj is byte[] bytes) diff --git a/crypto/src/asn1/DerInteger.cs b/crypto/src/asn1/DerInteger.cs index 337e73ff6..59ca6046d 100644 --- a/crypto/src/asn1/DerInteger.cs +++ b/crypto/src/asn1/DerInteger.cs @@ -48,10 +48,9 @@ namespace Org.BouncyCastle.Asn1 if (obj is DerInteger derInteger) return derInteger; - if (obj is IAsn1Convertible asn1Convertible && !(obj is Asn1Object)) + if (obj is IAsn1Convertible asn1Convertible) { - Asn1Object asn1Object = asn1Convertible.ToAsn1Object(); - if (asn1Object is DerInteger converted) + if (!(obj is Asn1Object) && asn1Convertible.ToAsn1Object() is DerInteger converted) return converted; } else if (obj is byte[] bytes) diff --git a/crypto/src/asn1/DerNumericString.cs b/crypto/src/asn1/DerNumericString.cs index ecfa08b73..44adceb6b 100644 --- a/crypto/src/asn1/DerNumericString.cs +++ b/crypto/src/asn1/DerNumericString.cs @@ -36,10 +36,9 @@ namespace Org.BouncyCastle.Asn1 if (obj is DerNumericString derNumericString) return derNumericString; - if (obj is IAsn1Convertible asn1Convertible && !(obj is Asn1Object)) + if (obj is IAsn1Convertible asn1Convertible) { - Asn1Object asn1Object = asn1Convertible.ToAsn1Object(); - if (asn1Object is DerNumericString converted) + if (!(obj is Asn1Object) && asn1Convertible.ToAsn1Object() is DerNumericString converted) return converted; } else if (obj is byte[] bytes) diff --git a/crypto/src/asn1/DerObjectIdentifier.cs b/crypto/src/asn1/DerObjectIdentifier.cs index 7c76173f4..d09f2c094 100644 --- a/crypto/src/asn1/DerObjectIdentifier.cs +++ b/crypto/src/asn1/DerObjectIdentifier.cs @@ -54,10 +54,9 @@ namespace Org.BouncyCastle.Asn1 if (obj is DerObjectIdentifier derObjectIdentifier) return derObjectIdentifier; - if (obj is IAsn1Convertible asn1Convertible && !(obj is Asn1Object)) + if (obj is IAsn1Convertible asn1Convertible) { - Asn1Object asn1Object = asn1Convertible.ToAsn1Object(); - if (asn1Object is DerObjectIdentifier converted) + if (!(obj is Asn1Object) && asn1Convertible.ToAsn1Object() is DerObjectIdentifier converted) return converted; } else if (obj is byte[] bytes) diff --git a/crypto/src/asn1/DerPrintableString.cs b/crypto/src/asn1/DerPrintableString.cs index 5e9c99bdc..c3b453a9d 100644 --- a/crypto/src/asn1/DerPrintableString.cs +++ b/crypto/src/asn1/DerPrintableString.cs @@ -36,10 +36,9 @@ namespace Org.BouncyCastle.Asn1 if (obj is DerPrintableString derPrintableString) return derPrintableString; - if (obj is IAsn1Convertible asn1Convertible && !(obj is Asn1Object)) + if (obj is IAsn1Convertible asn1Convertible) { - Asn1Object asn1Object = asn1Convertible.ToAsn1Object(); - if (asn1Object is DerPrintableString converted) + if (!(obj is Asn1Object) && asn1Convertible.ToAsn1Object() is DerPrintableString converted) return converted; } else if (obj is byte[] bytes) diff --git a/crypto/src/asn1/DerT61String.cs b/crypto/src/asn1/DerT61String.cs index 05b0c62f5..cc02be41d 100644 --- a/crypto/src/asn1/DerT61String.cs +++ b/crypto/src/asn1/DerT61String.cs @@ -36,10 +36,9 @@ namespace Org.BouncyCastle.Asn1 if (obj is DerT61String derT61String) return derT61String; - if (obj is IAsn1Convertible asn1Convertible && !(obj is Asn1Object)) + if (obj is IAsn1Convertible asn1Convertible) { - Asn1Object asn1Object = asn1Convertible.ToAsn1Object(); - if (asn1Object is DerT61String converted) + if (!(obj is Asn1Object) && asn1Convertible.ToAsn1Object() is DerT61String converted) return converted; } else if (obj is byte[] bytes) diff --git a/crypto/src/asn1/DerUTF8String.cs b/crypto/src/asn1/DerUTF8String.cs index 965a8ebf8..6e933ba4b 100644 --- a/crypto/src/asn1/DerUTF8String.cs +++ b/crypto/src/asn1/DerUTF8String.cs @@ -36,10 +36,9 @@ namespace Org.BouncyCastle.Asn1 if (obj is DerUtf8String derUtf8String) return derUtf8String; - if (obj is IAsn1Convertible asn1Convertible && !(obj is Asn1Object)) + if (obj is IAsn1Convertible asn1Convertible) { - Asn1Object asn1Object = asn1Convertible.ToAsn1Object(); - if (asn1Object is DerUtf8String converted) + if (!(obj is Asn1Object) && asn1Convertible.ToAsn1Object() is DerUtf8String converted) return converted; } else if (obj is byte[] bytes) diff --git a/crypto/src/asn1/DerUniversalString.cs b/crypto/src/asn1/DerUniversalString.cs index fc031ecf5..806c869e5 100644 --- a/crypto/src/asn1/DerUniversalString.cs +++ b/crypto/src/asn1/DerUniversalString.cs @@ -40,10 +40,9 @@ namespace Org.BouncyCastle.Asn1 if (obj is DerUniversalString derUniversalString) return derUniversalString; - if (obj is IAsn1Convertible asn1Convertible && !(obj is Asn1Object)) + if (obj is IAsn1Convertible asn1Convertible) { - Asn1Object asn1Object = asn1Convertible.ToAsn1Object(); - if (asn1Object is DerUniversalString converted) + if (!(obj is Asn1Object) && asn1Convertible.ToAsn1Object() is DerUniversalString converted) return converted; } else if (obj is byte[] bytes) diff --git a/crypto/src/asn1/DerVideotexString.cs b/crypto/src/asn1/DerVideotexString.cs index 3b65861f0..de236e195 100644 --- a/crypto/src/asn1/DerVideotexString.cs +++ b/crypto/src/asn1/DerVideotexString.cs @@ -35,10 +35,9 @@ namespace Org.BouncyCastle.Asn1 if (obj is DerVideotexString derVideotexString) return derVideotexString; - if (obj is IAsn1Convertible asn1Convertible && !(obj is Asn1Object)) + if (obj is IAsn1Convertible asn1Convertible) { - Asn1Object asn1Object = asn1Convertible.ToAsn1Object(); - if (asn1Object is DerVideotexString converted) + if (!(obj is Asn1Object) && asn1Convertible.ToAsn1Object() is DerVideotexString converted) return converted; } else if (obj is byte[] bytes) diff --git a/crypto/src/asn1/DerVisibleString.cs b/crypto/src/asn1/DerVisibleString.cs index 0d8131d65..55bfe8604 100644 --- a/crypto/src/asn1/DerVisibleString.cs +++ b/crypto/src/asn1/DerVisibleString.cs @@ -36,10 +36,9 @@ namespace Org.BouncyCastle.Asn1 if (obj is DerVisibleString derVisibleString) return derVisibleString; - if (obj is IAsn1Convertible asn1Convertible && !(obj is Asn1Object)) + if (obj is IAsn1Convertible asn1Convertible) { - Asn1Object asn1Object = asn1Convertible.ToAsn1Object(); - if (asn1Object is DerVisibleString converted) + if (!(obj is Asn1Object) && asn1Convertible.ToAsn1Object() is DerVisibleString converted) return converted; } else if (obj is byte[] bytes) |