Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annotate unsupported APIs in System.Security.* #50528

Closed
Tracked by #64488
buyaa-n opened this issue Mar 31, 2021 · 38 comments · Fixed by #67264
Closed
Tracked by #64488

Annotate unsupported APIs in System.Security.* #50528

buyaa-n opened this issue Mar 31, 2021 · 38 comments · Fixed by #67264

Comments

@buyaa-n
Copy link
Member

buyaa-n commented Mar 31, 2021

As part of #47228 i am running an analyzer to detect APIs throwing PNSE but not annotated with Obsolete/SupportedOSPlatform/UnsupportedOSPlatform attributes, we need to annotate them so that developers get warnings when they use them unexpectedly

For now, I have results only for cross-platform builds, analysis of targeted builds are coming soon where more APIs could be detected

API Comment Suggestion Location
'SecurityContext.Capture()' throws unconditionally All APIs throws [Obsolete] the type libraries\System.Security.Permissions\src\System\Security\SecurityContext.cs(11,51)
'SecurityContext.CreateCopy()' throws unconditionally [Obsolete] the type libraries\System.Security.Permissions\src\System\Security\SecurityContext.cs(12,47)
'SecurityContext.Dispose()' throws unconditionally [Obsolete] the type libraries\System.Security.Permissions\src\System\Security\SecurityContext.cs(13,33)
'SecurityContext.IsFlowSuppressed()' throws unconditionally [Obsolete] the type libraries\System.Security.Permissions\src\System\Security\SecurityContext.cs(14,49)
'SecurityContext.IsWindowsIdentityFlowSuppressed()' throws unconditionally [Obsolete] the type libraries\System.Security.Permissions\src\System\Security\SecurityContext.cs(15,64)
'SecurityContext.RestoreFlow()' throws unconditionally [Obsolete] the type libraries\System.Security.Permissions\src\System\Security\SecurityContext.cs(16,44)
'SecurityContext.Run(SecurityContext, ContextCallback, object)' throws unconditionally [Obsolete] the type libraries\System.Security.Permissions\src\System\Security\SecurityContext.cs(17,107)
'SecurityContext.SuppressFlow()' throws unconditionally [Obsolete] the type libraries\System.Security.Permissions\src\System\Security\SecurityContext.cs(18,57)
'SecurityContext.SuppressFlowWindowsIdentity()' throws unconditionally [Obsolete] entire type libraries\System.Security.Permissions\src\System\Security\SecurityContext.cs(19,72)

EDIT: Adding APIs found for netstandard targeted builds

API Comment Suggestion Location
'ECDiffieHellmanCng.FromXmlString(string, ECKeyXmlFormat)' Uncondidionally throws obsolete libraries\System.Security.Cryptography.Cng\src\System\Security\Cryptography\ECDiffieHellmanCng.Xml.cs(10,13)
'ECDiffieHellmanCng.ToXmlString(ECKeyXmlFormat)' Uncondidionally throws obsolete libraries\System.Security.Cryptography.Cng\src\System\Security\Cryptography\ECDiffieHellmanCng.Xml.cs(15,13)
'ECDiffieHellmanCngPublicKey.ToXmlString()' Uncondidionally throws obsolete libraries\System.Security.Cryptography.Cng\src\System\Security\Cryptography\ECDiffieHellmanCngPublicKey.cs(37,13)
'ECDiffieHellmanCngPublicKey.FromXmlString(string)' Uncondidionally throws obsolete libraries\System.Security.Cryptography.Cng\src\System\Security\Cryptography\ECDiffieHellmanCngPublicKey.cs(42,13)
'ECDsaCng.FromXmlString(string, ECKeyXmlFormat)' Uncondidionally throws obsolete libraries\System.Security.Cryptography.Cng\src\System\Security\Cryptography\ECDsaCng.cs(131,16)
'ECDsaCng.ToXmlString(ECKeyXmlFormat)' Uncondidionally throws obsolete libraries\System.Security.Cryptography.Cng\src\System\Security\Cryptography\ECDsaCng.cs(143,16)
'ECDiffieHellmanOpenSslPublicKey.ToXmlString()' Internal API, unconditionally throwing obsolet if referenced in public API libraries\Common\src\System\Security\Cryptography\ECDiffieHellmanOpenSslPublicKey.cs(42,17)
'ECDiffieHellmanOpenSslPublicKey.ToByteArray()' Internal API, unconditionally throwing obsolete if referenced in public API libraries\Common\src\System\Security\Cryptography\ECDiffieHellmanOpenSslPublicKey.cs(47,17)
'CmsSigner.CmsSigner(CspParameters)' It has comment possibly adding windows support but no issue attached, obsolete libraries\System.Security.Cryptography.Pkcs\src\System\Security\Cryptography\Pkcs\CmsSigner.cs(63,55)
'SignerInfo.ComputeCounterSignature()' Uncondidionally throws obsolete libraries\System.Security.Cryptography.Pkcs\src\System\Security\Cryptography\Pkcs\SignerInfo.cs(296,13)
'PermissionSet.PermitOnly()' Uncondidionally throws it has ifdef-ed obsolete libraries\System.Private.CoreLib\src\System\Security\PermissionSet.cs(43,36)
'CodeAccessPermission.PermitOnly()' Uncondidionally throws it has ifdef-ed obsolete libraries\System.Security.Permissions\src\System\Security\CodeAccessPermission.cs(22,36)

