newbie question ( RSA with ac )

JohnSteam johnsteam at gmx.net
Mon Aug 20 15:45:07 CEST 2007


Hello everybody,

i want to encrypt / decrypt a string with the ac interface

i tried this to encrypt:

   g_err = gcry_ac_open( &handle, GCRY_AC_RSA, 0);
   assert( !g_err );
   g_err = gcry_mpi_scan( &plain, GCRYMPI_FMT_USG, plain_b,
strlen( plain_b ), NULL );
   assert( !g_err );
   g_err = gcry_ac_data_encrypt( handle, 0, key, plain, &encrypted );
   assert( !g_err );
   g_err = gcry_ac_data_get_index( encrypted, 0, 0, NULL, &tmp_mpi );
   assert( !g_err );
   g_err = gcry_mpi_aprint( GCRYMPI_FMT_HEX, &buffer, &len, tmp_mpi );
   assert( !g_err );

decrypt:

  g_err = gcry_ac_open( &handle, GCRY_AC_RSA, 0);
   assert( !g_err );
   g_err = gcry_mpi_scan( &enc_mpi, GCRYMPI_FMT_USG, enc_b,
strlen( enc_b ), NULL );
   assert( !g_err );
   g_err = gcry_ac_data_new( &enc );
   assert( !g_err );
   g_err = gcry_ac_data_set( enc, GCRY_AC_FLAG_COPY, "a", enc_mpi );
   assert( !g_err );
   g_err = gcry_ac_data_decrypt( handle, 0, key, &decrypted, enc );
   assert( !g_err );
   g_err = gcry_mpi_aprint( GCRYMPI_FMT_HEX, &buffer, &len, decrypted );
   assert( !g_err );

but the decryption result does not match my string....
can you please tell me what i've done wrong?




More information about the Gcrypt-devel mailing list