diff mbox

[v2,5/8] usb-ccid: Fix USB descriptor

Message ID 1500541371-24788-6-git-send-email-sf@sfritsch.de
State New
Headers show

Commit Message

Stefan Fritsch July 20, 2017, 9:02 a.m. UTC
From: Stefan Fritsch <stefan_fritsch@genua.de>

- We want to support both T=0 and T=1. Additionally, note that all
  fields in USB descriptors are little endian and the supported
  protocols are in the lowest byte the of the 32-Bit dwProtocols field.
- We want APDU level exchanges. This saves us from PPS exchanges and from
  APDU reassembly from T=1 packets.

Signed-off-by: Stefan Fritsch <stefan_fritsch@genua.de>
Signed-off-by: Christian Ehrhardt <christian_ehrhardt@genua.de>
---
 hw/usb/dev-smartcard-reader.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Marc-André Lureau July 20, 2017, 9:44 a.m. UTC | #1
On Thu, Jul 20, 2017 at 11:09 AM Stefan Fritsch <sf@sfritsch.de> wrote:

> From: Stefan Fritsch <stefan_fritsch@genua.de>
>
> - We want to support both T=0 and T=1. Additionally, note that all
>   fields in USB descriptors are little endian and the supported
>   protocols are in the lowest byte the of the 32-Bit dwProtocols field.
> - We want APDU level exchanges. This saves us from PPS exchanges and from
>   APDU reassembly from T=1 packets.
>
>
Did you test this with various versions of Windows?


