mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-17 02:48:34 +03:00
pySim-shell: Authenticate (3g) support
This adds support for AUTHENTICATE to the USIM and ISIM application, based on the newly-introduced 'construct' encoder/decoder support. Change-Id: Id5697463e29c3dceff98bcf80f5400f7f2bcaa6c
This commit is contained in:
@@ -268,6 +268,7 @@ EF_USIM_ADF_map = {
|
||||
# ADF.USIM
|
||||
######################################################################
|
||||
|
||||
from struct import unpack, pack
|
||||
from pySim.filesystem import *
|
||||
from pySim.ts_51_011 import EF_IMSI, EF_xPLMNwAcT, EF_SPN, EF_CBMI, EF_ACC, EF_PLMNsel, EF_AD
|
||||
from pySim.ts_51_011 import EF_CBMID, EF_CBMIR
|
||||
@@ -489,6 +490,8 @@ class ADF_USIM(CardADF):
|
||||
def __init__(self, aid='a0000000871002', name='ADF.USIM', fid=None, sfid=None,
|
||||
desc='USIM Application'):
|
||||
super().__init__(aid=aid, fid=fid, sfid=sfid, name=name, desc=desc)
|
||||
# add those commands to the general commands of a TransparentEF
|
||||
self.shell_commands += [self.AddlShellCommands()]
|
||||
|
||||
files = [
|
||||
EF_LI(sfid=0x02),
|
||||
@@ -520,6 +523,23 @@ class ADF_USIM(CardADF):
|
||||
def decode_select_response(self, data_hex):
|
||||
return pySim.ts_102_221.decode_select_response(data_hex)
|
||||
|
||||
@with_default_category('Application-Specific Commands')
|
||||
class AddlShellCommands(CommandSet):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
authenticate_parser = argparse.ArgumentParser()
|
||||
authenticate_parser.add_argument('rand', help='Random challenge')
|
||||
authenticate_parser.add_argument('autn', help='Authentication Nonce')
|
||||
#authenticate_parser.add_argument('--context', help='Authentication context', default='3G')
|
||||
@cmd2.with_argparser(authenticate_parser)
|
||||
def do_authenticate(self, opts):
|
||||
"""Perform Authentication and Key Agreement (AKA)."""
|
||||
(data, sw) = self._cmd.card._scc.authenticate(opts.rand, opts.autn)
|
||||
self._cmd.poutput_json(data)
|
||||
|
||||
|
||||
|
||||
# TS 31.102 Section 7.3
|
||||
sw_usim = {
|
||||
'Security management': {
|
||||
|
||||
Reference in New Issue
Block a user