Am Mi 10.09.2014, 13:20:01 schrieb Sudhir Khanger:
> Hello,
> 
> Is there a way to tell if a GPG key's passphrase is cached or not?
> Just like ssh-add -l prints all the keys that are in current keychain
> ready to be used.

I am working on a Python script which does that as preparation for its 
main task. You could probably easily adapt it to your needs. Of course, 
it does not (cannot) solve the race condition Werner mentioned).

The general approach is to read the fingerprints of all available secret 
mainkeys and subkeys

gpg --with-colons --fingerprint --fingerprint --list-secret-keys

and check for each entry whether gpg-agent knows the fingerprint:

gpg-connect-agent "GET_PASSPHRASE --data --no-ask "\
"4F7E9F723D197D667842AE115F048E6F0E4B4494 t1 t2 t3" /bye


Hauke
-- 
Crypto für alle: http://www.openpgp-schulungen.de/fuer/unterstuetzer/
http://userbase.kde.org/Concepts/OpenPGP_Help_Spread
OpenPGP: 7D82 FB9F D25A 2CE4 5241 6C37 BF4B 8EEF 1A57 1DF5

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
Gnupg-users mailing list
Gnupg-users@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gnupg-users

Reply via email to