Mailing List Archive

trying to use the public key functions
Im trying to write a program that uses libgcrypt to verify a file against
a known public gpg key.

Im really strugling to make any progress at all, as a start i would like
to be able load store and verify the public key.

GCRY_SEXP key;

/* Store the key in libgcrypt's struct */
gcry_sexp_build(/* I have no idea what goes in here */)

/* Check the key is in a valid format */
result = gcry_pk_testkey(key);
if (result != 0) {
printf("Key check failed, %s\n", gcry_strerror(result));
}

I dont know how to trasfer the data from the .gpg file to the GCRY_SEXP
structure.

e.g. i have
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)

iEYEABECAAYFAjzivCQACgkQqn3re3IvGu0knQCfem0zm2wCWYxNgTrsjmw8f5Se
m7oAoKYonuIKxty8YWcZHTm+qo1A6oTa
=msEe
-----END PGP SIGNATURE-----

How do i format and parse this ?

It probably should be an easy question, ive been looking around the gpg
and libgpcrypt code for for a few hours trying to work it out, but im
lost.


Thanks

Glenn
Re: trying to use the public key functions [ In reply to ]
On Fri, 17 May 2002 03:49:37 +1000
"Glenn McGrath" <bug1@optushome.com.au> wrote:

> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.0.6 (GNU/Linux)
>
> iEYEABECAAYFAjzivCQACgkQqn3re3IvGu0knQCfem0zm2wCWYxNgTrsjmw8f5Se
> m7oAoKYonuIKxty8YWcZHTm+qo1A6oTa
> =msEe
> -----END PGP SIGNATURE-----
>

gpg --list-packets shows
:signature packet: algo 17, keyid AA7DEB7B722F1AED
version 4, created 1021492260, md5len 0, sigclass 00
digest algo 2, begin of digest 24 9d
hashed subpkt 2 len 5 (sig created 2002-05-15)
subpkt 16 len 9 (issuer key ID AA7DEB7B722F1AED)
data: [159 bits]
data: [160 bits]

I think i have to do something like
result = gcry_sexp_build(&key, NULL, "(public-key (dsa (p A) (y B) (q C)
(g D)");

where A, B, C and D are derived from the public key somehow.



Glenn
Re: trying to use the public key functions [ In reply to ]
On Fri May 17 2002; 03:49, Glenn McGrath wrote:

> I dont know how to trasfer the data from the .gpg file to the GCRY_SEXP
> structure.

The OpenCDK library contains a lot of code for transforming
OpenPGP keys into the GCRY_SEXP structure. Currently the library
is under *heavy* development but the code for this procedure works
and you can use it as an example.

You can get the latest source from the CVS:
cvs -d :pserver:anoncvs@cvs.gnupg.org:/cvs/gnutls checkout opencdk
or a snapshot from the OpenCDK website (http://www.winpt.org/opencdk.html).


Timo