Note: We are suggesting to add [Obsolete] for the APIs only supported in .Net framework but not supported in .NetCore, with the corresponding Message, DiagnosticId, and UrlFormat

[Obsolete(Obsoletions.AuthenticationManagerMessage, DiagnosticId = Obsoletions.AuthenticationManagerDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
You can claim the next available DiagnosticId from Obsoletions.cs .

If it is only supported on a specific platform(s) consider adding [SupportedOSPlatform("platformName")] or if it is unsupported on a specific platform(s) [UnsupportedOSPlatform("platformName")] attribute instead

cc @jeffhandley @terrajobst @GrabYourPitchforks

@buyaa-n buyaa-n added this to the 6.0.0 milestone Mar 31, 2021
@ghost
Copy link

ghost commented Mar 31, 2021

Tagging subscribers to this area: @bartonjs, @vcsjones, @krwq, @GrabYourPitchforks
See info in area-owners.md if you want to be subscribed.

Issue Details

As part of #47228 i am running an analyzer to detect APIs throwing PNSE but not annotated with Obsolete/SupportedOSPlatform/UnsupportedOSPlatform attributes, we need to annotate them so that developers get warnings when they use them unexpectedly

For now, I have results only cross-platform and .Net 5.0 or higher builds, analysis of targeted builds or lower env are coming soon where more APIs could be detected

API Comment Suggestion Location
'CryptoConfigForwarder.CreateDefaultHashAlgorithm()' unconditionally throws on all platforms add [Obsolete] libraries\System.Security.Cryptography.Primitives\src\System\Security\Cryptography\CryptoConfigForwarder.cs(41,13)
'HMAC.HashName.set' Checking non platform related condition Consider changing the exception to NotSupportedException libraries\System.Security.Cryptography.Primitives\src\System\Security\Cryptography\HMAC.cs(48,21)
'HMAC.HashCore(byte[], int, int)' unconditionally throws add [Obsolete] libraries\System.Security.Cryptography.Primitives\src\System\Security\Cryptography\HMAC.cs(65,13)
'HMAC.HashCore(ReadOnlySpan)' unconditionally throws add [Obsolete] libraries\System.Security.Cryptography.Primitives\src\System\Security\Cryptography\HMAC.cs(68,13)
'HMAC.HashFinal()' unconditionally throws add [Obsolete] libraries\System.Security.Cryptography.Primitives\src\System\Security\Cryptography\HMAC.cs(71,13)
'HMAC.TryHashFinal(Span, out int)' unconditionally throws add [Obsolete] libraries\System.Security.Cryptography.Primitives\src\System\Security\Cryptography\HMAC.cs(74,13)
'HMAC.Initialize()' unconditionally throws add [Obsolete] libraries\System.Security.Cryptography.Primitives\src\System\Security\Cryptography\HMAC.cs(77,13)
'SecurityContext.Capture()' Entire class throws unconditionally, might add Obsolete for the class add [Obsolete] libraries\System.Security.Permissions\src\System\Security\SecurityContext.cs(11,51)
'SecurityContext.CreateCopy()' Entire class throws unconditionally, might add Obsolete for the class add [Obsolete] libraries\System.Security.Permissions\src\System\Security\SecurityContext.cs(12,47)
'SecurityContext.Dispose()' Entire class throws unconditionally, might add Obsolete for the class add [Obsolete] libraries\System.Security.Permissions\src\System\Security\SecurityContext.cs(13,33)
'SecurityContext.IsFlowSuppressed()' Entire class throws unconditionally, might add Obsolete for the class add [Obsolete] libraries\System.Security.Permissions\src\System\Security\SecurityContext.cs(14,49)
'SecurityContext.IsWindowsIdentityFlowSuppressed()' Entire class throws unconditionally, might add Obsolete for the class add [Obsolete] libraries\System.Security.Permissions\src\System\Security\SecurityContext.cs(15,64)
'SecurityContext.RestoreFlow()' Entire class throws unconditionally, might add Obsolete for the class add [Obsolete] libraries\System.Security.Permissions\src\System\Security\SecurityContext.cs(16,44)
'SecurityContext.Run(SecurityContext, ContextCallback, object)' Entire class throws unconditionally, might add Obsolete for the class add [Obsolete] libraries\System.Security.Permissions\src\System\Security\SecurityContext.cs(17,107)
'SecurityContext.SuppressFlow()' Entire class throws unconditionally, might add Obsolete for the class add [Obsolete] libraries\System.Security.Permissions\src\System\Security\SecurityContext.cs(18,57)
'SecurityContext.SuppressFlowWindowsIdentity()' Entire class throws unconditionally, might add Obsolete for the class add [Obsolete] libraries\System.Security.Permissions\src\System\Security\SecurityContext.cs(19,72)

Note: We are suggesting to add [Obsolete] with the corresponding message for APIs supported in .Net framework but not supported in .NetCore, if it is only supported on a specific platform(s) consider adding [SupportedOSPlatform("platformName")] or if it is unsupported on a specific platform(s) [UnsupportedOSPlatform("platformName")] attribute instead

Suggestions for changing the exception is optional

cc @jeffhandley @terrajobst @GrabYourPitchforks

Author: buyaa-n
Assignees: -
Labels:

area-System.Security

Milestone: 6.0.0

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Mar 31, 2021
@buyaa-n
Copy link
Member Author

buyaa-n commented Apr 6, 2021

Notes need to consider:

  • If the API has an issue associated with future support we are not suggesting to add [Obsolete], we need to make sure that we are not gonna support the API ever and related issue should be closed, then we can add [Obsolete]
  • If the API is internal/private the annotation is not necessary, but they could point you to the public API needs annotation

@marek-safar marek-safar removed the untriaged New issue has not been triaged by the area owner label Apr 20, 2021
@vcsjones
Copy link
Member

vcsjones commented Jul 6, 2021

Some of these APIs that "unconditionally throw" are virtual and are expected to be overridden in derived classes, so while the base class throws, they aren't necessarily obsolete because derived classes override them and some functionality depend on these classes. I think this would be the case for all of the methods on the HMAC class. So I do not think those should be obsolete or otherwise annotated.

@buyaa-n
Copy link
Member Author

buyaa-n commented Jul 21, 2021

I think this would be the case for all of the methods on the HMAC class. So I do not think those should be obsolete or otherwise annotated.

That is right, removed HMAC related APIs, but others looks valid

@buyaa-n
Copy link
Member Author

buyaa-n commented Jul 22, 2021

Adding few more:

API Comment Suggestion Location
'ECDsa.ECDsaImplementation.ECDsaSecurity Transforms.ExportExplicitParameters(bool)' unconditionally throwing, reachable on iOS, tvOS, OSX unreachable: browser UnsupportedOSPlatform("iOS"), UnsupportedOSPlatform("tvOS"), UnsupportedOSPlatform("tOSX") \libraries\Common\src\System\Security\ Cryptography\ECDsaSecurityTransforms.cs(209,21)
'Rfc2898DeriveBytes.CryptDeriveKey(string, string, int, byte[])' unconditionally throwing reachable on Android, Unix, iOS, tvOs, OSX, Windows unreachable: browser Only implemented for PasswordDeriveBytes and has SupportedOSPlatform("windows") attribute, should we obsolete or also add SupportedOSPlatform("windows") libraries\System.Security.Cryptography.Algorithms\src \System.Security.Cryptography.Algorithms.csproj]

CC @bartonjs

@vcsjones
Copy link
Member

DSA.CreateCore()

The public entry, Create is already marked with UnsupportedOSPlatform:

So I think that one is already taken care of.

@buyaa-n
Copy link
Member Author

buyaa-n commented Jul 23, 2021

Removed, thanks

@vcsjones
Copy link
Member

vcsjones commented Aug 4, 2021

@buyaa-n is this something you are working on or is this something I can contribute to? Some of these look reasonable.

@buyaa-n
Copy link
Member Author

buyaa-n commented Aug 4, 2021

@buyaa-n is this something you are working on

Not really, my intent here (and all other issues i filed) was to detect the PNSE and let the area owners know because some of the findings might be invalid or need more investigation. For now, I resolved this only for the areas I own, but if the security area owners are OK with the proposed change then i can go ahead and do updates

or is this something I can contribute to? Some of these look reasonable.

Sure, that would be great, thanks!

@vcsjones
Copy link
Member

vcsjones commented Aug 5, 2021

'ECDsa.ECDsaImplementation.ECDsaSecurity Transforms.ExportExplicitParameters(bool)'

I'm not sure adding an UnsupportedOSPlatform here would be ergonomic. The issue is that the public API ExportExplicitParameters is accessible via the virtual ECDsa.ExportExplicitParameters. We would have to decorate the virtual with the UOSP attribute, which would not interact well with derived classes (our own or developers' own). To illustrate:

