Problem with C++ wrapper and gpgme

Werner Koch wk at gnupg.org
Mon May 26 22:26:01 CEST 2003


On Mon, 26 May 2003 21:27:23 +0400, Yenot  said:

> is a keymanager written in C++. Your goal is to take the information 
> from *all* keys on a keyring and display them in a pretty GUI.

Reading *all* keys might not be a good idea at all. Depending on the
backend you might end uop with millions of keys.  OpenPGP does not
specify something like a keyring; this is just waht's use in gpg
currently.  Another version may in theory access directly the keys on
a keyserver or from an LDAP server.  Tools trying to read all keys on
startup would then need to offer the user some entertainment
facilities.

> For this, your best bet is parse the raw binary output of
> "gpg --list-keys".  If you don't parse the raw binary output, this is 
> what will happen:

I don't know what is meant by the raw binary format.  A plain
--list-keys prints the keys in a format useful for humans and
resembles mostly the well known format of PGP.  However this is hard
to parse and thus the colon format can be used.  In terms of
computations needed the colon format is even faster because only
minimal filtering needs to be done.

One might get the impression, that the colon listing is slower, but
this is due to the extra information provided: The key validity is
calculated (or taken from a cache) for each key.  Use
--no-expensive-trust-checks to suppress this.

> GnuPG will first do lots of expensive string parsing and memory 
> management operations to force all the data into an unnecessary [for 
> your application] "colon format".  Then GPGME will do lots of 

but this is a well defined format.  The other one might change
without notice and actually did a couple of times.

> expensive string parsing and memory management operations to parse 

That are not expensive operations.  Have a look at the parsing code of
gpg and you will notice that everything is done dynamically and there
is not much performance penalty as long as the meory is released in an
appropriate way.


-- 
  Nonviolence is the greatest force at the disposal of
  mankind. It is mightier than the mightiest weapon of
  destruction devised by the ingenuity of man. -Gandhi





More information about the Gnupg-devel mailing list