unsigned char * BUFFER_PTR;
CRYPT_CONTEXT cryptContext;
// Initialize the buffer
BUFFER_PTR = (unsigned char *) malloc(sizeof(char) * BUFFER_SIZE);
memset(BUFFER_PTR, 'X', BUFFER_SIZE);
//Initialize crytplib
cryptInit();
// create encryption context
cryptCreateContext( &cryptContext, CRYPT_UNUSED, CRYPT_ALGO_ELGAMAL);
cryptSetAttributeString( cryptContext, CRYPT_CTXINFO_LABEL, KEY_ID, strlen(KEY_ID));
cryptGenerateKey(cryptContext);
/* ERROR >>>*/ cryptEncrypt(cryptContext, BUFFER_PTR, BUFFER_SIZE); /* this line fails and I don't know why :-( */