Description
RSAOpenSsl Equals returns false when comparing an instance with itself when running on Linux in a net8.0 project.
Reproduction Steps
var rsa = RSA.Create(); // creates a RSAOpenSsl in Linux
var result = rsa.Equals(rsa);
Expected behavior
The value of result is true.
Actual behavior
The value of result is false.
Regression?
Don't know.
Known Workarounds
If using data structures for storing RSA objects that use EqualityComparer under the hood (such as ConcurrentDictionary<TKey, RSA>), an adapter class implementing IEquatable can be used to wrap the RSA so the equality checks within the data structure can behave as expected.
Configuration
Other information
This was found when trying to use ConcurrentDictionary<TKey, RSA>::AddOrUpdate. The Update path in this code uses an equality check using the old value that is expected to eventually succeed. The bug causes this to never succeed, so the thread gets stuck inside an infinite while loop that keeps retrying the underlying Update and never succeeds.