title: PEM_read_bio_RSAPrivateKey() difference on Windows
body: <p>I am writing some code to RSA sign data. I have gotten this code to work successfully on Ubuntu (OpenSSL version is 1.0.1f-1ubuntu2.7). The code takes the message, and produces the signed result with the private key, I can verify is correct using a separate program and the matching public key. </p>
  
  <p>Under windows, the exact same code produces a different result, the signed data is different (And does not verify. I can't figure out why. I am using the OpenSSL distribution 'Win64OpenSSL-1_0_1j' from <a href="http://slproweb.com/products/Win32OpenSSL.html" rel="nofollow">http://slproweb.com/products/Win32OpenSSL.html</a> .</p>
  
  <p>Here is the code: </p>
  
  <pre><code>const char * rsa_pri_key = "-----BEGIN RSA PRIVATE KEY-----\n"
          "MII...L1t\n"
          "yC0...+zk\n"
          "c0...5Q\n"
          "-----END RSA PRIVATE KEY-----\n";
  
  BIO* bio = BIO_new_mem_buf( (void*)rsa_pri_key, -1 );
  BIO_set_flags( bio, BIO_FLAGS_BASE64_NO_NL );
  
  RSA* private_key = PEM_read_bio_RSAPrivateKey(bio, NULL, NULL, NULL ) ;
  if( !private_key )
  {
      std::cout &lt;&lt; "Key load failed" &lt;&lt; std::endl;
  }
  BIO_free( bio ) ;
  
  
  // Sign the data
  signature = (unsigned char*) malloc(RSA_size(private_key));
  
  RSA_sign(NID_md5, (unsigned char*) message, strlen(message), signature, &amp;slen, private_key)
  </code></pre>