[gpgme] when the password is aked?

Marcus Brinkmann marcus.brinkmann at ruhr-uni-bochum.de
Tue Oct 5 15:08:32 CEST 2004


At Tue, 5 Oct 2004 10:11:59 +0200,
micron <micron at madlab.it> wrote:
> to one of my programs.
> The only gpgme's documentation resource I've found is an info file. In this 
> file, in the section regarding the crypto operations (signature,...) there's 
> nothing about key's password.

The list of possible error values lists the error
GPG_ERR_BAD_PASSPHRASE if the operation requires a passphrase.  This
is also mentioned explicitely for the symmetric encryption operation.

> How the password is retrieved by gpgme?
> The only thing I've to do is to set the password callback function for my 
> context?

Right.  

> If so anybody can explain (maybe with some code) how the function 
> "gpgme_error_t (*gpgme_passphrase_cb_t)(void *HOOK, const  char *UID_HINT, 
> const char *PASSPHRASE_INFO, int PREV_WAS_BAD, int FD)" works?

It's documented in the chapter "Context attributes", node "Passphrase
callback".

 - Data type: gpgme_error_t (*gpgme_passphrase_cb_t)(void *HOOK, const
char *UID_HINT, const char *PASSPHRASE_INFO, int PREV_WAS_BAD, int FD)
     The `gpgme_passphrase_cb_t' type is the type of functions usable as
     passphrase callback function.

...

A very simple example is in gpgme/cvs/tests/gpg/t-support.h Better
example code can be found in mutt or other GPGME using applications.
Note that storing the passphrase in secured (mlock) memory is a good
idea.  Newer gpg versions also support use of gpg-agent, in which case
the passphrase callback will not be used at all.

Thanks,
Marcus





More information about the Gnupg-devel mailing list