Skip to content

sysmocom/onomondo-uicc

 
 

Repository files navigation

Onomondo software SIM/USIM implementation

This repository contains the [current state of work towards] a pure software implementation/emulation of the most relevant SIM/UICC/USIM functionalities.

License

License: GPL v3

The Onomondo UICC Repository is provided under:

  • SPDX-License-Identifier: GPL-3.0-only

Being under the terms of the GNU General Public License version 3 only, according with:

  • LICENSE

For files licensed under BSD license, refer to BSD-3-Clause file in the root directory of this source tree.

GIT Repository

The canonical git+ssh access of the repository is [email protected]:onomondo/onomondo-uicc.git

External Dependencies

We try to not create any external dependencies. This has both technical and licensing reasons: We cannot expect to cross-compile most external dependencies to the deep embedded "close to bare iron" environments of a cellular modem or microcontroller.

If we reuse existing code, it must be under a permissive license (e.g. BSD, MIT), such as for example the MILENAGE implementation, which we can take from wpa_supplicant, which is BSD/GPL dual-licensed.

Testing

We expect to have both

  • unit tests for individual low-level functions using cunit or autotest in this very repository.
  • higher level integration tests written in python, based on pySim, interfacing with the virtual SIM card via the TCP based vpcd as can be found as part of the open source vsmartcard project

Getting Started

Building from source

Install autoconf, automake, a C compiler and make (on Debian: apt install build-essential autoconf automake), then run:

$ autoreconf -i
$ ./configure
$ make

Installing run time dependencies

  • Install the VPCD, which links smartsim into the PC/SC smart card APIs and pcsc-tools to for gscriptor and pcsc_scan (used for interacting with the sim card). (On Debian: apt install vsmartcard-vpcd pcsc-tools)
  • Install pysim according to its description.

Running smartsim

Wake up PC/SC, by briefly (or even permanently) running pcsc_scan, or a brief run of socat - /run/pcscd/pcscd.comm.

$ ./src/softsim/softsim
    VPCD     INFO softsim!
    VPCD     INFO connected.
      FS     INFO no file selected
 STORAGE     INFO requested file definition for 3f00 rom host file system: ./files/3f00.def
      FS     INFO no file selected
 STORAGE     INFO requested file definition for 3f00 rom host file system: ./files/3f00.def
...

When the program is running, pcsc_scan should show the presence of a card in the Virtual PCD reader:

 Reader 0: Virtual PCD 00 00
  Event number: 19
  Card state: Card inserted, Shared Mode,
  ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 4C 75 30 34 05 4B A9
[...]

With gscriptor, selecting the Virtual PCD enables running the test scripts in ./gscriptor/.

pySim offers interaction with the running softsim card:

$ pySim-shell.py -p 0
Using PC/SC reader interface
Waiting for card...
Autodetected card type: sysmoISIM-SJA2
Info: Card is of type: UICC-SIM
[...]
pySIM-shell (MF)>

Operation compared to ETSI specifications

The SoftSIM largely operates as described by the relevant specifications (ETSI TS 102 series and ISO 7816) to the extent implemented and necessary.

Aspects of its operation that the specifications do not describe are outlined here, with details in the code's in-line documentation:

  • The life cycle of the card is expressed in the master file's life cycle bit: while it is in creation or initialization state, access controls are suspended to allow bottstrapping the file system. Consequently, the master file needs to be in one of these two states when it is created, and the initialization is finished by executing the ACTIVATE command on the master file.

    This is aligned with how ISO 7816 expresses privileges (in that termination of the master file is equated to termination of card usage).

  • Data that needs to be persisted on the card but is not accessed by the applications through the file system still utilizes the file system as a consistent layer of abstraction for all the SoftSIM's persistent storage requirements.

    Data such as PINs and key material is stored in files whose access controls never allow access. (Access control does not apply to read and write operations originating within the SoftSIM). These files may use an extended range of file IDs (32bit rather than 16bit) that is in acccessible through regular file commands such as SELECT.

  • Requirements on the file system, summarized:

    • All files: Access control is exclusively managed through EF.ARR references.
    • MF: At creation, life cycle is set to 3.
    • ADF.USIM / EF.UST: Service 27 needs (GSM access) to be enabled.
  • Overview of proprietary files:

    • A001: SIM authentication keys
    • A002: SIM authentication sequence numbers
    • A003: PINs and their state
    • A004: TARs and keys for remote commands (OTA RFM)
  • Permissions granted to the remotes in OTA RFM are expressed in terms of PINs (CHVs) to allow unified management of permissions. The PINs active with any given OTA TAR are hard-coded in setup_ctx_from_tar until the need for further customization arises; by default, the ADM1 PIN is set.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 96.5%
  • Makefile 1.6%
  • CMake 1.4%
  • M4 0.5%