title: How to encrypt small data block with only RSA public key using Microsoft ECSP?
body: <p>I need to encrypt a small block of data (16 bytes) using 512 bit RSA public key -- quite an easy task for most cryptography libraries known to me, except for MS CSP API, as it seems.
  Documentation for <a href="http://msdn.microsoft.com/en-us/library/aa379924(VS.85).aspx" rel="nofollow noreferrer">CryptEncrypt</a> function states that</p>
  
  <blockquote>
    <p>The Microsoft Enhanced Cryptographic Provider supports direct encryption with RSA public keys and decryption with RSA private keys. The encryption uses PKCS #1 padding.</p>
  </blockquote>
  
  <p>It didn't work to me though. Well, my code works and produces encrypted block of data with correct size, but openssl fails to decypher it. It looks much like CryptEncrypt still uses symmetric cypher.</p>
  
  <p>Unfortunately all the examples I've found refer to combined cryptography with symmetric cypher, so I don't have a working example on hands which definitely would make things easier.</p>
  
  <p>Could please anyone point me to such an example or let me know if there are some not that obvious pitfalls I've missed?</p>
  
  <p>Thank you.</p>