title: Node.js Builtin Crypto: RSA Decryption
body: <p>I'm using node.js 0.10.12. I have generated 2048-bit RSA keypairs that I store as .pem files locally. </p>
  
  <p>Using the built-in 'crypto' library that comes with node, I am trying to decrypt a block of data encrypted with the public RSA key mentioned above.</p>
  
  <p>I've gotten this far:</p>
  
  <pre><code>var privateKey = fs.readFileSync('private.pem', { encoding: 'utf8' });
  
  var cryptOpt = { key: /* PEM encoded private key */ privKey };
  
  var cred = crypto.createCredentials( cryptOpt );
  
  var rsa = crypto.createDecipheriv( 'rsa', cred.?key-in-binary-format?, cred.?initialization vector? );
  </code></pre>
  
  <p>I'm not sure I'm on the right path here. </p>
  
  <p>• I don't know where the key is stored in binary form inside 'cred'.</p>
  
  <p>• I don't know what to put in initialization-vector parameter.</p>
  
  <p>The data will be encrypted using standard libraries on iOS, which, to my knowledge, does not allow the user to specify an initialization vector when encrypting with RSA.</p>
  
  <p>I haven't been able to extract much knowledge or understanding from the node.js crypto docs:
  <a href="http://nodejs.org/api/crypto.html" rel="nofollow">http://nodejs.org/api/crypto.html</a></p>