[Gnuk-users] gnuk-users Digest, Vol 81, Issue 3

Srinivas V vsrinu26f at gmail.com
Thu Apr 6 13:29:31 UTC 2017


Hi All

Is there any Scd apdu command to change serial number of pgp applet. For yubikey 

Thank you
Srinivas

> On Apr 6, 2017, at 7:02 AM, gnuk-users-request at lists.alioth.debian.org wrote:
> 
> Send gnuk-users mailing list submissions to
>    gnuk-users at lists.alioth.debian.org
> 
> To subscribe or unsubscribe via the World Wide Web, visit
>    https://lists.alioth.debian.org/mailman/listinfo/gnuk-users
> or, via email, send a message with subject or body 'help' to
>    gnuk-users-request at lists.alioth.debian.org
> 
> You can reach the person managing the list at
>    gnuk-users-owner at lists.alioth.debian.org
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of gnuk-users digest..."
> 
> 
> Today's Topics:
> 
>   1. GnuK 1.2.1 locked Admin PW (Peter Lebbing)
>   2. Re: GnuK 1.2.1 locked Admin PW (NIIBE Yutaka)
>   3. Re: GnuK 1.2.1 locked Admin PW (Peter Lebbing)
> 
> 
> ----------------------------------------------------------------------
> 
> Message: 1
> Date: Wed, 5 Apr 2017 14:23:23 +0200
> From: Peter Lebbing <peter at digitalbrains.com>
> To: gnuk-users at lists.alioth.debian.org
> Subject: [Gnuk-users] GnuK 1.2.1 locked Admin PW
> Message-ID: <e9101bb4-21b5-7e59-c203-1cbfe08b8b3f at digitalbrains.com>
> Content-Type: text/plain; charset=utf-8
> 
> Hi all and especially NIIBE. I'm new on this list, but am a regular of
> GnuPG-Users.
> 
> At the OpenPGP Conference, I bought an FST-01 with GnuK 1.2.1.[1]. It
> had been collecting dust since then, and I reckoned it's better at
> collecting keys, so I tried to start using it.
> 
> I kept struggling with PINs, and now, completely weirdly, it stopped
> accepting my Admin PIN. Now it's locked.
> 
> How can I unlock it? I don't have a completely assembled SWD programmer
> yet. What I mean is, I have a TIAO USB Multi-Protocol Adapter v1. They
> added SWD support in v2. But it might be possible to coax this from v1
> as well with some wires or perhaps a transistor.
> 
> What are the different ways I could go about getting it to work again?
> 
> Finally, let me end in a loose account of how it went. Since I worked
> with actual PINs, I did not log stuff. I thought if it failed I could
> recreate later with fake PINs, but since I now locked it, I can't go any
> further.
> 
> I used:
>> $ gpg2 --version
>> gpg (GnuPG) 2.1.19
>> libgcrypt 1.7.6-beta
>> [...]
>> $ gpg-agent --version
>> gpg-agent (GnuPG) 2.1.19
>> libgcrypt 1.7.6-beta
>> [...]
>> $ /usr/lib/gnupg2/scdaemon --version
>> scdaemon (GnuPG) 2.1.19
>> libgcrypt 1.7.6-beta
>> libksba 1.3.5-unknown
>> [...]
> 
> I wanted separate user and admin PINs. So first I changed the Admin PIN.
> That worked. Then I changed the user PIN. For some reason, I couldn't
> use either the new or the old PIN, and I locked it. I tried to unblock
> using the Admin PIN and later also a Reset Code, but got "Condition of
> use not satisfied" (SW1/SW2 = 6985). Upon reading some source code, I
> figured out this was because I didn't have any keys. I don't know why
> this is a condition, but it is, so...
> 
> Here I encountered a nice catch-22. If I used --card-edit generate, it
> would prompt for my User PIN! Well, it's blocked, sorry about that. So
> no "generate" for me. I did --edit-key some-RSA-2048-test-key and
> "keytocard", so I now had a key on there. Hooray, I could change the PIN.
> 
> As an aside, I think this is a bit awkward. Want to unblock your PIN?
> Sure, generate some keys. Generate some keys? Please unblock your PIN
> first. This is pretty unfortunate and not a nice user experience. I can
> cope, I roll my eyes and do "keytocard", but somebody else might not
> know a way out. The basic issue is: *why* is GnuPG even asking for a
> user PIN? Section 7.2.13 of the OpenPGP Card Spec v3.0 says:
> 
>> The command can only be used after correct presentation of
>> PW3 for the generation of a key pair.
> 
> It says nothing about PW1 being needed.
> 
> Back to my issues. I got there, right? No. Any attempt to do something
> requiring the user PIN got me "PINs not synched" or similar message. I
> could not change the PINs. An unblock lead to "PINs not synched". As a
> final "let's try this then", I changed the Admin PIN without changing
> it. I typed my old PIN, and then my old PIN twice again.
> 
> At this point my Admin PIN was no longer accepted. Not having any other
> thing to try, I managed to exhaust my Admin PIN retry counter, and I now
> have the "Hello, World!" of hardware designs: a blinking LED.
> 
> In addition to the blinking LED, it also shows this:
> 
>> Reader ...........: 234B:0000:FSIJ-1.2.1-87061340:0
>> Application ID ...: D276000124010200FFFE870613400000
>> Version ..........: 2.0
>> Manufacturer .....: unmanaged S/N range
>> Serial number ....: 87061340
>> Name of cardholder: Peter Lebbing
>> Language prefs ...: en
>> Sex ..............: male
>> URL of public key : [not set]
>> Login data .......: [not set]
>> Signature PIN ....: not forced
>> Key attributes ...: rsa2048 rsa2048 rsa2048
>> Max. PIN lengths .: 127 127 127
>> PIN retry counter : 2 3 0
>> Signature counter : 0
>> Signature key ....: [none]
>> Encryption key....: 713F F089 6E52 73C8 7DD2  844F 1BD8 6BE8 3C3F 84D5
>>      created ....: 2016-12-05 11:12:51
>> Authentication key: [none]
> 
> 
> I'm considering buying a TIAO USB Multi-Protocol Adapter v2, so I can
> easily flash the firmware on the FST-01. But can this also be solved
> without an SWD interface?
> 
> Thanks,
> 
> Peter.
> 
> [1] I could not attend the talk by NIIBE unfortunately! Video captures
> were supposed to be released at some time, and I have poked Martin
> Schulte about this, but so far nothing has come forth. Again, unfortunately.
> 
> -- 
> I use the GNU Privacy Guard (GnuPG) in combination with Enigmail.
> You can send me encrypted mail if you want some privacy.
> My key is available at <http://digitalbrains.com/2012/openpgp-key-peter>
> 
> 
> 
> ------------------------------
> 
> Message: 2
> Date: Thu, 06 Apr 2017 10:07:39 +0900
> From: NIIBE Yutaka <gniibe at fsij.org>
> To: Peter Lebbing <peter at digitalbrains.com>,
>    gnuk-users at lists.alioth.debian.org
> Subject: Re: [Gnuk-users] GnuK 1.2.1 locked Admin PW
> Message-ID: <87efx61gys.fsf at iwagami.gniibe.org>
> Content-Type: text/plain
> 
> Hello,
> 
> I understand your frustration.  I'm sorry for that.
> 
>> I'm considering buying a TIAO USB Multi-Protocol Adapter v2, so I can
>> easily flash the firmware on the FST-01. But can this also be solved
>> without an SWD interface?
> 
> In Gnuk 1.2.2 and later, it supports "Factory Reset" command as a
> compile time option (for me, reluctantly).  So, this "Factory Reset" can
> be an option.  But, it is 1.2.1, unfortunately.
> 
> The reason I did reluctantly is that it might invite another risk of
> being stolen as a hardware (not as private key).
> 
> Peter Lebbing <peter at digitalbrains.com> wrote:
>> How can I unlock it? I don't have a completely assembled SWD programmer
>> yet. What I mean is, I have a TIAO USB Multi-Protocol Adapter v1. They
>> added SWD support in v2. But it might be possible to coax this from v1
>> as well with some wires or perhaps a transistor.
> 
> I think that if you have some experience with FTDI chip, you can use the
> v1 adapter with wires and resistors (no transistor), perhaps, by
> configuring OpenOCD.  Once, I used the configuration of FTDI chip in
> OpenOCD:
> 
>     openocd/tcl/interface/ftdi/swd-resistor-hack.cfg
> 
> But, I recommend using working tool at first.
> 
> FYI: what I use (and I ask the manufacturer) is my own tool of BBG-SWD.
> 
>    FST-01G Test Plan:
>    https://www.gniibe.org/memo/development/fst-01/fst-01g-testplan.html
> 
>> I wanted separate user and admin PINs. So first I changed the Admin PIN.
>> That worked. Then I changed the user PIN. For some reason, I couldn't
>> use either the new or the old PIN, and I locked it. I tried to unblock
>> using the Admin PIN and later also a Reset Code, but got "Condition of
>> use not satisfied" (SW1/SW2 = 6985). Upon reading some source code, I
>> figured out this was because I didn't have any keys. I don't know why
>> this is a condition, but it is, so...
> 
> I guess that original OpenPGP card implementation stores some
> information of user PIN in the card.  But for Gnuk, I try hard not to do
> so, to lower the risk of possible attack reading out the content of
> flash ROM.  Gnuk 1.2 does validation of user PIN by successful
> decryption of private key.
> 
>> Here I encountered a nice catch-22. If I used --card-edit generate, it
>> would prompt for my User PIN! Well, it's blocked, sorry about that. So
>> no "generate" for me. I did --edit-key some-RSA-2048-test-key and
>> "keytocard", so I now had a key on there. Hooray, I could change the PIN.
>> 
>> As an aside, I think this is a bit awkward. Want to unblock your PIN?
>> Sure, generate some keys. Generate some keys? Please unblock your PIN
>> first. This is pretty unfortunate and not a nice user experience. I can
>> cope, I roll my eyes and do "keytocard", but somebody else might not
>> know a way out. The basic issue is: *why* is GnuPG even asking for a
>> user PIN? Section 7.2.13 of the OpenPGP Card Spec v3.0 says:
>> 
>>> The command can only be used after correct presentation of
>>> PW3 for the generation of a key pair.
>> 
>> It says nothing about PW1 being needed.
> 
> I see your point.
> 
> I confirmed that GnuPG frontend asks PW1 when generating keys.  I can
> find the comment in g10/card-uti.c:
> 
>      /* Check the PIN now, so that we won't get asked later for each
>         binding signature. */
> 
> It doesn't match Gnuk Token, as Gnuk Token resets PIN at key generation.
> 
>> Back to my issues. I got there, right? No. Any attempt to do something
>> requiring the user PIN got me "PINs not synched" or similar message. I
>> could not change the PINs. An unblock lead to "PINs not synched". As a
>> final "let's try this then", I changed the Admin PIN without changing
>> it. I typed my old PIN, and then my old PIN twice again.
> 
> I don't understand this paragraph.  Could you please identify PINs by
> PIN-Admin-old, PIN-Admin-new, PIN-user-factory, PIN-user-0, etc.?
> 
>> In addition to the blinking LED, it also shows this:
>> 
>>> Reader ...........: 234B:0000:FSIJ-1.2.1-87061340:0
>>> Application ID ...: D276000124010200FFFE870613400000
>>> Version ..........: 2.0
>>> Manufacturer .....: unmanaged S/N range
>>> Serial number ....: 87061340
>>> Name of cardholder: Peter Lebbing
>>> Language prefs ...: en
>>> Sex ..............: male
>>> URL of public key : [not set]
>>> Login data .......: [not set]
>>> Signature PIN ....: not forced
>>> Key attributes ...: rsa2048 rsa2048 rsa2048
>>> Max. PIN lengths .: 127 127 127
>>> PIN retry counter : 2 3 0
>>> Signature counter : 0
>>> Signature key ....: [none]
>>> Encryption key....: 713F F089 6E52 73C8 7DD2  844F 1BD8 6BE8 3C3F 84D5
>>>      created ....: 2016-12-05 11:12:51
>>> Authentication key: [none]
> 
> I think that you can decrypt by the user PIN of factory setting
> "123456".
> -- 
> 
> 
> 
> ------------------------------
> 
> Message: 3
> Date: Thu, 6 Apr 2017 12:20:13 +0200
> From: Peter Lebbing <peter at digitalbrains.com>
> To: NIIBE Yutaka <gniibe at fsij.org>, gnuk-users at lists.alioth.debian.org
> Subject: Re: [Gnuk-users] GnuK 1.2.1 locked Admin PW
> Message-ID: <dffdd909-45d0-e71c-da7f-067139feb61c at digitalbrains.com>
> Content-Type: text/plain; charset="utf-8"
> 
>> On 06/04/17 03:07, NIIBE Yutaka wrote:
>> I understand your frustration.  I'm sorry for that.
> 
> Oh, I don't mind. The source of the frustration is probably largely that
> I'm well acquainted with the standard version of the OpenPGP card, and
> I'm stumbling on the slight differences that somebody else would never
> notice, probably :-).
> 
>> The reason I did reluctantly is that it might invite another risk of
>> being stolen as a hardware (not as private key).
> 
> You really look at things from all angles! I can appreciate that.
> 
>> But, I recommend using working tool at first.
> 
> Is there a risk of bricking the processor if an SWD interface fails? I'm
> not talking about me stupidly shorting wires, but I am talking about
> loose contacts or problems with the protocol.
> 
>> FYI: what I use (and I ask the manufacturer) is my own tool of BBG-SWD.
> 
> Thanks for the hint. I'm considering options, and this is definitely one
> of them.
> 
>> I guess that original OpenPGP card implementation stores some
>> information of user PIN in the card.  But for Gnuk, I try hard not to do
>> so, to lower the risk of possible attack reading out the content of
>> flash ROM.  Gnuk 1.2 does validation of user PIN by successful
>> decryption of private key.
> 
> I completely forgot! If I had remembered, my stumbling along would have
> been more focused. Silly me.
> 
>> I confirmed that GnuPG frontend asks PW1 when generating keys.  I can
>> find the comment in g10/card-uti.c:
>> 
>>      /* Check the PIN now, so that we won't get asked later for each
>>         binding signature. */
>> 
>> It doesn't match Gnuk Token, as Gnuk Token resets PIN at key generation.
> 
> Perhaps instead of failing to unblock a PIN without keys, GnuK should
> just reset the retry counters anyway, since the concept of a PIN without
> keys is meaningless anyway. That way, you could unblock without keys and
> the catch-22 would be resolved.
> 
>>> Back to my issues. I got there, right? No. Any attempt to do something
>>> requiring the user PIN got me "PINs not synched" or similar message. I
>>> could not change the PINs. An unblock lead to "PINs not synched". As a
>>> final "let's try this then", I changed the Admin PIN without changing
>>> it. I typed my old PIN, and then my old PIN twice again.
>> 
>> I don't understand this paragraph.  Could you please identify PINs by
>> PIN-Admin-old, PIN-Admin-new, PIN-user-factory, PIN-user-0, etc.?
> 
> Step 1:
> - Admin PIN set to PIN-Admin-0
> - No keys on card
> - PIN-User retry counter at 0 (blocked)
> Step 2: keytocard, with encryption key
> Step 3:
> - Unblock PIN-User using PIN-Admin-0
> - Set PIN-User to PIN-User-0
> Step 4:
> - Notice "PINs not synched" when trying to use PIN-User-0
> Step 5a:
> - Change PIN-User -> "PINs not synched" (I believe)
> Step 5b:
> - Unblock PIN-User using PIN-Admin-0
> - Set PIN-User to PIN-User-0
> 
> I'm not sure about the order of step 5a/5b, it could have been 5b/5a.
> Also, they were tried multiple times with the same failing results.
> 
> Step 6:
> - Change PIN-Admin (keeping it the same)
> - "Enter Admin PIN": PIN-Admin-0
> - "Enter new PIN": PIN-Admin-0
> - "Repeat new PIN": PIN-Admin-0
> 
> Step 7:
> - Catastrophe. PIN-Admin-0 no longer accepted. Retry counter quickly
> drops to 0, device locks.
> 
> Note that I did not fall in the trap that was discussed only recently on
> GnuPG-Users, where somebody thought the default Admin PIN was 123456789
> but this ended up with his new Admin PIN starting with an unexpected
> 9.[1] During, for example, keytocard, it was clear that Admin-PIN-0 was
> what I expected it to be!
> 
>> I think that you can decrypt by the user PIN of factory setting
>> "123456".
> 
> That doesn't seem to be the case...
> 
> ------------------8<-------->8------------------
> $ echo hoi | gpg2 -r 1BD86BE83C3F84D5 -e | gpg2 -d
> [...]
> gpg: public key decryption failed: Bad PIN
> gpg: decryption failed: No secret key
> ------------------8<-------->8------------------
> 
> Thanks,
> 
> Peter.
> 
> [1] I'm storing this mistake in the OpenPGP Card specification in my
> mind as a nice trap to avoid while designing a protocol. "The card knows
> the length of the PIN", that's cute, but the user does not, so it does
> you no good! It's a good learning experience.
> 
> -- 
> I use the GNU Privacy Guard (GnuPG) in combination with Enigmail.
> You can send me encrypted mail if you want some privacy.
> My key is available at <http://digitalbrains.com/2012/openpgp-key-peter>
> 
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: signature.asc
> Type: application/pgp-signature
> Size: 488 bytes
> Desc: OpenPGP digital signature
> URL: <http://lists.alioth.debian.org/pipermail/gnuk-users/attachments/20170406/856dcc09/attachment-0001.sig>
> 
> ------------------------------
> 
> Subject: Digest Footer
> 
> _______________________________________________
> gnuk-users mailing list
> gnuk-users at lists.alioth.debian.org
> https://lists.alioth.debian.org/mailman/listinfo/gnuk-users
> 
> 
> ------------------------------
> 
> End of gnuk-users Digest, Vol 81, Issue 3
> *****************************************



More information about the gnuk-users mailing list