title: Generate RSA public/private key with OpenSSL?
body: <p>The main problem is that I'm quite new to C, and the OpenSSL documentation is not clear enough for me, I've tried using <a href="https://stackoverflow.com/questions/12647220/reading-and-writing-rsa-keys-to-a-pem-file-in-c">Reading and writing rsa keys to a pem file in C</a>, but I don't quite understand it. For example, how does the <code>create_rsa_key()</code> function creates both the private and the public? And where does <code>pCipher</code> come from? And what's the point of the <code>pcszPassphrase</code>?</p>
  
  <p>I'll explain as if it was some sort of pseudocode, this is what I want to do, and the parts in bold are those I don't know how to do it:</p>
  
  <ul>
  <li><strong>generate private key and public key as buffers in hex (client)</strong></li>
  <li>send the public key to the other endpoint safely (client)</li>
  <li>encrypt some data with a random 256 bit password using AES256 CBC (server)</li>
  <li><strong>encrypt the password using the public key (server)</strong></li>
  <li>send the encrypted data to the client (server)</li>
  <li>decrypt the encrypted 256 bit password using the private key (client)</li>
  <li><strong>decrypt the file</strong></li>
  </ul>
  
  <p>Basically I know how to handle AES encryption/decryption and the communication protocol, they're already implemented anyway, my issue is RSA, and I need hex format not base64 or pem as I'm working with sockets and sending and storing as binary data.</p>