#include <openssl/pem.h>
#include <openssl/evp.h>
#include <openssl/applink.c>
int LoadPublicKey( const char* keyFile )
{
FILE* f = fopen( keyFile, "r" );
if (!f) return FALSE;
RSA* pRSA = PEM_read_RSAPublicKey( f, NULL, NULL, NULL );
if (!pRSA)
{
fclose( f );
return 0;
}
fclose( f );
return (int)pRSA;
}
int main()
{
CRYPTO_malloc_init();
EVP_add_cipher( EVP_aes_256_cbc() );
int keyPub = LoadPublicKey( "public.pem" );
....
}
#include <openssl/pem.h>
#include <openssl/evp.h>
#include <openssl/applink.c>
int LoadPublicKey( const char* keyFile )
{
FILE* f = fopen( keyFile, "r" );
if (!f) return FALSE;
RSA* pRSA = PEM_read_RSAPublicKey( f, NULL, NULL, NULL );
if (!pRSA)
{
fclose( f );
return 0;
}
fclose( f );
return (int)pRSA;
}
int main()
{
CRYPTO_malloc_init();
EVP_add_cipher( EVP_aes_256_cbc() );
int keyPub = LoadPublicKey( "public.pem" );
....
}
To copy to clipboard, switch view to plain text mode
The same code works fine when compiled by a VC6 compiler.
Bookmarks