Dear Mr., Thanks for your time reading this. I use the crypto library in openssl-0.9.6b.tar.gz, and configure into VC-WIN32. After setting up and compling, every thing works fine with the XXXtest.exe in out32dll directory. Then I try to use the file demos\eay\loadrsa.c and it works. I try to use pub_rsa and priv_rsa as paramter to test RSA_public_encrypt() and RSA_private_decrypt(), but it always return -1. I try to encrypt first 64 bytes data and decrypt it, but....seem wrong. Do I use the functions in wrong ways? May I ask what's the different between RSA_PKCS1_PADDING, RSA_SSLV23_PADDING, RSA_NO_PADDING, and RSA_PKCS1_OAEP_PADDING padding method? If I change the padding in below codes, it will always return -1. Are there any demo file for using EVP functions? Or, are there any other convienent method to use varios encrypt? Here are the added code and output, thanks for your kindly help! Yours, Mars Lin ================================= static unsigned char msg[]="TEST_DATA_FOR_RSA_1231490sdf0anzjhlkjhasjdfh102931u04u102_TESTING"; unsigned char *to, *from; BIO *out; out = BIO_new(BIO_s_file()); if (out == NULL) return -1; BIO_set_fp(out,stdout,BIO_NOCLOSE); ........... p=buf; pub_rsa=d2i_RSAPublicKey(NULL,&p,(long)len); len-=(p-buf); priv_rsa=d2i_RSAPrivateKey(NULL,&p,(long)len); if ((pub_rsa == NULL) || (priv_rsa == NULL)) ERR_print_errors(out); RSA_print(out, pub_rsa, 0); RSA_print(out, priv_rsa, 0); to = OPENSSL_malloc(RSA_size(pub_rsa)); from = msg; BIO_printf(out, "original:\n%s\n", from); memset(to,0,strlen(to)); ret = 0; if (RSA_size(pub_rsa)!=RSA_size(priv_rsa)) BIO_puts(out, "Different size..\n"); BIO_printf(out, "mod size: %i\n", RSA_size(pub_rsa)); BIO_printf(out, "data length: %i\n", strlen(msg)); ret=RSA_public_encrypt(RSA_size(pub_rsa), from, to, pub_rsa, RSA_NO_PADDING); if (ret == -1) { ERR_print_errors(out); } BIO_printf(out, "%s\n", to); BIO_printf(out, "ret: %i\n",ret); ret=RSA_private_decrypt(RSA_size(priv_rsa), to, result, priv_rsa, RSA_NO_PADDING); if (ret == -1) { ERR_print_errors(out); } buf[ret]='\0'; BIO_printf(out, "%s\n", buf); BIO_printf(out, "ret: %i\n",ret); RSA_free(pub_rsa); RSA_free(priv_rsa); return 0; ================================= OUTPUT: original: TEST_DATA_FOR_RSA_1231490sdfja;l0901238lkjasdfsdf0anzjhlkjhasjdfh102931u04u1 02_TESTING mod size: 64 data length: 86 ?n?Z?WIȺ_;jFR2i0}???pTD ret: 64 0HA ret: 64 ================================= ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List [EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]