I am using libgcrypt libraries to do public key private key generation, and its encryption/decryption/signing/verification.(DSA)

But my problem is, when i encrypt the data, the gcry_strerror gives me error "not implemented", which the error in manual is stated as "this error should never happen"

My part of codes are written below. Please help me to see why the encryption cannot be done. I use the public key generated to do verification, it s also successful,so i dont know where am i wrong.

Thanks for advice in advance first!!!

--------------------------------------------------------------------------------------------------

#include <gcrypt.h>
..
..
int main (){
gcry_error_t err;
gcry_sexp_t key_spec,key,pubk,pvt,plaintext,data;
gcry_mpi_t x;

err = gcry_sexp_new
(&key_spec,
"(genkey (dsa (transient-key)(domain"
"(p #d3aed1876054db831d0c1348fbb1ada72507e5fbf9a62cbd4 7a63aeb7859d6921"//1024 bits
"4adeb9146a6ec3f43520f0fd8e3125dd8bbc5d87405d1ac5f 82073cd762a3f8d7"
"74322657c9da88a7d2f0e1a9ceb84a39cb40876179e6a76e4 00498de4bb9379b0"
"5f5feb7b91eb8fea97ee17a955a0a8a37587a272c4719d6fe b6b54ba4ab69#)"
"(q #9c916d121de9a03f71fb21bc2e1c0d116f065a4f#)"//160 bits
"(g #8157c5f68ca40b3ded11c353327ab9b8af3e186dd2e8dade9 8761a0996dda99ab"
"0250d3409063ad99efae48b10c6ab2bba3ea9a67b12b911a3 72a2bba260176fad"
"b4b93247d9712aad13aa70216c55da9858f7a298deb670a40 3eb1e7c91b847f1e"
"ccfbd14bd806fd42cf45dbb69cd6d6b43add2a78f7d16928e aa04458dea44#)"
")))", 0, 1);

err = gcry_pk_genkey(&key,key_spec);
gcry_sexp_release(key_spec);

pubk = gcry_sexp_find_token(key, "public-key",0);
pvt = gcry_sexp_find_token(key, "private-key",0);
gcry_sexp_release(key);


x=gcry_mpi_new(800);

gcry_mpi_randomize(x,800,GCRY_WEAK_RANDOM);
err = gcry_sexp_build(&plaintext,NULL,"(data(flags raw)(value %m))",x);

data= gcry_sexp_find_token(plaintext,"value",0);

--------------------------//UNTIL THIS POINT, THE CODES ARE ALL OKAY. AND I CAN PRINT OUT ALL THE KEYS ON SCREEN
gcry_sexp_t enc;

err = gcry_pk_encrypt(&enc,data,pubk);if (err)
printf("Encryption failed: %s\n",gcry_strsource(err));//THIS ERROR MSG SHOWS UP - NOT IMPLEMENTED.else
printf("Encrypting data successful\n");

return 0;}

-----------------------------------------------------------------------------------------------------

I ve tried to initialize all s-expression variables to NULL ,but it doest work either.

ANYONE helps me! thanks!