title: Is MGF1 padding assumed in System.Security.Cryptography.RSA.Encrypt method with RSAEncryptionPadding.OaepSHA256?
body: <p>I need to encrypt plain bytes with RSA public key using OaepSHA256 and MGF1 padding. So I figured that I can write following code (using .net framework 4.7):</p>
  
  <pre><code>var encryptionCert = new X509Certificate2(certBytes);
  using (var rsaPublicKey = encryptionCert.GetRSAPublicKey()) // Get an instance of RSA derived class
      {
          var encryptedKeyBytes = rsaPublicKey.Encrypt(plainBytes, RSAEncryptionPadding.OaepSHA256);  
  }
  </code></pre>
  
  <p><em>I have no idea if MGF1 padding and Optimal Asymmetric Encryption Padding (OAEP) are related or not.</em></p>
  
  <p>Here are my questions:</p>
  
  <ol>
  <li>In .net framework, does the above code automatically account for MGF1 padding (in addition to supplied OAEP)?</li>
  <li>If not, then what are my options to achieve my goal (other than going to bouncy castle library)?</li>
  </ol>