Issues with primary key & subkeys on different smartcards

Paul R. Ramer free10pro at gmail.com
Sat Sep 7 09:45:28 CEST 2013


On 09/06/2013 03:08 PM, Pete Stephenson wrote:
> On Thu, Sep 5, 2013 at 8:35 PM, Pete Stephenson <pete at heypete.com> wrote:
> Quick followup: I was also able to create the correct private key with
> stubs pointing at both smartcards by loading the actual private keys
> onto the smartcard using "keytocard", as expected.
> 
> However, I'm unable to re-create this file starting only with the
> public key and running "gpg2 --card-status" for each card. It seems
> like running "gpg2 --card-status" for each card should be able to
> create the stubs, but if there's already a stub associated with a
> particular smartcard, then running "gpg2 --card-status" doesn't seem
> to have any effect other than to display the card info.
> 
> Put simply: running "gpg2 --card-status" will create one stub pointing
> at the card, but running that command again with a different card only
> displays the card info and doesn't add any additional stubs. This
> seems inconsistent and not what I would expect.

Hello Pete,

It seems that the keytocard command is the way to correctly load the
subkeys and primary key onto the smartcards.  I had not thought about
splitting the primary and subkeys across the two smartcards, but it
works quite easily by using the keytocard command.  I tested it to see
how it works, and I feel certain that the keytocard method that you used
is the correct way to do it.

For those who may be reading, I found loading one OpenPGP card with the
primary key and a second with the subkey to work as the following
example demonstrates:

$ gpg2 --edit-key Joe
gpg (GnuPG) 2.0.17; Copyright (C) 2011 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/123B9C22  created: 2013-09-07  expires: 2018-09-06  usage: SC
                     trust: ultimate      validity: ultimate
sub  2048R/972C7E79  created: 2013-09-07  expires: 2018-09-06  usage: E
[ultimate] (1). Joe <joe at example.com>

gpg> toggle

sec  2048R/123B9C22  created: 2013-09-07  expires: 2018-09-06
ssb  2048R/972C7E79  created: 2013-09-07  expires: never
(1)  Joe <joe at example.com>

gpg> keytocard
Really move the primary key? (y/N) y
Signature key ....: [none]
Encryption key....: [none]
Authentication key: [none]

Please select where to store the key:
   (1) Signature key
   (3) Authentication key
Your selection? 1

You need a passphrase to unlock the secret key for
user: "Joe <joe at example.com>"
2048-bit RSA key, ID 123B9C22, created 2013-09-07


sec  2048R/123B9C22  created: 2013-09-07  expires: 2018-09-06
                     card-no: 0005 DECAFBAD
ssb  2048R/972C7E79  created: 2013-09-07  expires: never
(1)  Joe <joe at example.com>

gpg> key 1

sec  2048R/123B9C22  created: 2013-09-07  expires: 2018-09-06
                     card-no: 0005 DECAFBAD
ssb* 2048R/972C7E79  created: 2013-09-07  expires: never
(1)  Joe <joe at example.com>

gpg> keytocard
Signature key ....: [none]
Encryption key....: [none]
Authentication key: [none]

Please select where to store the key:
   (2) Encryption key
Your selection? 2

You need a passphrase to unlock the secret key for
user: "Joe <joe at example.com>"
2048-bit RSA key, ID 972C7E79, created 2013-09-07


sec  2048R/123B9C22  created: 2013-09-07  expires: 2018-09-06
                     card-no: 0005 DECAFBAD
ssb* 2048R/972C7E79  created: 2013-09-07  expires: never
                     card-no: 0005 DEADBEEF
(1)  Joe <joe at example.com>

gpg> save

Now you are done, and the cards work great.  If you need either the
primary key or subkey, pinentry will prompt you to insert the
appropriate card.  The only thing is that if you need a backup of the
secret keys before moving them to the smartcards, you need to do that
before following the example above.

Anyway, Pete, thank you for bringing this subject up and experimenting
with it and helping make us all a little smarter.  I can't answer the
question as to whether it was designed to work that way, but I don't
feel there is any doubt.

Cheers,

--Paul

--
PGP: 0x3DB6D884
PGP Fingerprint: EBA7 88B3 6D98 2D4A E045  A9F7 C7C6 6ADF 3DB6 D884



More information about the Gnupg-users mailing list