How to use it

Ralf Schneider ralf@tapfere-schneiderleins.de
Wed, 16 Jul 2003 14:12:48 +0200


=2D----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am Mittwoch, 16. Juli 2003 10:00 schrieb Moritz Schulte:
> > 2. How can I convert the generated keys from gcry_ac_key_t to anything
> > else that can be stored in a database? Which data type should I use for
> > that (SAP DB)?
>
> Well, libgcrypt contains functions for printing and scanning MPI
> values, which could be used for storing and reading the key material.
> Maybe it makes sense to to have high level functions for storing and
> reading data sets in the ac interface.

What is the best way to store keys in a database? base64 encoded in a VARCH=
AR=20
field?

> > 3. If I understood the example in ac.c correctly, an unsigned int value
> > is encrypted. How can I pass a string to gcry_ac_data_encrypt for
> > encryting it?
>
> The data must be encoded in a MPI value.  I think it makes sense to
> have a function for this purpose in the ac interface.  Until that is

I tried the following sequence for storing a string in a MPI value, but I g=
et=20
a segmentation fault with the gcry_mpi_print call:

  char text[1024] =3D "This is a test string.";
  char buf[1024];
  size_t textlen =3D strlen(text);
  size_t buflen =3D 1024;
 =20
  gcry_mpi_scan  (&x, GCRYMPI_FMT_HEX, text, &textlen);
  gcry_mpi_print (GCRYMPI_FMT_HEX, buf, &buflen, x);
  printf (buf);

What I expected is that the original string is printed in the last line. Wh=
at=20
is the problem with the above code? I looked into encode.c, but could not=20
identify a place where a string is encoded to a MPI value. Can you give me =
a=20
hint how the encoding can be done?

Thanks in advance,
Ralf.
=2D----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE/FUFB7YyyfykA0YkRAvwaAJ9jSYdraQRtWNQc/Z0ADfUXceBCVQCeLfHw
4QcihdILS1wB405yDFIyZFU=3D
=3DD5xZ
=2D----END PGP SIGNATURE-----