Hi, memcpy is not working for the RAND_bytes. could anyone help me to resolve the issue.
blf.c #include<stdio.h> #include"scatype.h" #include<stdlib.h> #define BF_DEFAULT_KEY_SIZE 128 typedef struct { unsigned long length; unsigned char dsc_type; unsigned char dsc_class; char *str; } STR_DESCRIPTOR; /* functions have to be external */ extern blfGenKey(); int main() { printf("in main\n"); /* call function from shared library */ STR_DESCRIPTOR key; key.str = malloc(1024); blfGenKey(&key); printf("digest - |%s|\n",key.str); free (key.str); return 0; } blowfish.c int blfGenKey(STR_DESCRIPTOR *key) { 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"); if(!RAND_bytes(keyData,BF_DEFAULT_KEY_SIZE)) memcpy(key->str,keyData,BF_DEFAULT_KEY_SIZE); key->length = BF_DEFAULT_KEY_SIZE; printf("key=\n%s\n",key->str); status = SUCCESS; printf("\n%d\n",key->length); output: in main entered 128 entered loop key= <--------------null value 128 status=0 digest - || <------key is not printing Any help would be greatly appreciable. kris