title: Decrypting Windows Crypto API RSA Ciphertext With OpenSSL
body: <p>I have created a C++ program that encrypts some bytes with a RSA 2048 key.</p>
  
  <p>The output of the program is 256 bytes and everything seems to work fine.</p>
  
  <p>However I've been completely unable to figure out how to decrypt this with openssl.</p>
  
  <p>I've been told that I might need to reverse the byte order so it becomes big endian but it doesn't seem to help. (I assume reversing the bytes order means turning 1F 02 C8 into F1 20 8C etc.)</p>
  
  <p>I'm mainly getting the following error from openssl.</p>
  
  <p>openssl rsautl -in output.bin -inkey privatekey -decrypt
  rsa routines:RSA_padding_check_PKCS1_type_2:block type is not 02:rsa_pk1.c:190:</p>
  
  <p>Here is a code snippet of my encryption for anyone that interested (I've tried it with final as true also)</p>
  
  <pre><code>BYTE crapBuffer[1200] = {0x33,0x1F,0x22,0x34,0x33,0x1F,0x22,0x34,0x33,0x1F,0x22,0x34,0x33,0x1F,0x22,0x34,0x33,0x1F,0x22,0x34};
  DWORD dataLen = 20;
  CryptEncrypt(publicKey,0,false,0,(BYTE *)crapBuffer,&amp;dataLen,1200);
  </code></pre>
  
  <p>Any help would be greatly appreciated,</p>