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

SW match failed! Expected 9000 and got 6982 #1

Open
ReeturajBhuyan opened this issue Oct 13, 2023 · 9 comments
Open

SW match failed! Expected 9000 and got 6982 #1

ReeturajBhuyan opened this issue Oct 13, 2023 · 9 comments

Comments

@ReeturajBhuyan
Copy link

Hello,

I am trying to program a SIM Card using pySim. But I am getting this below error
pySim.exceptions.SwMatchError: SW match failed! Expected 9000 and got 6982

I guess this error basically means "Security condition not satisfied.” I am passing the below parameters in the prog command.
IMSI 234015555020000
MSISDN 12800520000
mcc 234
mnc 015
AMDPIN ADM11111

./pySim-prog.py -p 0 -t sysmoUSIM-SJS1 --mcc=234 --mnc=015 --iccid=89010020000005348007 --imsi=234015555020000 --msisdn=+12800520000 -a ADM11111

Is there any other parameter that needs to be added or mandatory which is not included.

@herlesupreeth
Copy link
Owner

I believe your ADM pin is wrong. It should be only digits. Please check the ADM1 pin provided to you by sysmocom

@ReeturajBhuyan
Copy link
Author

Hi
We received this ADM pin. We tried using verify_adm using this pin and was successful.
For testing I entered an incorrect/different pin and it responded with 6983 and said 1 retries left.

@herlesupreeth
Copy link
Owner

herlesupreeth commented Oct 13, 2023

Hmm, so you are saying that the SIM ADMI1 key is ADM11111 ??

Also, can you post the full error you get when you attempt to program using pySIM??

@ReeturajBhuyan
Copy link
Author

ReeturajBhuyan commented Oct 14, 2023

Yes we received the ADM pin as ADM11111. We verified the same using verify_adm
pySIM-shell (MF)>
pySIM-shell (MF)> verify_adm ADM11111
pySIM-shell (MF)>
pySIM-shell (MF)>

I tried with a random ADM just to check. But got an 6983 "Authentication Method Blocked"

pySIM-shell (MF)> verify_adm 88888888
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/cmd2/cmd2.py", line 2399, in onecmd_plus_hooks
stop = self.onecmd(statement, add_to_history=add_to_history)
File "/usr/local/lib/python3.10/dist-packages/cmd2/cmd2.py", line 2852, in onecmd
stop = func(statement)
File "/home/reeturaj/SIM_CARD/pyscard-2.0.7/pysim/pySim-shell.py", line 787, in do_verify_adm
self._cmd.card._scc.verify_chv(self._cmd.card._adm_chv_num, h2b(pin_adm))
File "/home/reeturaj/SIM_CARD/pyscard-2.0.7/pysim/pySim/commands.py", line 523, in verify_chv
self._chv_process_sw('verify', chv_no, code, sw)
File "/home/reeturaj/SIM_CARD/pyscard-2.0.7/pysim/pySim/commands.py", line 511, in _chv_process_sw
raise SwMatchError(sw, '9000')
pySim.exceptions.SwMatchError: SW match failed! Expected 9000 and got 6983.
EXCEPTION of type 'SwMatchError' occurred with message: SW match failed! Expected 9000 and got 6983.

We then proceeded to program the SIM using the below commands and parameters but got 6982 error.

./pySim-prog.py -p 0 -t sysmoUSIM-SJS1 --mcc=234 --mnc=015 --iccid=89010020000005348007 --imsi=234015555020000 --msisdn=+12800520000 -a ADM11111

pySim.exceptions.SwMatchError: SW match failed! Expected 9000 and got 6982.

@ReeturajBhuyan
Copy link
Author

root@reeturaj--ubuntu:/home/reeturaj/SIM_CARD/pyscard-2.0.7/pysim# ./pySim-prog.py -p 0 -t sysmoUSIM-SJS1 --mcc=234 --mnc=015 --iccid=89010020000005348007 --imsi=234015555020000 --msisdn=+12800520000 -a ADM11111
Using PC/SC reader interface
Ready for Programming: Insert card now (or CTRL-C to cancel)
Generated card parameters :

Name : Magic
SMSP : e1ffffffffffffffffffffffff0581005155f5ffffffffffff000000
ICCID : 89010020000005348007
MCC/MNC : 234/015
IMSI : 234015555020000
Ki : 2e52e940b1040f91fbaf9b2b35d7810f
OPC : 74b1de734d753c7a3b3f1b9cffb532ac
ACC : None
ADM1(hex): 41444d3131313131
OPMODE : None
Programming ...

Card programming failed with an exception:
---------------------8<---------------------
Traceback (most recent call last):
File "/home/reeturaj/SIM_CARD/pyscard-2.0.7/pysim/pySim/commands.py", line 223, in update_binary
chunk_data, chunk_sw = self._tp.send_apdu_checksw(pdu)
File "/home/reeturaj/SIM_CARD/pyscard-2.0.7/pysim/pySim/transport/init.py", line 213, in send_apdu_checksw
raise SwMatchError(rv[1], sw.lower(), self.sw_interpreter)
pySim.exceptions.SwMatchError: SW match failed! Expected 9000 and got 6982.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/reeturaj/SIM_CARD/pyscard-2.0.7/pysim/./pySim-prog.py", line 824, in
rc = process_card(opts, first, ch)
File "/home/reeturaj/SIM_CARD/pyscard-2.0.7/pysim/./pySim-prog.py", line 774, in process_card
card.program(cp)
File "/home/reeturaj/SIM_CARD/pyscard-2.0.7/pysim/pySim/legacy/cards.py", line 929, in program
data, sw = self._scc.update_binary('2fe2', enc_iccid(p['iccid']))
File "/home/reeturaj/SIM_CARD/pyscard-2.0.7/pysim/pySim/commands.py", line 225, in update_binary
raise ValueError('%s, failed to write chunk (chunk_offset %d, chunk_len %d)' %
ValueError: SW match failed! Expected 9000 and got 6982., failed to write chunk (chunk_offset 0, chunk_len 10)
---------------------8<---------------------

Programming failed: Remove card from reader

@laf0rge
Copy link
Contributor

laf0rge commented Oct 14, 2023 via email

@ReeturajBhuyan
Copy link
Author

I had received the below Secret codes. All are numeric except the ADM PIN.
GPIN1, PUK1, LPIN1, PUK2, ADM1(Keyset 1)

Is there any other security parameter that needs to be passed while programing the Cards?

@herlesupreeth
Copy link
Owner

@ReeturajBhuyan As @laf0rge (Harald from Sysmocom) mentioned ADM PIN cannot be anything other than digits so I would suggest to re-check ADM1 key.

@ReeturajBhuyan
Copy link
Author

Thank you so much @laf0rge @herlesupreeth for the support.
Let me get the SIM Cards and the documentation provided revalidated.

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