-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Span<byte> on ICryptoTransform #38764
Comments
cc @GrabYourPitchforks since I think you had thoughts on this. |
In general I like this concept. @terrajobst and @bartonjs might have thoughts on the use of DIMs, but this seems like a straightforward enough application. The |
I hadn't given the implementation of the DIM too much thought, but you're right - it seems that likely the best solution then is for it to throw. Though if we have to throw for Another option is to just get rid of the I had also forgotten that the abstract |
Another option would be to introduce a new interface and not give the methods default implementations. Then if you want spanny APIs you'd cast to the new interface. The built in ICryptoTransform-implementing types could implement both interfaces implicitly to make things more convenient for callers. |
Duplicate of #27118. Since it requires the use of DIMs, it's going to be "no" for a long time. An entirely new approach, not modifying the current interface, is much likely a better plan (such as the new oneshot methods, which can be use virtuals to call ICryptoTransform or overridden in the real implementations to ignore all of the middle management. |
Is there ever a world in which the runtime repo can ship an interface with a default implementation? I feel this keeps coming up with some regularity. Perhaps it's time to doc that such a thing is not feasible within the runtime repo. |
Something net new introduced for net5+-only... perhaps. Modifying an existing interface? Probably not for several years, we need to understand what goes wrong with it before we're comfortable accepting whatever risk we understand at the time. The unacceptable breaking changes list includes modifying an interface, that still stands for the shared framework, even with DIMs now part of the runtime. |
It should be possible to pass an empty |
Background and Motivation
The current APIs on
ICryptoTransform
arebyte[]
based, and accept an offset and length. This pattern is better represented as aSpan<byte>
today, as developers are more familiar with Span and expect these APIs where the previous pattern was used.For
TransformFinalBlock
, a byte array is returned, which forces the implementation to allocate on return. TheSpan
based implementations could allow transformation in to an existing buffer, or in-place.Proposed API
Risks
This would require the use of DIM, which to my knowledge hasn't been used in any significant capacity within the core libraries.
The DIM implementation would either need to throw something like
NotSupported_SubclassOverride
, or, provide a default implementation where theSpan
overloads defer back to thebyte
overloads. For implementations that end up using the DIM, the performance characteristics would be counter-intuitive. TheSpan
s would need to allocate arrays to use the existing implementations, where the caller might have forced theSpan
overloads to be called since there is some reason for folks to believe that Span = Better.The text was updated successfully, but these errors were encountered: