[PATCH] scd: correct length for RSA public key response

Werner Koch wk at gnupg.org
Sun Aug 27 16:37:03 CEST 2017


On Fri, 25 Aug 2017 13:23, arnaud.fontaine at ssi.gouv.fr said:
> For example, with an exponent of 17 bits (e.g. 0x010001 which is
> commonly used on smartcards), 3 bytes are needed to encode it, not 2.

Sure,  I just wondered why it seemed to work in the past.

> Actually, when the incorrect expected response length (i.e. Le field) is
> transmitted to the card, the card's answer is missing a byte (i.e. ...
> 6101) so an additional command has to be sent to the card to retrieve
> the last byte. Using the correct length avoids to send the additional

Okay, that explains it.

>>> -    + 2 /* tag+len */ + app->app_local->keyattr[keyno].rsa.e_bits/8;
>>> +    + 2 /* tag+len */ + (app->app_local->keyattr[keyno].rsa.e_bits + 7)/8;

Also odd lengths are not that common for N, I will do the same for
N_BITS too.

Thanks for figuring this out.


Shalom-Salam,

   Werner

-- 
Die Gedanken sind frei.  Ausnahmen regelt ein Bundesgesetz.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 227 bytes
Desc: not available
URL: </pipermail/attachments/20170827/d831261a/attachment-0001.sig>


More information about the Gnupg-devel mailing list