Bug 85037

Summary: sim: use +CSIM to gather remaining unlock attempts
Product: ModemManager Reporter: Aleksander Morgado <aleksander>
Component: generalAssignee: ModemManager bug user <modemmanager>
Status: RESOLVED MOVED QA Contact:
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Aleksander Morgado 2014-10-15 08:37:19 UTC
Originally reported at:
  https://bugzilla.gnome.org/show_bug.cgi?id=697282
Please refer to the original bug report if more details are needed.

Several modems allow to use AT+CSIM to get remaining unlock retries, so
probably worth adding it to the generic modem implementation:
  AT+CSIM=10,”0020000100” to check PIN1 remaining unlock attempts
  AT+CSIM=10,”002C000100” to check PUK1 remaining unlock attempts
  AT+CSIM=10,"0020008100" to check PIN2 remaining unlock attempts
  AT+CSIM=10,"002C008100" to check PUK2 remaining unlock attempts

  For example:
  AT+CSIM =10,"0020008100"
  +CSIM: 4,"63C3" displays PIN2 remaining unlock attempts
  OK
  Last number shows 3 attempts left

The result of the commands needs to be considered successful only if it's given as: SW1SW2='63CX', where X is the number of attempts left. This is, if the result doesn't start with "63C", a generic error should be assumed.

The additional SW1SW2='6983' result code should also be treated as 0 attempts left. 

-----------
Further detailed info from Dan:

0020000100 (remaining PIN1)
CLS = 00
INS = 20 (VERIFY)
P1  = 00
P2  = 01
LEN = 00

ETSI TS 102.221 Section 10.2.1.3 table 10.9 shows SW1=63 SW2=CX and states "For
the VERIFY PIN command, SW1SW2 indicates that the command was successful but
the PIN was not correct and there are 'X' retries left. For all other commands
it indicates the number of internal retries performed by the card to complete
the command."

Further, section 11.1.9.1.2 (PIN retry counter) states "The VERIFY PIN with
empty data field is used to retrieve the PIN retry counter from the UICC. This
function is performed whether or not the relevant PIN is disabled or blocked
(e.g. by 3 consecutive wrong PIN presentations). The VERIFY PIN command is sent
to the UICC with parameter P2 indicating the PIN for which the retry counter
value is to be retrieved with an empty data field. The number of retries, if
any, is indicated in the response by SW1 SW2 = '63CX', where X indicates the
number of retries left. A VERIFY PIN command with empty data field applied to a
blocked PIN shall return SW1 SW2 = '63C0' or SW1 SW2 = '6983'."

The lower 5 bits of P2 indicate which access condition you want, and 01 = PIN
(see Table 9.2, clause 9.5.1).

The error you're getting (6A86) means "Incorrect parameters P1 to P2" (TS
102.221 Table 10.14 "Status byte coding - wrong parameters").  No idea what's
going on there.


002C000100 (remaining PUK1)
CLS = 00
INS = 2C (CHANGE PIN)
P1  = 00
P2  = 01
LEN = 00

See section 11.1.13.1.2 (UNBLOCK PIN retry counter), which states "The UNBLOCK
PIN command with empty data field is used to retrieve the UNBLOCK PIN retry
counter from the UICC. This function may be performed whether or not the
relevant PIN is blocked (e.g. by 3 consecutive wrong PIN presentations) and
whether or not the UNBLOCK PIN is blocked. The UNBLOCK PIN command is sent to
the UICC with parameter P2 indicating the PIN for which the UNBLOCK
PIN retry counter value is to be retrieved with an empty data field. The number
of retries, if any, is indicated in the response by SW1 SW2 ='63CX', where X
indicates the number of retries left. An UNBLOCK PIN command with empty data
field applied to a blocked UNBLOCK PIN shall return SW1 SW2 = '63C0' or SW1 SW2
= '6983'."

But maybe we could use these commands if the other ones fail, since we know
what the "success" code is.
Comment 1 Aleksander Morgado 2017-03-24 13:10:13 UTC
This is implemented in the Telit plugin. Should we import it to the generic broadband modem?
Comment 2 GitLab Migration User 2018-06-10 09:00:46 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/mobile-broadband/ModemManager/issues/11.
Comment 3 Thomas K 2019-10-30 14:08:07 UTC
Thanks for the wise update on https://best-essay-writing.services/essay-shark-com-review/ with us. That would help lots of people to fix the problem easily. I just found the useful update and able to reach goals as well. Thumb up with your sharing please do share more such helping material.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.