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