I am writing a c/c++ code for Win32 Dynamic_link Library in visual studio 6. Actually i am using libcryptoMD.lib for implementing RSA encryption using pem file and ppk file. I'm able to do this encryption in sample code but PEM_read_RSAPublicKey() crashes in actual application code.
I have already tried setting all the Project Settings of actual application code to sample project as there could be some conflicts in dependency libries of actual application code. But to my surprise, sample project worked successfully and actual application failed. I also searched for why this function could have crashed in actual application code, but could not find any useful answer. This function needs filepointer of public key pem file and RSA pointer which are absolutely fine.
RSA * create_RSA(RSA * keypair, int pem_type, char *file_name) {
RSA *rsa = NULL;
FILE *fp = NULL;
if(pem_type == PUBLIC_KEY_PEM)
{
fp = fopen(file_name, "rb");
PEM_read_RSAPublicKey(fp, &rsa, NULL, NULL);
fclose(fp);
}
else if(pem_type == PRIVATE_KEY_PEM)
{
fp = fopen(file_name, "rb");
PEM_read_RSAPrivateKey(fp, &rsa, NULL, NULL);
fclose(fp);
}
return rsa;
}
PEM_read_RSAPublicKey(fp, &rsa, NULL, NULL); crashes showing
OPENSSL_Uplink(6F8D1880,08): no OPENSSL_Applink in actual application code.