using System.Runtime.Versioning;

Foo f = new Bar();
f.Do(); // This is actually a `Bar` but since it's called through the base type, a compiler warning appears.

public class Foo
{
    [UnsupportedOSPlatform("iOS")]
    public virtual object Do() => throw new PlatformNotSupportedException();
}

public class Bar : Foo
{
    public override object Do() => new();
}

Similar concerns lie with ToXmlString, FromXmlString, and ToByteArray. It seems a little odd to obsolete an override when a user derived type could override one of these from the base class and implement it.

Some of these do make sense to me to obsolete:

  1. Rfc2898DeriveBytes.CryptDeriveKey - it's unimplemented and can't be implemented xplat since it's a Windows thing. I'm unaware of demand to bring it back.
  2. CmsSigner.CmsSigner(CspParameters) seems weird. It manufactures a certificate on the fly based on those CspParameters. It makes sense to obsolete since it can only be implemented on Windows. If we really, really wanted "make me a cert on the fly" behavior, it probably makes sense to implement a new API that accepted an AsymmetricAlgorithm or something.
  3. SignerInfo.ComputeCounterSignature() There's an overload that accepts the CmsSigner, so I think it makes sense to obsolete.

I don't see any immediately actionable things for 6.0. Presumably the obsoletions need to go through API review, and I don't know if we're taking any more obsoletions for 6.0 (granted all of them throw, so it's not exactly a breaking change).

