title: OpenSSL RSA_size with EVP_PKEY
body: <p>I have a question regarding RSA_size.</p>
  
  <p>Version that crash on WIN32 but works on linux platforms :</p>
  
  <pre><code>  ... 
    EVP_PKEY* pPublicKey = null;
    unsigned int uKeySize = 0;
    const unsigned char *pData;
    pData = a_publicKey-&gt;Key.Data; /* Key.Data = unsigned char *p containing the Key in a string version */
    pPublicKey = d2i_PublicKey(EVP_PKEY_RSA, null, &amp;pData, a_publicKey-&gt;Key.Length);
    if(pPublicKey != null)
    {
      uKeySize = RSA_size(pPublicKey-&gt;pkey.rsa); //Crash
    }
    ...
  </code></pre>
  
  <p>Version that work on win32 (not tested on linux but I suppose it works as well): </p>
  
  <pre><code>  ... 
    EVP_PKEY* pPublicKey = null;
    RSA* pRsaPublicKey = null;
    unsigned int uKeySize = 0;
    const unsigned char *pData;
    pData = a_publicKey-&gt;Key.Data; /* Key.Data = unsigned char *p containing the Key in a string version */
    pPublicKey = d2i_PublicKey(EVP_PKEY_RSA, null, &amp;pData, a_publicKey-&gt;Key.Length);
    if(pPublicKey != null)
    {
      pRsaPublicKey = EVP_PKEY_get1_RSA(pPublicKey);
      EVP_PKEY_free(pPublicKey);
      uKeySize = RSA_size(pRsaPublicKey);
    }
    ...
  </code></pre>
  
  <p>I do not understand why the first version crash. But when I look into the pkey.rsa structure, values are not the same as in the RSA pointer in the 2nd version.
  Any ideas ?</p>