Error 65 in call to gcry_pk_encrypt

skhan@gatekeeper.umtstrial.co.uk skhan@gatekeeper.umtstrial.co.uk
Thu, 13 Feb 2003 18:59:01 +0000 (GMT)


Hi
Working on some simple encryption using libgcrypt but having problems
when trying to encrypt a buffer. Have a look at the code below:

/* Our Program - v0.1 */
/* 13/2/03            */

#include <stdio.h>
#include "/home/licq/install/include/gcrypt.h"

int main (int argn, char *argv[])
{

char str[10]="123456789";
char fkey[3000];
FILE *fp;
GcrySexp result;
GcrySexp data;
GcrySexp key;
int i;

str[9]='\0';
i=0;
fp=fopen("/home/licq/pubkey-ascii","r");

while (!feof(fp)) {
 fkey[i++]=fgetc(fp);
}
fkey[i]='\0';
fclose(fp);

gcry_sexp_new (&data,str,strlen(str),0);
gcry_sexp_new (&key,fkey,strlen(fkey),0);

printf("Return value is [%d]",gcry_pk_encrypt (&result, data, key));
}

* pubkey-ascii holds my key

- Should I be using ascii or binary keys?
- Am I initialising the key and data values correctly?
- Can result be passed in by refrence.
- What does the fourth argument in gcry_sexp_new mean?


I know that the error means there is problem in one of the parameters
passed to crypt but which one.....

Cheers
SK