gpgme and keys on smartcards

Hendrik Jaeger gnupg-users at
Fri Sep 21 12:50:53 CEST 2012


I am trying to replace my "old" keypair with one stored on a smartcard.
I have a SCM SPR-332 (reader with pinpad), which seems to work fine
with gpg. I can list the cards’ contents, create signatures and I’m
asked to enter the pin on the pinpad:

% gpg -u '3352C710!' -b -a gpgsign.c.old
-- I’m asked to enter the pin on the pinpad and do that
% gpg --verify gpgsign.c.old.asc 
gpg: Signature made Fre 21 Sep 2012 12:34:52 CEST using RSA key ID
gpg: Good signature from "Hendrik Niklas Jäger <henk at>"
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the
Primary key fingerprint: C899 4C00 FC3E 8048 4A06  AE7D F562 C121 DC25
Subkey fingerprint: 2CE9 418C 8088 A1A2 0B8D  0FE6 861F B11E 3352 C710

3352C710 is the keyid of my signing subkey on the card:

% gpg --list-secret-keys
sec   1024D/9914042F 2004-02-27
uid                  Hendrik Jaeger <hendrik_jaeger at>
uid                  Hendrik Jaeger <hank84 at>
uid                  Hendrik Jaeger <hank at>
uid                  Hendrik Jaeger <hank at>
uid                  Hendrik Jaeger <henk at>
uid                  Hendrik Jaeger <hendrik.jaeger at>
uid                  Hendrik Jaeger <henk at>
uid                  Hendrik Jaeger <hendrikjaeger at>
ssb   1024g/F22214D5 2004-02-27

sec#  2048R/DC256ED6 2012-08-23
uid                  Hendrik Niklas Jäger <henk at>
ssb>  2048R/3352C710 2012-08-29
ssb>  2048R/769C5F55 2012-08-29
ssb>  2048R/E091D806 2012-08-29

% gpg --edit-key dc256ed6
gpg (GnuPG) 1.4.12; Copyright (C) 2012 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Secret key is available.

pub  2048R/DC256ED6  created: 2012-08-23  expires: never       usage:
SC trust: unknown       validity: unknown sub  2048R/3352C710  created:
2012-08-29  expires: 2013-08-29  usage: S
sub  2048R/769C5F55  created: 2012-08-29  expires: 2013-08-29  usage: E
sub  2048R/E091D806  created: 2012-08-29  expires: 2013-08-29  usage: S
[ unknown] (1). Hendrik Niklas Jäger <henk at>

So far everything is good.
The problems seem to start when gpgme gets involved. I noticed problems
when trying to use the new key on the card for mail-signing in
claws-mail and status-signing in psi, which both use gpgme.
I was pointed to
for a simple signing tool using gpgme. I adjusted it a little to allow
specifying the keyid to use, both versions are found on
The diff looks like this:
% diff gpgsign.c.old gpgsign.c
>     gpgme_key_t secret_key;
>     // Find key to use
>     err = gpgme_get_key(ctx, keyID, &secret_key, 1);
>     fail_if_err (err);
>     // Adding found key to signers
>     err = gpgme_signers_add(ctx, secret_key);
>     fail_if_err (err);

(I have almost no experience with C or GPGME, so I’d appreciate any
advice on how to make that any better!)
It does not seem to work for my new key though:

% ./gpgsign 9914042f 'test test test'
Signing "test test test" with key 9914042f
Hash: SHA1

test test test
Version: GnuPG v1.4.12 (GNU/Linux)


Signature made with Key: 50F8BC65295CF4368BC9A3BAE4F3BFCA9914042F
Created: 1348224197; Expires 0
Validity: unknown; Signature Status: GOOD

% ./gpgsign dc256ed6 'test test test'
Signing "test test test" with key dc256ed6
Hash: SHA256

test test test

gpgsign.c:153: GPGME: No data

I have absolutely no idea why that is happening or how to get it
working properly. Am I doing something obvious wrong?
What other information should I provide?
Has anyone experienced similar problems and got them solved?

Thank you for reading and any comments!

Best regards

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: </pipermail/attachments/20120921/c736554f/attachment-0001.pgp>

More information about the Gnupg-users mailing list