-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Description
Description
The ECDiffieHellmanPublicKey.ToByteArray() method does not have an implied file format, and for the built-in implementations it throws PlatformNotSupportedException on all non-Windows Operating Systems. Since ECDiffieHellmanPublicKey also has a standard format export (via the ExportSubjectPublicKeyInfo() method) we have declared the older member obsolete.
Version
.NET 7 Preview 4
Previous behavior
Calling ECDiffieHellmanPublicKey.ToByteArray() or the protected ECDiffieHellmanPublicKey(byte[]) constructor would not produce a warning.
New behavior
Calling ECDiffieHellmanPublicKey.ToByteArray() or the protected ECDiffieHellmanPublicKey(byte[]) constructor produces warning SYSLIB0043.
Type of breaking change
- Binary incompatible: Existing binaries may encounter a breaking change in behavior, such as failure to load/execute or different run-time behavior.
- Source incompatible: Source code may encounter a breaking change in behavior when targeting the new runtime/component/SDK, such as compile errors or different run-time behavior.
Reason for change
The method was not supported on all operating systems that .NET supports and on the ones it does support the data format was not a standard format.
Recommended action
For callers exporting the public key value, use the ExportSubjectPublicKeyInfo() method.
For existing derived types that already call the protected ECDiffieHellmanPublicKey(byte[]) constructor, continue calling the constructor and suppress the SYSLIB0043 warning.
For new derived types (or existing derived types that do not currently call the byte[]-based constructor) skip calling the protected ECDiffieHellmanPublicKey(byte[]) constructor, and either override ToByteArray() to throw an exception, or accept the default behavior of returning an empty array.
Feature area
Cryptography
Affected APIs
M:System.Security.Cryptography.ECDiffieHellmanPublicKey.#ctor(System.Byte[])
M:System.Security.Cryptography.ECDiffieHellmanPublicKey.ToByteArray()