@jeffhandley
Copy link
Member

We could take these 3 obsoletions without going through API Review--just code review from @bartonjs and @GrabYourPitchforks. I'm comfortable taking them before the August 17th cutoff for .NET 6, especially since it's not a breaking change.

@buyaa-n buyaa-n changed the title Annotate unsupported APIs in System.Security Annotate unsupported APIs in System.Security.* Aug 9, 2021
@buyaa-n
Copy link
Member Author

buyaa-n commented Aug 9, 2021

Adding last findings, these are all internal APIs / overrides in the different platform source PALs, might be false positive but might worth checking

API Comment Reachable platforms Location
'EccSecurityTransforms.ExtractPublicKeyFromPrivateKey(ref ECParameters)' unconditionally throws PNSE reachable on iOS, tvOS Common\src\System\Security\Cryptography\EccSecurityTransforms.iOS.cs(19,16)
'EccSecurityTransforms.ExtractPublicKeyFromPrivateKey(ref ECParameters)' unconditionally throws PNSE reachable on iOS, tvOS Common\src\System\Security\Cryptography\EccSecurityTransforms.iOS.cs(19,16)
'RC2Implementation.CreateTransformCore(CipherMode, PaddingMode, byte[], int, byte[]?, int, int, int, bool)' unconditionally throws PNSE reachable on Android System.Security.Cryptography.Algorithms\src\Internal\Cryptography\RC2Implementation.Android.cs(23,13)
'AppleCertificatePal.FriendlyName.set' unconditionally throws PNSE reachable on iOS, OSX, tvOS System.Security.Cryptography.X509Certificates\src\Internal\Cryptography\Pal.OSX\AppleCertificatePal.cs(198,17)
'AppleCertificatePal.Archived.set' unconditionally throws PNSE reachable on iOS, OSX, tvOS System.Security.Cryptography.X509Certificates\src\Internal\Cryptography\Pal.OSX\AppleCertificatePal.cs(313,17)
'OpenSslX509CertificateReader.Archived.set' unconditionally throws PNSE reachable on Unix System.Security.Cryptography.X509Certificates\src\Internal\Cryptography\Pal.Unix\OpenSslX509CertificateReader.cs(405,17)
'OpenSslX509CertificateReader.FriendlyName.set' unconditionally throws PNSE reachable on Unix System.Security.Cryptography.X509Certificates\src\Internal\Cryptography\Pal.Unix\OpenSslX509CertificateReader.cs(415,17)
'AndroidCertificatePal.Archived.set' unconditionally throws PNSE reachable on Android System.Security.Cryptography.X509Certificates\src\Internal\Cryptography\Pal.Android\AndroidCertificatePal.cs(262,17)
'AndroidCertificatePal.FriendlyName.set' unconditionally throws PNSE reachable on Android System.Security.Cryptography.X509Certificates\src\Internal\Cryptography\Pal.Android\AndroidCertificatePal.cs(272,17)
'AppleCertificatePal.CopyWithPrivateKey(DSA)' unconditionally throws PNSE reachable on iOS, tvOS System.Security.Cryptography.X509Certificates\src\Internal\Cryptography\Pal.iOS\AppleCertificatePal.Keys.cs(21,13)

