Is this abug... ? or i am doing something wrong....


ok in the falowing code ... very often i can se 0123456789 (whit is the string i want to encryp...)
in the encrypted string... most of the time at theend of the string...


ps i tries the both RSA_generate_key() that you see the coment one and the other and it does not seems to chage nothing..


#include <stdio.h> //required by every program #include <openssl/rsa.h> //rsa library #include <openssl/evp.h>

void callback(stage,count,arg)
int stage,count;
char *arg;
       {
       FILE *out;

       out=(FILE *)arg;
       fprintf(out,"%d",stage);
       if (stage == 3)
               fprintf(out,"\n");
       fflush(out);
       }

main()
{
        int len;
        unsigned char buf[10240],*p, *c;

        srand(5);
        RSA *rsa;

                rsa=RSA_generate_key(1024,RSA_F4,callback,(char *)stdout); //demo 
example
                //rsa=RSA_generate_key(2048, 65537, NULL, NULL);

                unsigned char to_encrypt[10] = "0123456789";
                unsigned char encrypted_string[RSA_size(rsa)];
                unsigned char decrypted_string[10];

RSA_public_encrypt(10, to_encrypt, encrypted_string, rsa, RSA_PKCS1_OAEP_PADDING);

RSA_private_decrypt(RSA_size(rsa), encrypted_string, decrypted_string, rsa, RSA_PKCS1_OAEP_PADDING);



                printf("\n\n string to encrypt: ", to_encrypt);
                printf(to_encrypt);
                printf("\n\n string public encrypted: \n\t");
                printf(encrypted_string);
                printf("\n\nEnd of encrypted_string\n\n");
                printf("\n\n string decrypted: ");
                printf(decrypted_string);

printf("\n\n it is the end \n\n");

}

_________________________________________________________________
MSN Search, le moteur de recherche qui pense comme vous ! http://fr.ca.search.msn.com/


______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to