You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Today all buffer related operations in both the high level and the low level APIs use arrays. When one must deal with external buffer slices this becomes inefficient and error prone since temporary arrays need to be allocated and content must be copied back and forth.
For example consider implementing the ICryptoTransform.TransformBlock method:
If the inputOffset parameter is non-zero, temporary array must be allocated and inputCount bytes must be copied from it before it can be passed to C_EncryptUpdate method. If a new overload would be added to Pkcs11Library supporting the Span
public CKR C_EncryptUpdate(NativeULongsession,ReadOnlySpan<byte>part,Span<byte>encryptedPart,refNativeULongencryptedPartLen);
the unnecessary allocation could be eliminated and the call would be simplified to
Yes, Span utilization would be a great addition but as you already mentioned it would limit supported platforms. Maybe it will land in Pkcs11Interop 6 along with #160 and #161. We'll see.
Today all buffer related operations in both the high level and the low level APIs use arrays. When one must deal with external buffer slices this becomes inefficient and error prone since temporary arrays need to be allocated and content must be copied back and forth.
For example consider implementing the
ICryptoTransform.TransformBlock
method:If the
inputOffset
parameter is non-zero, temporary array must be allocated andinputCount
bytes must be copied from it before it can be passed toC_EncryptUpdate
method. If a new overload would be added toPkcs11Library
supporting theSpan
the unnecessary allocation could be eliminated and the call would be simplified to
The downside of this is the
Span
could be only supported for net45 and netstandard2.0 builds through the System.Memory package.The text was updated successfully, but these errors were encountered: