0

RSAを使用していくつかのものを暗号化するために使用しようとしていますOpenSSL

RSA *rsaPubKey = RSA_new();
FILE *file;
file = fopen("PubKey.pem","r");

if(file){
    rsaPubKey = PEM_read_RSA_PUBKEY(file, &rsaPubKey ,NULL,NULL);
}
.......... //some stuff 
return 0

アプリの実行後PEM_read_RSA_PUBKEY、エラーなしで終了します。何が悪いのかわからない!!

4

1 に答える 1

0

I have used the following code in an old project:

BIO *bioPub = BIO_new_file(pubkeyPath, "r");
RSA *pubkey = PEM_read_bio_PUBKEY(bioPub, NULL, NULL, NULL);
/* do some stuff */
RSA_free(pubkey);
BIO_free(bioPub);

Have you tried the following?

FILE *file = fopen("PubKey.pem","r");
RSA *rsaPubKey = PEM_read_RSA_PUBKEY(file, NULL, NULL, NULL);
于 2012-07-25T18:06:00.933 に答える