> Signed-off-by: Stefan Fritsch <stefan_fritsch@genua.de>
> Signed-off-by: Christian Ehrhardt <christian_ehrhardt@genua.de>
> ---
>  hw/usb/dev-smartcard-reader.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c
> index 769949144b..bc4dc35d3f 100644
> --- a/hw/usb/dev-smartcard-reader.c
> +++ b/hw/usb/dev-smartcard-reader.c
> @@ -353,8 +353,8 @@ static const uint8_t qemu_ccid_descriptor[] = {
>                       */
>          0x07,       /* u8  bVoltageSupport; 01h - 5.0v, 02h - 3.0, 03 -
> 1.8 */
>
> -        0x00, 0x00, /* u32 dwProtocols; RRRR PPPP. RRRR = 0000h.*/
> -        0x01, 0x00, /* PPPP: 0001h = Protocol T=0, 0002h = Protocol T=1 */
> +        0x03, 0x00, /* u32 dwProtocols; RRRR PPPP. RRRR = 0000h.*/
> +        0x00, 0x00, /* PPPP: 0001h = Protocol T=0, 0002h = Protocol T=1 */
>                      /* u32 dwDefaultClock; in kHZ (0x0fa0 is 4 MHz) */
>          0xa0, 0x0f, 0x00, 0x00,
>                      /* u32 dwMaximumClock; */
> @@ -397,7 +397,7 @@ static const uint8_t qemu_ccid_descriptor[] = {
>                       * insertion and removal. Must set bit 5 in
> bmAttributes
>                       * in Configuration descriptor if 100000 is set.
>                       */
> -        0xfe, 0x04, 0x01, 0x00,
> +        0xfe, 0x04, 0x04, 0x00,
>                      /*
>                       * u32 dwMaxCCIDMessageLength; For extended APDU in
>                       * [261 + 10 , 65544 + 10]. Otherwise the minimum is
> --
> 2.11.0
>
>
> --
Marc-André Lureau
Stefan Fritsch July 20, 2017, 12:16 p.m. UTC | #2
On Thu, 20 Jul 2017, Marc-André Lureau wrote:

> On Thu, Jul 20, 2017 at 11:09 AM Stefan Fritsch <sf@sfritsch.de> wrote:
> 
> > From: Stefan Fritsch <stefan_fritsch@genua.de>
> >
> > - We want to support both T=0 and T=1. Additionally, note that all
> >   fields in USB descriptors are little endian and the supported
> >   protocols are in the lowest byte the of the 32-Bit dwProtocols field.
> > - We want APDU level exchanges. This saves us from PPS exchanges and from
> >   APDU reassembly from T=1 packets.
> >
> >
> Did you test this with various versions of Windows?

Yes, we have tested that with windows 7, windows 10 and ubuntu 16.04 as 
guests.

> 
> 
> > Signed-off-by: Stefan Fritsch <stefan_fritsch@genua.de>
> > Signed-off-by: Christian Ehrhardt <christian_ehrhardt@genua.de>
> > ---
> >  hw/usb/dev-smartcard-reader.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c
> > index 769949144b..bc4dc35d3f 100644
> > --- a/hw/usb/dev-smartcard-reader.c
> > +++ b/hw/usb/dev-smartcard-reader.c
> > @@ -353,8 +353,8 @@ static const uint8_t qemu_ccid_descriptor[] = {
> >                       */
> >          0x07,       /* u8  bVoltageSupport; 01h - 5.0v, 02h - 3.0, 03 -
> > 1.8 */
> >
> > -        0x00, 0x00, /* u32 dwProtocols; RRRR PPPP. RRRR = 0000h.*/
> > -        0x01, 0x00, /* PPPP: 0001h = Protocol T=0, 0002h = Protocol T=1 */
> > +        0x03, 0x00, /* u32 dwProtocols; RRRR PPPP. RRRR = 0000h.*/
> > +        0x00, 0x00, /* PPPP: 0001h = Protocol T=0, 0002h = Protocol T=1 */
> >                      /* u32 dwDefaultClock; in kHZ (0x0fa0 is 4 MHz) */
> >          0xa0, 0x0f, 0x00, 0x00,
> >                      /* u32 dwMaximumClock; */
> > @@ -397,7 +397,7 @@ static const uint8_t qemu_ccid_descriptor[] = {
> >                       * insertion and removal. Must set bit 5 in
> > bmAttributes
> >                       * in Configuration descriptor if 100000 is set.
> >                       */
> > -        0xfe, 0x04, 0x01, 0x00,
> > +        0xfe, 0x04, 0x04, 0x00,
> >                      /*
> >                       * u32 dwMaxCCIDMessageLength; For extended APDU in
> >                       * [261 + 10 , 65544 + 10]. Otherwise the minimum is
> > --
> > 2.11.0
> >
> >
> > --
> Marc-André Lureau
>
diff mbox

Patch

diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c
index 769949144b..bc4dc35d3f 100644
--- a/hw/usb/dev-smartcard-reader.c
+++ b/hw/usb/dev-smartcard-reader.c
@@ -353,8 +353,8 @@  static const uint8_t qemu_ccid_descriptor[] = {
                      */
         0x07,       /* u8  bVoltageSupport; 01h - 5.0v, 02h - 3.0, 03 - 1.8 */
 
-        0x00, 0x00, /* u32 dwProtocols; RRRR PPPP. RRRR = 0000h.*/
-        0x01, 0x00, /* PPPP: 0001h = Protocol T=0, 0002h = Protocol T=1 */
+        0x03, 0x00, /* u32 dwProtocols; RRRR PPPP. RRRR = 0000h.*/
+        0x00, 0x00, /* PPPP: 0001h = Protocol T=0, 0002h = Protocol T=1 */
                     /* u32 dwDefaultClock; in kHZ (0x0fa0 is 4 MHz) */
         0xa0, 0x0f, 0x00, 0x00,
                     /* u32 dwMaximumClock; */
@@ -397,7 +397,7 @@  static const uint8_t qemu_ccid_descriptor[] = {
                      * insertion and removal. Must set bit 5 in bmAttributes
                      * in Configuration descriptor if 100000 is set.
                      */
-        0xfe, 0x04, 0x01, 0x00,
+        0xfe, 0x04, 0x04, 0x00,
                     /*
                      * u32 dwMaxCCIDMessageLength; For extended APDU in
                      * [261 + 10 , 65544 + 10]. Otherwise the minimum is