Avoid infinite recursion in RSAEncryptionPadding equality check
authorAndrew Au <andrewau@microsoft.com>
Thu, 21 Nov 2019 20:08:07 +0000 (12:08 -0800)
committerAndrew Au <andrewau@microsoft.com>
Thu, 21 Nov 2019 20:08:07 +0000 (12:08 -0800)
src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/RSAEncryptionPadding.cs
src/libraries/System.Security.Cryptography.Algorithms/tests/RSATests.cs

index e34594d..422cad8 100644 (file)
@@ -100,7 +100,7 @@ namespace System.Security.Cryptography
 
         public bool Equals(RSAEncryptionPadding other)
         {
-            return other != null
+            return !object.ReferenceEquals(other, null)
                 && _mode == other._mode
                 && _oaepHashAlgorithm == other._oaepHashAlgorithm;
         }
index 1ed4a4f..782415a 100644 (file)
@@ -192,6 +192,12 @@ namespace System.Security.Cryptography.Algorithms.Tests
             Assert.True(rsa.VerifyData(new MemoryStream(new byte[] { 42 }), new byte[1] { 24 }, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1));
         }
 
+        [Fact]
+        public void RSAEncryptionPadding_Equals()
+        {
+            Assert.Equal(RSAEncryptionPadding.Pkcs1, RSAEncryptionPadding.Pkcs1);
+        }
+
         private sealed class EmptyRSA : RSA
         {
             public override RSAParameters ExportParameters(bool includePrivateParameters) => throw new NotImplementedException();