Re: [opensc-devel] Problem with Gemplus GemXpresso Pro R3 E32 PK

2011-08-18 Thread Martin Paljak
Hello,

On Wed, Aug 17, 2011 at 23:39, Douglas E. Engert deeng...@anl.gov wrote:

 --- a/src/libopensc/card-gemsafeV1.c
 +++ b/src/libopensc/card-gemsafeV1.c
 @@ -172,6 +172,7 @@ static int gemsafe_init(struct sc_card *card)
         /* SELECT applet */
         r = gp_select_applet(card, exdata-aid, exdata-aid_len);
         if (r  0) {
 +               card-lock_count--;
                 free(exdata);
                 sc_debug(card-ctx, SC_LOG_DEBUG_NORMAL, applet selection 
 failed\n);
                 return SC_ERROR_INTERNAL;

sc_lock/sc_unlock should be used instead of direct modification.

Best,
Martin
___
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel

Re: [opensc-devel] Problem with Gemplus GemXpresso Pro R3 E32 PK

2011-08-18 Thread Douglas E. Engert


On 8/18/2011 9:26 AM, Martin Paljak wrote:
 Hello,

 On Wed, Aug 17, 2011 at 23:39, Douglas E. Engertdeeng...@anl.gov  wrote:

 --- a/src/libopensc/card-gemsafeV1.c
 +++ b/src/libopensc/card-gemsafeV1.c
 @@ -172,6 +172,7 @@ static int gemsafe_init(struct sc_card *card)
  /* SELECT applet */
  r = gp_select_applet(card, exdata-aid, exdata-aid_len);
  if (r  0) {
 +   card-lock_count--;
  free(exdata);
  sc_debug(card-ctx, SC_LOG_DEBUG_NORMAL, applet selection 
 failed\n);
  return SC_ERROR_INTERNAL;

 sc_lock/sc_unlock should be used instead of direct modification.

The patch was in the spirit of the current code, that already does
card-lock_count++; before this, and card-lock_count--; after this.

sc_lock/sc_unlock appears to be a better way. I don't know why it was
not used in the first place. I have no way to test this code, just
pointing out what appears to be the problem.


 Best,
 Martin



-- 

  Douglas E. Engert  deeng...@anl.gov
  Argonne National Laboratory
  9700 South Cass Avenue
  Argonne, Illinois  60439
  (630) 252-5444
___
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel


Re: [opensc-devel] Problem with Gemplus GemXpresso Pro R3 E32 PK

2011-08-18 Thread Martin Paljak
On 18/08/11 17:34, Douglas E. Engert wrote:

 The patch was in the spirit of the current code, that already does
 card-lock_count++; before this, and card-lock_count--; after this.
Ah, a good thing to grep for :)

Thanks,

Martin
___
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel


Re: [opensc-devel] Problem with Gemplus GemXpresso Pro R3 E32 PK

2011-08-17 Thread Marcelo Grassi F . Melgaço
Anyone ?

Em 15 de agosto de 2011 17:23, Marcelo Grassi F. Melgaço mgfra...@gmail.com
 escreveu:

 Hello,
 I have a Brazilian e-cnpj certisign certificate.
 The card is a Gemplus GemXpresso Pro R3 E32 PK.
 I'm trying to get this work in linux, but i'm having some errors.
 It works on windows.
 Can anyone help me?
 If you need aditional commands just ask me.

 Thanks a lot !

 Here is the output of the command:

 # pkcs15-tool --list-certificates -

 0x7f9422606720 13:39:54.725 [pkcs15-tool] sc.c:195:sc_detect_card_presence:
 called
 0x7f9422606720 13:39:54.725 [pkcs15-tool]
 reader-pcsc.c:364:pcsc_detect_card_presence: called
 0x7f9422606720 13:39:54.725 [pkcs15-tool]
 reader-pcsc.c:277:refresh_attributes: ACS ACR 38U-CCID 00 00 check
 0x7f9422606720 13:39:54.725 [pkcs15-tool]
 reader-pcsc.c:293:refresh_attributes: returning with: 0 (Success)
 0x7f9422606720 13:39:54.725 [pkcs15-tool]
 reader-pcsc.c:369:pcsc_detect_card_presence: returning with: 1
 0x7f9422606720 13:39:54.725 [pkcs15-tool] sc.c:200:sc_detect_card_presence:
 returning with: 1
 Using reader with a card: ACS ACR 38U-CCID 00 00
 0x7f9422606720 13:39:54.725 [pkcs15-tool] sc.c:195:sc_detect_card_presence:
 called
 0x7f9422606720 13:39:54.725 [pkcs15-tool]
 reader-pcsc.c:364:pcsc_detect_card_presence: called
 0x7f9422606720 13:39:54.725 [pkcs15-tool]
 reader-pcsc.c:277:refresh_attributes: ACS ACR 38U-CCID 00 00 check
 0x7f9422606720 13:39:54.725 [pkcs15-tool]
 reader-pcsc.c:293:refresh_attributes: returning with: 0 (Success)
 0x7f9422606720 13:39:54.725 [pkcs15-tool]
 reader-pcsc.c:369:pcsc_detect_card_presence: returning with: 1
 0x7f9422606720 13:39:54.725 [pkcs15-tool] sc.c:200:sc_detect_card_presence:
 returning with: 1
 Connecting to card in reader ACS ACR 38U-CCID 00 00...
 0x7f9422606720 13:39:54.725 [pkcs15-tool] card.c:115:sc_connect_card:
 called
 0x7f9422606720 13:39:54.725 [pkcs15-tool] reader-pcsc.c:444:pcsc_connect:
 called
 0x7f9422606720 13:39:54.725 [pkcs15-tool]
 reader-pcsc.c:277:refresh_attributes: ACS ACR 38U-CCID 00 00 check
 0x7f9422606720 13:39:54.725 [pkcs15-tool]
 reader-pcsc.c:293:refresh_attributes: returning with: 0 (Success)
 0x7f9422606720 13:39:54.728 [pkcs15-tool] reader-pcsc.c:473:pcsc_connect:
 Initial protocol: T=0
 0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:829:match_atr_table:
 ATR : 3b:7a:94:00:00:80:65:a2:01:01:01:3d:72:d6:43
 0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:840:match_atr_table: ATR
 try : 3b:6e:00:ff:45:73:74:45:49:44:20:76:65:72:20:31:2e:30
 0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:843:match_atr_table:
 ignored - wrong length
 0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:840:match_atr_table: ATR
 try :
 3b:fe:94:00:ff:80:b1:fa:45:1f:03:45:73:74:45:49:44:20:76:65:72:20:31:2e:30:43
 0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:843:match_atr_table:
 ignored - wrong length
 0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:840:match_atr_table: ATR
 try : 3b:5e:11:ff:45:73:74:45:49:44:20:76:65:72:20:31:2e:30
 0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:843:match_atr_table:
 ignored - wrong length
 0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:840:match_atr_table: ATR
 try :
 3b:de:18:ff:c0:80:b1:fe:45:1f:03:45:73:74:45:49:44:20:76:65:72:20:31:2e:30:2b
 0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:843:match_atr_table:
 ignored - wrong length
 0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:840:match_atr_table: ATR
 try : 3b:6e:00:00:45:73:74:45:49:44:20:76:65:72:20:31:2e:30
 0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:843:match_atr_table:
 ignored - wrong length
 0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:840:match_atr_table: ATR
 try :
 3b:fe:18:00:00:80:31:fe:45:45:73:74:45:49:44:20:76:65:72:20:31:2e:30:a8
 0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:843:match_atr_table:
 ignored - wrong length
 0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:840:match_atr_table: ATR
 try :
 3b:fe:18:00:00:80:31:fe:45:80:31:80:66:40:90:a4:56:1b:16:83:01:90:00:86
 0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:843:match_atr_table:
 ignored - wrong length
 0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:840:match_atr_table: ATR
 try :
 3b:fe:18:00:00:80:31:fe:45:80:31:80:66:40:90:a4:16:2a:00:83:01:90:00:e1
 0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:843:match_atr_table:
 ignored - wrong length
 0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:840:match_atr_table: ATR
 try :
 3b:fe:18:00:00:80:31:fe:45:80:31:80:66:40:90:a4:16:2a:00:83:0f:90:00:ef
 0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:843:match_atr_table:
 ignored - wrong length
 0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:840:match_atr_table: ATR
 try :
 3b:ff:94:00:ff:80:b1:fe:45:1f:03:00:68:d2:76:00:00:28:ff:05:1e:31:80:00:90:00:23
 0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:843:match_atr_table:
 ignored - wrong length
 0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:840:match_atr_table: ATR
 try :
 

Re: [opensc-devel] Problem with Gemplus GemXpresso Pro R3 E32 PK

2011-08-17 Thread Douglas E. Engert


On 8/17/2011 3:00 PM, Marcelo Grassi F. Melgaço wrote:
 Anyone ?

 Em 15 de agosto de 2011 17:23, Marcelo Grassi F. Melgaço mgfra...@gmail.com 
 mailto:mgfra...@gmail.com escreveu:

 Hello,
 I have a Brazilian e-cnpj certisign certificate.
 The card is a Gemplus GemXpresso Pro R3 E32 PK.
 I'm trying to get this work in linux, but i'm having some errors.
 It works on windows.

Are you using OpenSC on Windows, or the vendors windows drivers?


 Can anyone help me?
 If you need aditional commands just ask me.

It looks like the card-gemsafeV1.c is looking for an Application ID on the card,
and did not find it. So this may require additional code in the driver.
There was code added to support a Portuguese eID cards.

There is also code to search opensc.conf for a card gemsafeV1 section
to get the aid (I am not sure what you would have to add.)


It looks like there is also a bug.

In card-gemsafeV1.c the card-lock_count is incremented,
but if the gp_select_applet fails, the count is not decremented,
which then causes in card.c in sc_disconnect_card
 assert(card-lock_count == 0);
to fail with a -1400 (Internal error)


diff --git a/src/libopensc/card-gemsafeV1.c b/src/libopensc/card-gemsafeV1.c
index 03c8ca3..8cc3a17 100644
--- a/src/libopensc/card-gemsafeV1.c
+++ b/src/libopensc/card-gemsafeV1.c
@@ -172,6 +172,7 @@ static int gemsafe_init(struct sc_card *card)
 /* SELECT applet */
 r = gp_select_applet(card, exdata-aid, exdata-aid_len);
 if (r  0) {
+   card-lock_count--;
 free(exdata);
 sc_debug(card-ctx, SC_LOG_DEBUG_NORMAL, applet selection 
failed\n);
 return SC_ERROR_INTERNAL;



 Thanks a lot !

 Here is the output of the command:

 # pkcs15-tool --list-certificates -

 0x7f9422606720 13:39:54.725 [pkcs15-tool] 
 sc.c:195:sc_detect_card_presence: called
 0x7f9422606720 13:39:54.725 [pkcs15-tool] 
 reader-pcsc.c:364:pcsc_detect_card_presence: called
 0x7f9422606720 13:39:54.725 [pkcs15-tool] 
 reader-pcsc.c:277:refresh_attributes: ACS ACR 38U-CCID 00 00 check
 0x7f9422606720 13:39:54.725 [pkcs15-tool] 
 reader-pcsc.c:293:refresh_attributes: returning with: 0 (Success)
 0x7f9422606720 13:39:54.725 [pkcs15-tool] 
 reader-pcsc.c:369:pcsc_detect_card_presence: returning with: 1
 0x7f9422606720 13:39:54.725 [pkcs15-tool] 
 sc.c:200:sc_detect_card_presence: returning with: 1
 Using reader with a card: ACS ACR 38U-CCID 00 00
 0x7f9422606720 13:39:54.725 [pkcs15-tool] 
 sc.c:195:sc_detect_card_presence: called
 0x7f9422606720 13:39:54.725 [pkcs15-tool] 
 reader-pcsc.c:364:pcsc_detect_card_presence: called
 0x7f9422606720 13:39:54.725 [pkcs15-tool] 
 reader-pcsc.c:277:refresh_attributes: ACS ACR 38U-CCID 00 00 check
 0x7f9422606720 13:39:54.725 [pkcs15-tool] 
 reader-pcsc.c:293:refresh_attributes: returning with: 0 (Success)
 0x7f9422606720 13:39:54.725 [pkcs15-tool] 
 reader-pcsc.c:369:pcsc_detect_card_presence: returning with: 1
 0x7f9422606720 13:39:54.725 [pkcs15-tool] 
 sc.c:200:sc_detect_card_presence: returning with: 1
 Connecting to card in reader ACS ACR 38U-CCID 00 00...
 0x7f9422606720 13:39:54.725 [pkcs15-tool] card.c:115:sc_connect_card: 
 called
 0x7f9422606720 13:39:54.725 [pkcs15-tool] reader-pcsc.c:444:pcsc_connect: 
 called
 0x7f9422606720 13:39:54.725 [pkcs15-tool] 
 reader-pcsc.c:277:refresh_attributes: ACS ACR 38U-CCID 00 00 check
 0x7f9422606720 13:39:54.725 [pkcs15-tool] 
 reader-pcsc.c:293:refresh_attributes: returning with: 0 (Success)
 0x7f9422606720 13:39:54.728 [pkcs15-tool] reader-pcsc.c:473:pcsc_connect: 
 Initial protocol: T=0
 0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:829:match_atr_table: ATR 
 : 3b:7a:94:00:00:80:65:a2:01:01:01:3d:72:d6:43
 0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:840:match_atr_table: ATR 
 try : 3b:6e:00:ff:45:73:74:45:49:44:20:76:65:72:20:31:2e:30
 0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:843:match_atr_table: 
 ignored - wrong length
 0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:840:match_atr_table: ATR 
 try : 
 3b:fe:94:00:ff:80:b1:fa:45:1f:03:45:73:74:45:49:44:20:76:65:72:20:31:2e:30:43
 0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:843:match_atr_table: 
 ignored - wrong length
 0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:840:match_atr_table: ATR 
 try : 3b:5e:11:ff:45:73:74:45:49:44:20:76:65:72:20:31:2e:30
 0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:843:match_atr_table: 
 ignored - wrong length
 0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:840:match_atr_table: ATR 
 try : 
 3b:de:18:ff:c0:80:b1:fe:45:1f:03:45:73:74:45:49:44:20:76:65:72:20:31:2e:30:2b
 0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:843:match_atr_table: 
 ignored - wrong length
 0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:840:match_atr_table: ATR 
 try : 

[opensc-devel] Problem with Gemplus GemXpresso Pro R3 E32 PK

2011-08-15 Thread Marcelo Grassi F . Melgaço
Hello,
I have a Brazilian e-cnpj certisign certificate.
The card is a Gemplus GemXpresso Pro R3 E32 PK.
I'm trying to get this work in linux, but i'm having some errors.
It works on windows.
Can anyone help me?
If you need aditional commands just ask me.

Thanks a lot !

Here is the output of the command:

# pkcs15-tool --list-certificates -

0x7f9422606720 13:39:54.725 [pkcs15-tool] sc.c:195:sc_detect_card_presence:
called
0x7f9422606720 13:39:54.725 [pkcs15-tool]
reader-pcsc.c:364:pcsc_detect_card_presence: called
0x7f9422606720 13:39:54.725 [pkcs15-tool]
reader-pcsc.c:277:refresh_attributes: ACS ACR 38U-CCID 00 00 check
0x7f9422606720 13:39:54.725 [pkcs15-tool]
reader-pcsc.c:293:refresh_attributes: returning with: 0 (Success)
0x7f9422606720 13:39:54.725 [pkcs15-tool]
reader-pcsc.c:369:pcsc_detect_card_presence: returning with: 1
0x7f9422606720 13:39:54.725 [pkcs15-tool] sc.c:200:sc_detect_card_presence:
returning with: 1
Using reader with a card: ACS ACR 38U-CCID 00 00
0x7f9422606720 13:39:54.725 [pkcs15-tool] sc.c:195:sc_detect_card_presence:
called
0x7f9422606720 13:39:54.725 [pkcs15-tool]
reader-pcsc.c:364:pcsc_detect_card_presence: called
0x7f9422606720 13:39:54.725 [pkcs15-tool]
reader-pcsc.c:277:refresh_attributes: ACS ACR 38U-CCID 00 00 check
0x7f9422606720 13:39:54.725 [pkcs15-tool]
reader-pcsc.c:293:refresh_attributes: returning with: 0 (Success)
0x7f9422606720 13:39:54.725 [pkcs15-tool]
reader-pcsc.c:369:pcsc_detect_card_presence: returning with: 1
0x7f9422606720 13:39:54.725 [pkcs15-tool] sc.c:200:sc_detect_card_presence:
returning with: 1
Connecting to card in reader ACS ACR 38U-CCID 00 00...
0x7f9422606720 13:39:54.725 [pkcs15-tool] card.c:115:sc_connect_card: called
0x7f9422606720 13:39:54.725 [pkcs15-tool] reader-pcsc.c:444:pcsc_connect:
called
0x7f9422606720 13:39:54.725 [pkcs15-tool]
reader-pcsc.c:277:refresh_attributes: ACS ACR 38U-CCID 00 00 check
0x7f9422606720 13:39:54.725 [pkcs15-tool]
reader-pcsc.c:293:refresh_attributes: returning with: 0 (Success)
0x7f9422606720 13:39:54.728 [pkcs15-tool] reader-pcsc.c:473:pcsc_connect:
Initial protocol: T=0
0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:829:match_atr_table:
ATR : 3b:7a:94:00:00:80:65:a2:01:01:01:3d:72:d6:43
0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:840:match_atr_table: ATR
try : 3b:6e:00:ff:45:73:74:45:49:44:20:76:65:72:20:31:2e:30
0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:843:match_atr_table:
ignored - wrong length
0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:840:match_atr_table: ATR
try :
3b:fe:94:00:ff:80:b1:fa:45:1f:03:45:73:74:45:49:44:20:76:65:72:20:31:2e:30:43
0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:843:match_atr_table:
ignored - wrong length
0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:840:match_atr_table: ATR
try : 3b:5e:11:ff:45:73:74:45:49:44:20:76:65:72:20:31:2e:30
0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:843:match_atr_table:
ignored - wrong length
0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:840:match_atr_table: ATR
try :
3b:de:18:ff:c0:80:b1:fe:45:1f:03:45:73:74:45:49:44:20:76:65:72:20:31:2e:30:2b
0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:843:match_atr_table:
ignored - wrong length
0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:840:match_atr_table: ATR
try : 3b:6e:00:00:45:73:74:45:49:44:20:76:65:72:20:31:2e:30
0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:843:match_atr_table:
ignored - wrong length
0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:840:match_atr_table: ATR
try :
3b:fe:18:00:00:80:31:fe:45:45:73:74:45:49:44:20:76:65:72:20:31:2e:30:a8
0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:843:match_atr_table:
ignored - wrong length
0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:840:match_atr_table: ATR
try :
3b:fe:18:00:00:80:31:fe:45:80:31:80:66:40:90:a4:56:1b:16:83:01:90:00:86
0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:843:match_atr_table:
ignored - wrong length
0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:840:match_atr_table: ATR
try :
3b:fe:18:00:00:80:31:fe:45:80:31:80:66:40:90:a4:16:2a:00:83:01:90:00:e1
0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:843:match_atr_table:
ignored - wrong length
0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:840:match_atr_table: ATR
try :
3b:fe:18:00:00:80:31:fe:45:80:31:80:66:40:90:a4:16:2a:00:83:0f:90:00:ef
0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:843:match_atr_table:
ignored - wrong length
0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:840:match_atr_table: ATR
try :
3b:ff:94:00:ff:80:b1:fe:45:1f:03:00:68:d2:76:00:00:28:ff:05:1e:31:80:00:90:00:23
0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:843:match_atr_table:
ignored - wrong length
0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:840:match_atr_table: ATR
try :
3b:ff:11:00:ff:80:b1:fe:45:1f:03:00:68:d2:76:00:00:28:ff:05:1e:31:80:00:90:00:a6
0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:843:match_atr_table:
ignored - wrong length
0x7f9422606720 13:39:54.728 [pkcs15-tool] card.c:829:match_atr_table:
ATR :