public void TestNotSupportedException()
        {
            var supported = new HashSet <DigestAlgorithm> ();

            foreach (var field in typeof(RsaEncryptionPadding).GetFields(BindingFlags.Public | BindingFlags.Static))
            {
                if (field.FieldType != typeof(RsaEncryptionPadding))
                {
                    continue;
                }

                var padding = (RsaEncryptionPadding)field.GetValue(null);

                if (padding.Scheme == RsaEncryptionPaddingScheme.Oaep)
                {
                    supported.Add(padding.OaepHashAlgorithm);
                }
            }

            foreach (DigestAlgorithm hashAlgorithm in Enum.GetValues(typeof(DigestAlgorithm)))
            {
                if (!supported.Contains(hashAlgorithm))
                {
                    Assert.Throws <NotSupportedException> (() => RsaEncryptionPadding.CreateOaep(hashAlgorithm));
                }
                else
                {
                    Assert.DoesNotThrow(() => RsaEncryptionPadding.CreateOaep(hashAlgorithm));
                }
            }
        }
        static void AssertOaepAlgorithmIdentifier(RsaEncryptionPadding padding, DerObjectIdentifier hashAlgorithm)
        {
            var name = $"Oaep{padding.Scheme}";

            var algorithm = padding.GetAlgorithmIdentifier();

            Assert.IsNotNull(algorithm, $"{name} != null");
            Assert.AreEqual(PkcsObjectIdentifiers.IdRsaesOaep, algorithm.Algorithm, $"{name}.Algorithm == RSAES-OAEP");
            var parameters = (RsaesOaepParameters)algorithm.Parameters;

            Assert.AreEqual(hashAlgorithm, parameters.HashAlgorithm.Algorithm, $"{name}.HashAlgorithm == {padding.OaepHashAlgorithm}");
            Assert.AreEqual(PkcsObjectIdentifiers.IdMgf1, parameters.MaskGenAlgorithm.Algorithm, $"{name}.MaskGenAlgorithm == MGF1");
            var mgf1hash = (AlgorithmIdentifier)parameters.MaskGenAlgorithm.Parameters;

            Assert.AreEqual(hashAlgorithm, mgf1hash.Algorithm, $"{name}.MaskGenHashAlgorithm == {padding.OaepHashAlgorithm}");
        }
        public void TestEquality()
        {
            Assert.AreEqual(RsaEncryptionPadding.OaepSha1, RsaEncryptionPadding.CreateOaep(DigestAlgorithm.Sha1), "CreateOaep(SHA-1)");
            Assert.AreEqual(RsaEncryptionPadding.OaepSha256, RsaEncryptionPadding.CreateOaep(DigestAlgorithm.Sha256), "CreateOaep(SHA-256)");
            Assert.AreEqual(RsaEncryptionPadding.OaepSha384, RsaEncryptionPadding.CreateOaep(DigestAlgorithm.Sha384), "CreateOaep(SHA-384)");
            Assert.AreEqual(RsaEncryptionPadding.OaepSha512, RsaEncryptionPadding.CreateOaep(DigestAlgorithm.Sha512), "CreateOaep(SHA-512)");

            Assert.AreNotEqual(RsaEncryptionPadding.Pkcs1, RsaEncryptionPadding.OaepSha1, "PKCS1 !Equals SHA-1");
            Assert.AreNotEqual(RsaEncryptionPadding.Pkcs1, RsaEncryptionPadding.OaepSha256, "PKCS1 !Equals SHA-256");
            Assert.AreNotEqual(RsaEncryptionPadding.OaepSha1, RsaEncryptionPadding.OaepSha256, "SHA-1 !Equals SHA-256");

            Assert.AreNotEqual(RsaEncryptionPadding.Pkcs1, new object(), "PKCS1 !Equals object");

            Assert.IsTrue(RsaEncryptionPadding.OaepSha1 == RsaEncryptionPadding.CreateOaep(DigestAlgorithm.Sha1), "SHA-1 == SHA-1");
            Assert.IsFalse(RsaEncryptionPadding.OaepSha1 == RsaEncryptionPadding.OaepSha256, "SHA-1 == SHA-256");
            Assert.IsFalse(RsaEncryptionPadding.OaepSha1 == null, "SHA-1 == null");
            Assert.IsFalse(null == RsaEncryptionPadding.OaepSha1, "null == SHA-1");

            Assert.IsFalse(RsaEncryptionPadding.OaepSha1 != RsaEncryptionPadding.CreateOaep(DigestAlgorithm.Sha1), "SHA-1 != SHA-1");
            Assert.IsTrue(RsaEncryptionPadding.OaepSha1 != RsaEncryptionPadding.OaepSha256, "SHA-1 != SHA-256");
            Assert.IsTrue(RsaEncryptionPadding.OaepSha1 != null, "SHA-1 != null");
            Assert.IsTrue(null != RsaEncryptionPadding.OaepSha1, "null != SHA-1");
        }