tel dispas wrote:

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

see below


....
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);

that's bad: encrypted_string contains binary data (and not an ascii string) => printf will print everything from the given address until it reads a '\0' (including adjacent memory regions, if necessary).

        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");

}

Nils


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

Reply via email to