for signing; selecting a specific private key

folkert folkert at vanheusden.com
Sun May 31 20:14:06 CEST 2015


Hi,

I'm trying to sign some data.
In the key ring I have more then 1 private key so I want to select the
correct one.
This fails with: "Unusable secret key (117440566)".
The key was generated with gnupg2 itself.

sec   1024R/14B7E8E6 2015-05-27
      Key fingerprint = 95C7 6C5E F839 43DA 2F32  2CF4 D2C2 5144 14B7 E8E6
uid                  testkey2 (testkey2) <test at vanheusden.com>
ssb   1024R/ED8059EA 2015-05-27

pub  rsa1024/14B7E8E6
     created: 2015-05-27  expires: never       usage: SC  
     trust: ultimate      validity: ultimate
sub  rsa1024/ED8059EA
     created: 2015-05-27  expires: never       usage: E   
sub  rsa1024/74D6F5C6
     created: 2015-05-31  expires: never       usage: S   

First I check if there's a private key for the key selected:

	gpgme_op_keylist_start(..., ..., 1);
	if (gpgme_op_keylist_nex() == GPG_ERR_NO_ERROR) { proceed }

do the signing:

	gpgme_new()
	gpgme_set_pinentry_mode(GPGME_PINENTRY_MODE_LOOPBACK) // yes i installed v2.1
	gpgme_set_passphrase_cb()
	/* ...binary to gpgme_data_t... */
	gpgme_data_set_encoding(GPGME_DATA_ENCODING_BINARY)
	gpgme_signers_clear()
	gpgme_signers_add()   // <- that key that I checked for existance earlier
	if (gpgme_signers_count() != 1) { fail(); } // sanity check
	gpgme_op_encrypt_sign(ctx, recipient, GPGME_ENCRYPT_ALWAYS_TRUST /* FIXME */, data_in, sig);

Now that gpgme_op_encrypt_sign always fails with that error I wrote
earlier.
Any tips/hints?

Software versions:
-----------------
gnupg 	 1.4.18-7
gnupg-agent 	 2.1.4-1
gnupg2 	 2.1.4-1
libgpgme++2 	 4:4.14.2-2+b1
libgpgme11:amd64 	 1.5.1-6
libgpgme11-dev 	 1.5.1-6
python-gnupginterface 	 0.3.2-9.1



Folkert van Heusden

-- 
MultiTail ist eine flexible Applikation um Logfiles und Kommando
Eingaben zu überprüfen. Inkl. Filter, Farben, Zusammenführen,
Ansichten etc. http://www.vanheusden.com/multitail/
----------------------------------------------------------------------
Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com



More information about the Gnupg-devel mailing list