From 4465dd325cfec9c80fec084399f80070557ecbc0 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Fri, 21 Jun 2024 18:02:12 +0700 Subject: ASN.1: GetOptional for universal types should not convert --- crypto/src/asn1/Asn1GeneralizedTime.cs | 6 ------ crypto/src/asn1/Asn1Null.cs | 6 ------ crypto/src/asn1/Asn1ObjectDescriptor.cs | 6 ------ crypto/src/asn1/Asn1OctetString.cs | 6 ------ crypto/src/asn1/Asn1RelativeOid.cs | 6 ------ crypto/src/asn1/Asn1Sequence.cs | 6 ------ crypto/src/asn1/Asn1Set.cs | 6 ------ crypto/src/asn1/Asn1TaggedObject.cs | 6 ------ crypto/src/asn1/Asn1UtcTime.cs | 6 ------ crypto/src/asn1/DERExternal.cs | 6 ------ crypto/src/asn1/DerBMPString.cs | 6 ------ crypto/src/asn1/DerBitString.cs | 6 ------ crypto/src/asn1/DerBoolean.cs | 6 ------ crypto/src/asn1/DerEnumerated.cs | 6 ------ crypto/src/asn1/DerGeneralString.cs | 6 ------ crypto/src/asn1/DerGraphicString.cs | 6 ------ crypto/src/asn1/DerIA5String.cs | 6 ------ crypto/src/asn1/DerInteger.cs | 6 ------ crypto/src/asn1/DerNumericString.cs | 6 ------ crypto/src/asn1/DerObjectIdentifier.cs | 6 ------ crypto/src/asn1/DerPrintableString.cs | 6 ------ crypto/src/asn1/DerT61String.cs | 6 ------ crypto/src/asn1/DerUTF8String.cs | 6 ------ crypto/src/asn1/DerUniversalString.cs | 6 ------ crypto/src/asn1/DerVideotexString.cs | 6 ------ crypto/src/asn1/DerVisibleString.cs | 6 ------ 26 files changed, 156 deletions(-) diff --git a/crypto/src/asn1/Asn1GeneralizedTime.cs b/crypto/src/asn1/Asn1GeneralizedTime.cs index 9a6ed0a8a..6482b0f1a 100644 --- a/crypto/src/asn1/Asn1GeneralizedTime.cs +++ b/crypto/src/asn1/Asn1GeneralizedTime.cs @@ -64,12 +64,6 @@ namespace Org.BouncyCastle.Asn1 if (element is Asn1GeneralizedTime existing) return existing; - if (element is IAsn1Convertible asn1Convertible && !(element is Asn1Object) && - asn1Convertible.ToAsn1Object() is Asn1GeneralizedTime converted) - { - return converted; - } - return null; } diff --git a/crypto/src/asn1/Asn1Null.cs b/crypto/src/asn1/Asn1Null.cs index 93a56ecc4..0572be3f7 100644 --- a/crypto/src/asn1/Asn1Null.cs +++ b/crypto/src/asn1/Asn1Null.cs @@ -64,12 +64,6 @@ namespace Org.BouncyCastle.Asn1 if (element is Asn1Null existing) return existing; - if (element is IAsn1Convertible asn1Convertible && !(element is Asn1Object) && - asn1Convertible.ToAsn1Object() is Asn1Null converted) - { - return converted; - } - return null; } diff --git a/crypto/src/asn1/Asn1ObjectDescriptor.cs b/crypto/src/asn1/Asn1ObjectDescriptor.cs index 3f43a5070..0f5ae4507 100644 --- a/crypto/src/asn1/Asn1ObjectDescriptor.cs +++ b/crypto/src/asn1/Asn1ObjectDescriptor.cs @@ -83,12 +83,6 @@ namespace Org.BouncyCastle.Asn1 if (element is Asn1ObjectDescriptor existing) return existing; - if (element is IAsn1Convertible asn1Convertible && !(element is Asn1Object) && - asn1Convertible.ToAsn1Object() is Asn1ObjectDescriptor converted) - { - return converted; - } - return null; } diff --git a/crypto/src/asn1/Asn1OctetString.cs b/crypto/src/asn1/Asn1OctetString.cs index e90fa1ef3..82dd6d24d 100644 --- a/crypto/src/asn1/Asn1OctetString.cs +++ b/crypto/src/asn1/Asn1OctetString.cs @@ -82,12 +82,6 @@ namespace Org.BouncyCastle.Asn1 if (element is Asn1OctetString existing) return existing; - if (element is IAsn1Convertible asn1Convertible && !(element is Asn1Object) && - asn1Convertible.ToAsn1Object() is Asn1OctetString converted) - { - return converted; - } - return null; } diff --git a/crypto/src/asn1/Asn1RelativeOid.cs b/crypto/src/asn1/Asn1RelativeOid.cs index af0cd99f2..17e610121 100644 --- a/crypto/src/asn1/Asn1RelativeOid.cs +++ b/crypto/src/asn1/Asn1RelativeOid.cs @@ -82,12 +82,6 @@ namespace Org.BouncyCastle.Asn1 if (element is Asn1RelativeOid existing) return existing; - if (element is IAsn1Convertible asn1Convertible && !(element is Asn1Object) && - asn1Convertible.ToAsn1Object() is Asn1RelativeOid converted) - { - return converted; - } - return null; } diff --git a/crypto/src/asn1/Asn1Sequence.cs b/crypto/src/asn1/Asn1Sequence.cs index 9f95c780d..6618df546 100644 --- a/crypto/src/asn1/Asn1Sequence.cs +++ b/crypto/src/asn1/Asn1Sequence.cs @@ -84,12 +84,6 @@ namespace Org.BouncyCastle.Asn1 if (element is Asn1Sequence existing) return existing; - if (element is IAsn1Convertible asn1Convertible && !(element is Asn1Object) && - asn1Convertible.ToAsn1Object() is Asn1Sequence converted) - { - return converted; - } - return null; } diff --git a/crypto/src/asn1/Asn1Set.cs b/crypto/src/asn1/Asn1Set.cs index 3cb497457..c85c6f97d 100644 --- a/crypto/src/asn1/Asn1Set.cs +++ b/crypto/src/asn1/Asn1Set.cs @@ -84,12 +84,6 @@ namespace Org.BouncyCastle.Asn1 if (element is Asn1Set existing) return existing; - if (element is IAsn1Convertible asn1Convertible && !(element is Asn1Object) && - asn1Convertible.ToAsn1Object() is Asn1Set converted) - { - return converted; - } - return null; } diff --git a/crypto/src/asn1/Asn1TaggedObject.cs b/crypto/src/asn1/Asn1TaggedObject.cs index 510133a5b..2ce2c7cde 100644 --- a/crypto/src/asn1/Asn1TaggedObject.cs +++ b/crypto/src/asn1/Asn1TaggedObject.cs @@ -81,12 +81,6 @@ namespace Org.BouncyCastle.Asn1 if (element is Asn1TaggedObject existing) return existing; - if (element is IAsn1Convertible asn1Convertible && !(element is Asn1Object) && - asn1Convertible.ToAsn1Object() is Asn1TaggedObject converted) - { - return converted; - } - return null; } diff --git a/crypto/src/asn1/Asn1UtcTime.cs b/crypto/src/asn1/Asn1UtcTime.cs index ffcfec70a..795abaa94 100644 --- a/crypto/src/asn1/Asn1UtcTime.cs +++ b/crypto/src/asn1/Asn1UtcTime.cs @@ -70,12 +70,6 @@ namespace Org.BouncyCastle.Asn1 if (element is Asn1UtcTime existing) return existing; - if (element is IAsn1Convertible asn1Convertible && !(element is Asn1Object) && - asn1Convertible.ToAsn1Object() is Asn1UtcTime converted) - { - return converted; - } - return null; } diff --git a/crypto/src/asn1/DERExternal.cs b/crypto/src/asn1/DERExternal.cs index 5d4d9fd92..417c9646f 100644 --- a/crypto/src/asn1/DERExternal.cs +++ b/crypto/src/asn1/DERExternal.cs @@ -64,12 +64,6 @@ namespace Org.BouncyCastle.Asn1 if (element is DerExternal existing) return existing; - if (element is IAsn1Convertible asn1Convertible && !(element is Asn1Object) && - asn1Convertible.ToAsn1Object() is DerExternal converted) - { - return converted; - } - return null; } diff --git a/crypto/src/asn1/DerBMPString.cs b/crypto/src/asn1/DerBMPString.cs index 37d34897a..009b7aa58 100644 --- a/crypto/src/asn1/DerBMPString.cs +++ b/crypto/src/asn1/DerBMPString.cs @@ -80,12 +80,6 @@ namespace Org.BouncyCastle.Asn1 if (element is DerBmpString existing) return existing; - if (element is IAsn1Convertible asn1Convertible && !(element is Asn1Object) && - asn1Convertible.ToAsn1Object() is DerBmpString converted) - { - return converted; - } - return null; } diff --git a/crypto/src/asn1/DerBitString.cs b/crypto/src/asn1/DerBitString.cs index b83f4ebf0..cf4bffcc2 100644 --- a/crypto/src/asn1/DerBitString.cs +++ b/crypto/src/asn1/DerBitString.cs @@ -72,12 +72,6 @@ namespace Org.BouncyCastle.Asn1 if (element is DerBitString existing) return existing; - if (element is IAsn1Convertible asn1Convertible && !(element is Asn1Object) && - asn1Convertible.ToAsn1Object() is DerBitString converted) - { - return converted; - } - return null; } diff --git a/crypto/src/asn1/DerBoolean.cs b/crypto/src/asn1/DerBoolean.cs index a75ada5d3..5dd78098e 100644 --- a/crypto/src/asn1/DerBoolean.cs +++ b/crypto/src/asn1/DerBoolean.cs @@ -86,12 +86,6 @@ namespace Org.BouncyCastle.Asn1 if (element is DerBoolean existing) return existing; - if (element is IAsn1Convertible asn1Convertible && !(element is Asn1Object) && - asn1Convertible.ToAsn1Object() is DerBoolean converted) - { - return converted; - } - return null; } diff --git a/crypto/src/asn1/DerEnumerated.cs b/crypto/src/asn1/DerEnumerated.cs index 5025336bf..5a044d608 100644 --- a/crypto/src/asn1/DerEnumerated.cs +++ b/crypto/src/asn1/DerEnumerated.cs @@ -74,12 +74,6 @@ namespace Org.BouncyCastle.Asn1 if (element is DerEnumerated existing) return existing; - if (element is IAsn1Convertible asn1Convertible && !(element is Asn1Object) && - asn1Convertible.ToAsn1Object() is DerEnumerated converted) - { - return converted; - } - return null; } diff --git a/crypto/src/asn1/DerGeneralString.cs b/crypto/src/asn1/DerGeneralString.cs index a65eb669b..f2740eb54 100644 --- a/crypto/src/asn1/DerGeneralString.cs +++ b/crypto/src/asn1/DerGeneralString.cs @@ -61,12 +61,6 @@ namespace Org.BouncyCastle.Asn1 if (element is DerGeneralString existing) return existing; - if (element is IAsn1Convertible asn1Convertible && !(element is Asn1Object) && - asn1Convertible.ToAsn1Object() is DerGeneralString converted) - { - return converted; - } - return null; } diff --git a/crypto/src/asn1/DerGraphicString.cs b/crypto/src/asn1/DerGraphicString.cs index be3d70977..3197da625 100644 --- a/crypto/src/asn1/DerGraphicString.cs +++ b/crypto/src/asn1/DerGraphicString.cs @@ -76,12 +76,6 @@ namespace Org.BouncyCastle.Asn1 if (element is DerGraphicString existing) return existing; - if (element is IAsn1Convertible asn1Convertible && !(element is Asn1Object) && - asn1Convertible.ToAsn1Object() is DerGraphicString converted) - { - return converted; - } - return null; } diff --git a/crypto/src/asn1/DerIA5String.cs b/crypto/src/asn1/DerIA5String.cs index a03ded9c6..bd235b0b6 100644 --- a/crypto/src/asn1/DerIA5String.cs +++ b/crypto/src/asn1/DerIA5String.cs @@ -76,12 +76,6 @@ namespace Org.BouncyCastle.Asn1 if (element is DerIA5String existing) return existing; - if (element is IAsn1Convertible asn1Convertible && !(element is Asn1Object) && - asn1Convertible.ToAsn1Object() is DerIA5String converted) - { - return converted; - } - return null; } diff --git a/crypto/src/asn1/DerInteger.cs b/crypto/src/asn1/DerInteger.cs index c46aa99df..5e74e9a81 100644 --- a/crypto/src/asn1/DerInteger.cs +++ b/crypto/src/asn1/DerInteger.cs @@ -95,12 +95,6 @@ namespace Org.BouncyCastle.Asn1 if (element is DerInteger existing) return existing; - if (element is IAsn1Convertible asn1Convertible && !(element is Asn1Object) && - asn1Convertible.ToAsn1Object() is DerInteger converted) - { - return converted; - } - return null; } diff --git a/crypto/src/asn1/DerNumericString.cs b/crypto/src/asn1/DerNumericString.cs index 5c30217d2..557f951ec 100644 --- a/crypto/src/asn1/DerNumericString.cs +++ b/crypto/src/asn1/DerNumericString.cs @@ -76,12 +76,6 @@ namespace Org.BouncyCastle.Asn1 if (element is DerNumericString existing) return existing; - if (element is IAsn1Convertible asn1Convertible && !(element is Asn1Object) && - asn1Convertible.ToAsn1Object() is DerNumericString converted) - { - return converted; - } - return null; } diff --git a/crypto/src/asn1/DerObjectIdentifier.cs b/crypto/src/asn1/DerObjectIdentifier.cs index b9d52a576..0cf3b7f33 100644 --- a/crypto/src/asn1/DerObjectIdentifier.cs +++ b/crypto/src/asn1/DerObjectIdentifier.cs @@ -99,12 +99,6 @@ namespace Org.BouncyCastle.Asn1 if (element is DerObjectIdentifier existing) return existing; - if (element is IAsn1Convertible asn1Convertible && !(element is Asn1Object) && - asn1Convertible.ToAsn1Object() is DerObjectIdentifier converted) - { - return converted; - } - return null; } diff --git a/crypto/src/asn1/DerPrintableString.cs b/crypto/src/asn1/DerPrintableString.cs index fcbe9dc84..f05511364 100644 --- a/crypto/src/asn1/DerPrintableString.cs +++ b/crypto/src/asn1/DerPrintableString.cs @@ -76,12 +76,6 @@ namespace Org.BouncyCastle.Asn1 if (element is DerPrintableString existing) return existing; - if (element is IAsn1Convertible asn1Convertible && !(element is Asn1Object) && - asn1Convertible.ToAsn1Object() is DerPrintableString converted) - { - return converted; - } - return null; } diff --git a/crypto/src/asn1/DerT61String.cs b/crypto/src/asn1/DerT61String.cs index 653702b55..9d3d9486a 100644 --- a/crypto/src/asn1/DerT61String.cs +++ b/crypto/src/asn1/DerT61String.cs @@ -76,12 +76,6 @@ namespace Org.BouncyCastle.Asn1 if (element is DerT61String existing) return existing; - if (element is IAsn1Convertible asn1Convertible && !(element is Asn1Object) && - asn1Convertible.ToAsn1Object() is DerT61String converted) - { - return converted; - } - return null; } diff --git a/crypto/src/asn1/DerUTF8String.cs b/crypto/src/asn1/DerUTF8String.cs index 61a76e9b0..701330dd9 100644 --- a/crypto/src/asn1/DerUTF8String.cs +++ b/crypto/src/asn1/DerUTF8String.cs @@ -76,12 +76,6 @@ namespace Org.BouncyCastle.Asn1 if (element is DerUtf8String existing) return existing; - if (element is IAsn1Convertible asn1Convertible && !(element is Asn1Object) && - asn1Convertible.ToAsn1Object() is DerUtf8String converted) - { - return converted; - } - return null; } diff --git a/crypto/src/asn1/DerUniversalString.cs b/crypto/src/asn1/DerUniversalString.cs index 47e7cc9a6..53a441ad1 100644 --- a/crypto/src/asn1/DerUniversalString.cs +++ b/crypto/src/asn1/DerUniversalString.cs @@ -80,12 +80,6 @@ namespace Org.BouncyCastle.Asn1 if (element is DerUniversalString existing) return existing; - if (element is IAsn1Convertible asn1Convertible && !(element is Asn1Object) && - asn1Convertible.ToAsn1Object() is DerUniversalString converted) - { - return converted; - } - return null; } diff --git a/crypto/src/asn1/DerVideotexString.cs b/crypto/src/asn1/DerVideotexString.cs index 5ace0cb17..9d136b7b9 100644 --- a/crypto/src/asn1/DerVideotexString.cs +++ b/crypto/src/asn1/DerVideotexString.cs @@ -76,12 +76,6 @@ namespace Org.BouncyCastle.Asn1 if (element is DerVideotexString existing) return existing; - if (element is IAsn1Convertible asn1Convertible && !(element is Asn1Object) && - asn1Convertible.ToAsn1Object() is DerVideotexString converted) - { - return converted; - } - return null; } diff --git a/crypto/src/asn1/DerVisibleString.cs b/crypto/src/asn1/DerVisibleString.cs index c0e296cef..0c4959b49 100644 --- a/crypto/src/asn1/DerVisibleString.cs +++ b/crypto/src/asn1/DerVisibleString.cs @@ -76,12 +76,6 @@ namespace Org.BouncyCastle.Asn1 if (element is DerVisibleString existing) return existing; - if (element is IAsn1Convertible asn1Convertible && !(element is Asn1Object) && - asn1Convertible.ToAsn1Object() is DerVisibleString converted) - { - return converted; - } - return null; } -- cgit 1.4.1