Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenSC formatted Starcos 2.3 smartcard cannot be initialized #151

Closed
arges opened this issue Apr 8, 2013 · 7 comments
Closed

OpenSC formatted Starcos 2.3 smartcard cannot be initialized #151

arges opened this issue Apr 8, 2013 · 7 comments

Comments

@arges
Copy link

arges commented Apr 8, 2013

I've reported a regression against Ubuntu, but this bug is also present with
e8eb4cd.

The issue copied here is:

  • What happened
    Erasing and initializing a Starcos 2.3 smartcard returns the error:
    Error -1211: Security status not satisfied
  • Test case
    $ pkcs15-init -E
    $ pkcs15-init --create-pkcs15 --profile pkcs15+onepin --use-default-transport-key --pin 0000 --puk 111111 --label "Test"

I've bisected the issue with the OpenSC git project and found that the first bad commit is:
1d82e8a

Here is a link to the Launchpad bug:
https://bugs.launchpad.net/ubuntu/+source/opensc/+bug/1166500

pscs_scan output will be attached to the Launchpad bug.

Thanks,
--chris j arges

@arges
Copy link
Author

arges commented Apr 30, 2013

So I've done a bit more debugging and found out that the following diff makes the smartcard work:
--- a/src/libopensc/types.h
+++ b/src/libopensc/types.h
@@ -169,9 +169,9 @@ struct sc_crt {
#define SC_AC_OP_PIN_RESET 19
#define SC_AC_OP_ACTIVATE 20
#define SC_AC_OP_DEACTIVATE 21
-#define SC_AC_OP_READ 22
-#define SC_AC_OP_UPDATE 23
-#define SC_AC_OP_WRITE 24
+#define SC_AC_OP_READ 0
+#define SC_AC_OP_UPDATE 1
+#define SC_AC_OP_WRITE 3
#define SC_AC_OP_RESIZE 25
#define SC_AC_OP_GENERATE 26
#define SC_AC_OP_CREATE_EF 27

So the commit 1d82e8a changes the AC_OP numbers, and changing them back seemed to fix this regression.

@arges
Copy link
Author

arges commented Apr 30, 2013

It appears that just the WRITE variable needs to be changed to 3 to make this work.

@viktorTarasov
Copy link
Member

OpenSC has changed a lot from 0.12.2 to 0.13.0 .

Would be nice if you could reproduce your problem with the latest master and with maximal debug level.

@arges
Copy link
Author

arges commented May 7, 2013

I've already tested with the latest OpenSC from git as of e8eb4cd (1 month ago), and the problem still exists. I'll get maximal debug output from the latest git when I can and attach it here.

Like I mentioned before I was able to bisect the issue and it seems like changing SC_AC_OP_WRITE from 24 to 3, fixes the issue for this card, so looks like something specific with starcos code.

@arges
Copy link
Author

arges commented May 16, 2013

Log is attached here: https://launchpadlibrarian.net/140033445/opensc_log.txt

@frankmorgner
Copy link
Member

in 8ed4db7 SC_AC_OP_CREATE and SC_AC_OP_WRITE are defined as 3, which seems like an error. 1d82e8a fixes this in defining SC_AC_OP_WRITE to 24.

It looks like somewhere in pkcs15-init something is written where creation was missing beforehand. I don't have such a card, could you check with yours?

@frankmorgner
Copy link
Member

Please re-open the issue if it is still relevant or if you have news about possible fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants