Starting with libgrypt

Moritz Schulte
Mon, 14 Jul 2003 13:58:51 +0200

Ralf Schneider <> writes:


> I'm currently starting with libgrypt. I want to use the public key
> algorithms (DSA 1024 bit). I looked into the docs (version 1.1.11),
> but did not find any info about the public key functions.

Oh, 1.1.11 is really ancient.  The last release was 1.1.12 and the
next release, with several fundamental changes, will follow quite
soon.  I suggest you have a look at the CVS version.

> Are there any examples on how to generate the keys and how to
> en-/decrypt texts/files?

Since you are talking about the generation of keys, I assume you are
referring to asymmetric cryptography.  The CVS version contains two
files showing how to generate new key pairs: pubkey.c, which uses the
S-Expression based gcry_pk_* Interface and ac.c, which uses the new
gcry_ac_* interface, that might be much easier to use, since it is not
based on S-Expressions, that have to be constructed/extracted by the

Both interfaces, and of course the gcry_cipher_* interface for
symmetric cryptography, are documented in the Texinfo manual.

> How can I tell the lib which pk algorithm to use?

When using the gcry_pk interface, the name of the algorithm to use is
embedded in S-Expressions; when using the gcry_ac interface, the name
is specified as a numeric constant when creating a new handle.

> Is there no open function for the pk algorithms?

For the gcry_pk interface, there is no open function, for the gcry_ac
interface there is one.

> How does the GcrySexp struct work?

This is also documented in the manual.

((gpg-key-id . "6F984199")
 (email      . "")
 (webpage    . ""))