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

I already help riham recover copyright infomation #134

Conversation

entersafe
Copy link
Contributor

Hello, can someone help to check? Thx!

LudovicRousseau and others added 2 commits December 10, 2012 02:12
…0121209

pkcs15-tool: initialize 'opt_auth_id' consistently.
…ng with a error pin 2.Force the xxx_pin_cmd() returned with the tries_left while a failure authentication occurred 3.Modified author contact infomation
@JenkinsForOpenSC
Copy link

Can one of the admins verify this patch?

@martinpaljak
Copy link
Member

If I recall correctly, a lawyer in copyright/GPL matters suggested to only accept code with copyright claims by human beings, not legal entities (companies), at least in/for EU, for reasons I unfortunately don't remember.

int ret = get_external_key_retries(card, 0x80 | kid, &retries);
if (ret == SC_SUCCESS)
*tries_left = retries;
return SC_ERROR_PIN_CODE_INCORRECT;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is not a PIN code but key based authentication, the error is misleading. In which context is this function called? (for example, if used through PKCS#11, how does the usual call stack look like in terms of C_ functions?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The usbkey returned status word 0x6300 represent verification failed.but in iso7816.c file, the error table "sc_card_error iso7816_errors[]",I don't know why status word 0x6300 represent "State of non-volatile memory changed"? Bcoz In ISO7816-4 7.5.1 last paragraph shows "In this group of commands, SW1-SW2 set to '6300' or '63CX' indicates that the verification failed ".

can anyone give me the answer ?

regards

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two things:

  1. iso7816.c/.h must be fixed (it is good when someone notices this)
    1a. Remove all the instances of wrongly used SC_ERROR_MEMORY_FAILURE as used in iasecc and sm code to signal memory allocation errors.
  2. Still, if you do key based authentication, then the failure to authenticate can't be translated to an incorrect PIN error. If there's no suitable API level error code defined, create a new one (and make sure that it translated to something meaningful once it escapes the inner workings of OpenSC, like in PKCS#11 or CNG). That's why it would be best if you show some call trace where/when this error actually gets triggered.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. and 1a. are fixed in 8fc679b,
    thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@martinpaljak
Should I change SC_ERROR_MEMORY_FAILURE( 0x6300 ) to SC_ERROR_AUTHENTICATION_FAILURE
I think it's more clear .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viktorTarasov
why change SC_ERROR_MEMORY_FAILURE to SC_WARNING , it's also misleading . The given error infomations "warning: no information given, non-volatile memory has changed" is also indefinite .

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For your authentication failure error, please show where/how it gets triggered (and what is the expected result). For a more generic comment, have a look at 8fc679bf#commitcomment-2732558

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I read the full file. Does the card support PIN based authentication at all? Why doesn't the external authenticate command return the retry counter? Given that for all other parts of OpenSC you actually do receive a PIN as input, the authentication failure indeed should be mapped to incorrect PIN. Epass was a token only, so secure PIN entry via pinpad is anyway not possible, correct?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@entersafe

My reasons were following:

  • according to ISO7816-4 the general meaning of 0x6300 return code is 'warning', without any precising information (ISO7816-4: ch. 5.1.3 "Status bytes", table 6, pp 12);
  • the OpenSC's iso7816.c generic driver defines the general meaning of return codes;
  • according to ISO7816-4 this return code in the context of particular APDU can be seen as 'error' (ISO7816-4: ch.7.5 "Basic secutity handling", pp 50);
  • card driver can redefine the description of the particular return codes;

Finally, I have not strong conviction on this subject.
If you vote for "despite the ISO7816 definitions, in OpenSC any return code that is not 9000 is an error" (that is the current state) I will follow.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From《Identification cards - Integrated circuit cards - Part 4: Organization, security and commands for interchange》Page 56 :
In this group of commands, SW1-SW2 set to '6300' or '63CX' indicates that the verification failed, 'X' > '0'
encodes the number of further allowed retries.

according to above, we can return SC_ERROR_PIN_CODE_INCORRECT when return 0x6300 .
We didn't find the exact error message which define verification failed, so we used the "SC_ERROR_PIN_CODE_INCORRECT" which most close to the current situation. And just use PIN to derive secret key for external authentication.

@entersafe
Copy link
Contributor Author

Can any gatekeeper close all pull requests fired on entersafe asap? We'll create a new on after fixing all issues. Thanks!

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

Successfully merging this pull request may close these issues.

None yet

5 participants