scd: change_keyattr_from_string for ECC.

Achim Pietig achim at
Mon Jul 20 15:36:33 CEST 2015

Hi all,

I had no time to answer earlier, here noe some suggestions...


Am 18.07.2015 um 04:25 schrieb NIIBE Yutaka:
> Hello,
> This message is Cc-ed to gnupg-devel.
> I'm going to implement changing key attribute by scdaemon of GnuPG.
> For the existing OpenPGPcard implementation (of v2.0), GnuPG only
> partially supports changing the key attribute.  That is, it only
> changes the length of key for RSA.  To do so, scdaemon asks the card
> about key attribute DO, changes the bit, and sends back it to the
> card.
> Now, it will be expected to change the attribute fully for ECC.
> On 07/17/2015 01:07 PM, NIIBE Yutaka wrote:
>> With OpenPGPcard version 3.0, it is possible to change key attribute.
> [...]
>> $ gpg-connect-agent "SCD SETATTR KEY-ATTR --force 1 19 nistp256" /bye
>> $ gpg-connect-agent "SCD SETATTR KEY-ATTR --force 2 18 nistp256" /bye
>> $ gpg-connect-agent "SCD SETATTR KEY-ATTR --force 3 22 ed25519" /bye
The card may support only one version of the specified algorithms - this may vary from maufacturer to manufacturer (developer).
Actual we did not define a feature list that shows all possibilities, but i think this is not important.
If a user wll change the default values he should reset the card, change the algo-attributes and then pass it to GnuPG to adminstrate the keys etc.
To change the values a developer/manufacturer should suppliy a special tool that knows the card features - it is enough that GnuPG deals with the results.
Changing these values will not happen very often and it is an optional feature.

> While this (change to ECC) works, I wonder how we could implement
> changing back to RSA from ECC.
See abouve, there should be a separete tool from the card vendor that can handle the card features...

> For RSA, the last byte of key attribute specifies the format of RSA
> key.
> There is no information in the host about the format of RSA of the
> card, when its key attribute is ECC.  I think that it would be not
> good for host to try all possible cases until it successes.  Also, it
> would not be good to detect manufacturer and change the behavior.
No - it's no good idea to try every possible values - a special tool for teh specific card should do thus.
Otherwise we need a feature list in the card that presents all possiblilties.

> It would be cleaner if host could just compose the value of '00' for
> the RSA format specifier and send this DO for the key attribute, and
> it's up to the card to change the value accordingly.
In my implementation the card rejects wrong entries during PUT DATA, but this is a feature abd there may be implementations that do not (in ISO the values in a PUT DATA are transparent to the card).

> I'm afraid if it conforms ISO 7816 or card things.
Yes, ISO is weak in that matter - but you can implement additional things and provide special tools for that.
A generic software like GnuPG is not able to support all variants at the moment.

More information about the Gnupg-devel mailing list