@vcsjones
Copy link
Member

vcsjones commented Aug 10, 2021

It does look like we can annotate RC2 to indicate that it is not supported on Android. I think we could annotate RC2.Create() for Android like we did for DSA for iOS.

@vcsjones
Copy link
Member

vcsjones commented Aug 10, 2021

Adding last findings

Just to summarize findings that I think are actionable:

It would still be useful to have someone else validate this.

@bartonjs
Copy link
Member

  • Rfc2898DeriveBytes.CryptDeriveKey obsolete
    • Agreed
  • System.Security.SecurityContext obsolete
    • Agreed (merged!)
  • CmsSigner.CmsSigner(CspParameters) obsolete
    • Agreed (double checked that we didn't make it work on Windows)
  • SignerInfo.ComputeCounterSignature() obsolete
    • Agreed (double checked that we didn't make it work on Windows)
  • RC2.Create() see below

For RC2-browser we seem to have marked the whole type, which was probably a bit of an overreach, because someone /could/ provide a working implementation of RC2. RC2.Create() on android I'm pretty sure succeeds, but returns an object that fails if you try to actually use it. Part of me thinks it'd be better to just put the PNSE there, but maybe there's a legit use case I can think of for the dummy RC2 instance.

So... yeah, marking RC2.Create as Unsupported-android is probably right. With a comment that says a more formal version of "yeah, it returns, but the object is going to throw if you call CreateEncryptor or CreateDecryptor... so it's the same as not working"

As for other things in @buyaa-n 's tables:

  • ECDiffieHellmanCng.ToXmlString/FromXmlString
    • Obsolete.
    • We never added them in Core, no one ever complained (to my recollection). The base class version literally never worked (even in NetFX when it was added), and the derived type is Windows-only.
  • ECDiffieHellmanCngPublicKey.ToXmlString/FromXmlString
    • Obsolete (same as above, probably same diagnostic ID)
  • ECDsaCng.ToXmlString/FromXmlString
    • Obsolete (same as above, probably same diagnostic ID)
  • ECDiffieHellmanPublicKey.ToXmlString
    • Obsolete
    • We've never had a derived type in Core that didn't throw. Let's just obsolete the base type's version. Maybe the same diagnostic ID as above.
    • Wasn't directly on the table, but addresses the ECDiffieHellmanOpenSslPublicKey case 😄

I think that only leaves ECDiffieHellmanPublicKey.ToByteArray and ECDiffieHellmanPublicKey..ctor(byte[]). I'd support Obsoleting these. I... thought... we had added SPKI export on this type, but I don't see it. So maybe we need to hold this one back one release. Using inbox types the ToByteArray only works on Windows, but since it's a virtual I don't like putting a SupportedOSAttribute on it.

@vcsjones
Copy link
Member

I... thought... we had added SPKI export on this type, but I don't see it.

We did, unless I am misunderstanding what API you're thinking of.

public virtual bool TryExportSubjectPublicKeyInfo(Span<byte> destination, out int bytesWritten)

@vcsjones
Copy link
Member

I'll tackle the rest of these over the next day or two.

@bartonjs
Copy link
Member

No, that's it. Just that I wasn't smart enough to remember to look in a partial file.

@vcsjones
Copy link
Member

vcsjones commented Aug 12, 2021

ECDiffieHellmanPublicKey.ToXmlString

Just so I am super clear, we are okay obsoleting a virtual on an abstract class that developers can inherit from for a RC? Or would it be better to push those for .NET vNext?

@bartonjs
Copy link
Member

Just so I am super clear, we are okay obsoleting a virtual on an abstract class that developers can inherit from for a RC? Or would it be better to push those for .NET vNext?

I am. @ericstj or @danmoseley would you care to object?

If there are more than three NuGet packages that have extended ECDiffieHellmanPublicKey I'll... I don't know... be flabbergasted. ("MC an API Review while only speaking French" (a language I don't know) sounds like a fun consequence, but would be incredibly unproductive). Even then, I doubt they'd've implemented To/FromByteArray in a way that interoperated with the inbox CNG one. Since https://github.com/novotnyllc/RSAKeyVaultProvider/tree/master/RSAKeyVaultProvider didn't do ECDH I'll even lower that expectation to two derived types.

@vcsjones
Copy link
Member

If there are more than three NuGet packages that have extended ECDiffieHellmanPublicKey I'll... I don't know... be flabbergasted. "MC an API Review while only speaking French" (a language I don't know)

I need to figure out how to publish a few NuGet packages, then.

Fair enough, just thought I'd ask. Will do those next then.

@bartonjs
Copy link
Member

I need to figure out how to publish a few NuGet packages, then.

Had there been an actual "eat my hat" type consequence I definitely would have thrown in a disclaimer like "(offer valid only for non-prerelease packages already present on nuget.org at the original time of this post)". I may not be smart enough to remember to look in partial files, but I'm not that naive 😄.

@danmoseley
Copy link
Member

@marklio is this an assumption we can easily verify from Nuget packages?

@marklio
Copy link

marklio commented Aug 12, 2021

I can look at this. I'll follow up with @bartonjs offline.

@marklio
Copy link

marklio commented Aug 12, 2021

OK, the landscape here is complicated, but in general it looks like @bartonjs's wager holds up, particularly through the lens of "ecosystem code exposed to such a change". I definitely found types that inherit from System.Security.Cryptography.ECDiffieHellmanPublicKey, but almost universally these are types in our own shipped assemblies (System.Core, System.Security.Cng/Algorithms/OpenSsl). These assemblies are in our own packages, as well as redistributed in other packages at a pretty high rate. None of those really represent problematic scenarios WRT deprecation. The few that were genuinely non-product types are in assemblies that are not published on NuGet.org, and instead come from other locations like internal test trees/tools.

@bartonjs
Copy link
Member

"Bonjour les amis. Nous sommes mardi et environ 10h à Redmond, il est donc temps de passer en revue l'API. Vous avez peut-être remarqué que je parle en français aujourd'hui. Non, je ne parle pas français, mais je peux lire des choses sur Google Translate dans ce que je pense ressemble à du français, et c'est loin d'être la bonne réponse mais le mieux que je puisse faire. Pourquoi? J'ai fait un mauvais pari sur Internet."

Yeah, I knew it. Obscure type, no clear implementation. No derivers. Obvs.

Thanks, @marklio 😄.

@vcsjones
Copy link
Member

vcsjones commented Aug 23, 2021

@bartonjs I was not able to get to the rest of these before the 6.0 branch was taken. Should this be moved to 7.0.0 or should I prioritize this so that it can get ported to the 6.0 branch (not sure that's even wise / a possibility)?

@bartonjs
Copy link
Member

Ah, yes. I'm guessing the answer will be move to 7 at this point. But if @danmoseley is happy to take another couple of obsoletions then I'd personally be happier to see them knocked out sooner.

@jeffhandley
Copy link
Member

Based on "Obscure type, no clear implementation. No derivers." I would be comfortable porting these into release/6.0-rc1 if @danmoseley is. We would need tactics approval.

Or we could take them in RC2 with just Dan's approval.

7.0 also wouldn't upset me.

@jeffhandley jeffhandley modified the milestones: 6.0.0, 7.0.0 Sep 4, 2021
@jeffhandley
Copy link
Member

Moved to 7.0.0.

@vcsjones
Copy link
Member

@bartonjs

I think that only leaves ECDiffieHellmanPublicKey.ToByteArray and ECDiffieHellmanPublicKey..ctor(byte[]). I'd support Obsoleting these. I... thought... we had added SPKI export on this type, but I don't see it

I didn't quite take this as an affirmative "let's obsolete these". Do we want to obsolete ECDiffieHellmanPublicKey.ToByteArray and ECDiffieHellmanPublicKey..ctor(byte[])?

@bartonjs
Copy link
Member

Do we want to obsolete ECDiffieHellmanPublicKey.ToByteArray and ECDiffieHellmanPublicKey..ctor(byte[])?

Yes, please. The method is easy:

[Obsolete("ECDiffieHellmanPublicKey.ToByteArray() does not have a consistent and interoperable implementation on all platforms. Use ECDiffieHellmanPublicKey.ExportSubjectPublicKeyInfo() instead.", ...)]

The constructor is... harder? The best message I've come up with is "The bytes-based constructor for ECDiffieHellmanPublicKey does not have an associated standard data format. This constructor only provides the bytes to the default implementation of the obsolete ToByteArray method, and is not necessary to call from a derived type."

But that's clunky and awkward. So maybe that one is better as a docs-remark instead of an Obsolete.

@vcsjones
Copy link
Member

The constructor is... harder?

Yeah. But then it feels weird to have a constructor that takes the key blob and no not-obsolete way to do anything with it.

Since it's a protected constructor on a class that no one is deriving from I would wager we could take a swing at obsoleting it with less than perfect wording.

@bartonjs
Copy link
Member

"ECDiffieHellmanPublicKey.ToByteArray() and the associated constructor do not..." might work?

@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Mar 28, 2022
@vcsjones
Copy link
Member

@bartonjs What do you think about obsoleting ECKeyXmlFormat? It's only used on obsolete methods now, only had one enum value, etc.

@bartonjs
Copy link
Member

I'm not really a fan of obsoleting types, as that makes every member declaration that uses it have to suppress the obsoletion. I think we just ignore it.

@terrajobst
Copy link
Member

That’s why we added the diagnostic ID. This way, you can add a global supression that’s still targeted. Existing code would do that, new code wouldn’t use it. Not sure that’s justified here though.

@vcsjones
Copy link
Member

as that makes every member declaration that uses it have to suppress the obsoletion.

I would imagine it would get obsolete under SYSLIB0042, if it were pursued.

I don't know if there is telemetry on this, but I would be surprised if developers were using ECKeyXmlFormat as a parameter type, especially since it never contained anything more than one enum value.

For dotnet/runtime members, it would only be half a dozen or so suppression I suspect, which seems manageable.

From my own searching on GitHub, I didn't see a single use of ECKeyXmlFormat that was not a fork of the runtime, or calling To/FromXmlString (which is going to hit the diagnostic anyway).

@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Mar 30, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Apr 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants