Dear Jakob, Thank your for your analysis. I am sorry for only post the part of my code. Actually, the result from Line 1 to Line 6 is to get the private key and make the pointer pKey_priv point to the private key. In the following lines below Line 8, I will use the pKey_priv to sign the data generated in Line 7 and Line 8.
Yes, I change the optimization option from -O2 to -O0. Only in this case, I can execute all the code lines. But I would like to know if the optimization will bring heavy negative impacts on the performance of the signing and verifying operation, which means the signing and verifying speed will be slow. That is my concern. Thank you. Best Regards, Xiang 2010/7/2 Jakob Bohm <jb-open...@wisemo.com> > On 02-07-2010 00:12, 翔芦 wrote: > >> Dear all, >> >> My code segment is to get a private key from a pem file for the data >> signing. The code is as the following: >> >> 1 BIO *priv_pem; >> >> 2 OpenSSL_add_all_algorithms(); >> >> 3 priv_pem = BIO_new_file("privkey.pem", "rb"); >> >> 4 pKey_priv = RSA_new(); >> >> 5 pKey_priv = PEM_read_bio_RSAPrivateKey(priv_pem, &pKey_priv, NULL, >> "3042"); >> >> 6 BIO_free(priv_pem); >> >> 7 data_generator(data_len, raw_apdu); >> >> 8 hdr_generator(p_h); >> >> > > There is apparently nothing in your code that uses the results from lines 7 > and 8, so the compiler optimizes it away as it doesn't contribute to the > result of your program. The compiler could/should > have done the same for lines 1 through 6 (as you don't actually use the > loaded key for anything), but just doesn't know enough about openssl > internals to be sure the openssl calls don't output something useful. > > Once you write lines 9 and later (to actually use the key and the generated > data) and some lines to actually output the result to your > smart card, the optimizer should stop optimizing away those lines. > > (Compiling with -O0 tells gcc to be too stupid to eliminate the unused > lines). > > ______________________________________________________________________ > OpenSSL Project http://www.openssl.org > User Support Mailing List openssl-users@openssl.org > Automated List Manager majord...@openssl.org >