>       From: owner-openssl-us...@openssl.org On Behalf Of krishnamurthy
santhanam
>       Sent: Tuesday, 05 October, 2010 14:26

>       memcpy is not working for the RAND_bytes. could anyone help me to
resolve the issue.

<snip>
>           unsigned char    keyData[BF_DEFAULT_KEY_SIZE];
>           int status = FAILURE;
>           printf("\n entered\n");
>           printf("%d\n",BF_DEFAULT_KEY_SIZE);    
>           int i;
>           printf("\n entered loop\n");

Aside: this is misleading; there's no loop here

>           if(!RAND_bytes(keyData,BF_DEFAULT_KEY_SIZE))
>               memcpy(key->str,keyData,BF_DEFAULT_KEY_SIZE);

RAND_bytes returns 1 for success and 0 or possibly -1 
for error. The memcpy is executed only if RAND_bytes 
failed, which it will if the PRNG isn't seeded.
You didn't explicitly seed, and whether there is 
adequate default seeding can depend on your platform, 
configuration and environment.

man 3 RAND_seed RAND_load_file RAND_egd 

>               key->length = BF_DEFAULT_KEY_SIZE;
>               printf("key=\n%s\n",key->str);
>               status = SUCCESS;
>               printf("\n%d\n",key->length);    

The indentation looks like you think these are (also) 
conditioned on the if above, but they aren't.

Even if you had gotten some random data into key->str,
it is binary data and not suitable for printing with %s.



______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to