Compare commits

..

No commits in common. "main" and "v0.0.8-alpha" have entirely different histories.

762 changed files with 65798 additions and 8703 deletions

View file

@ -1,12 +0,0 @@
root = true
[*]
charset = utf-8
indent_size = 4
indent_style = space
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
indent_size = 2

View file

@ -1,77 +1,83 @@
name: Build
name: Release
on:
workflow_dispatch:
push:
branches: [main]
tags: [v*]
pull_request:
branches: [main]
tags:
- "v*"
workflow_dispatch:
permissions:
contents: write
jobs:
build:
name: Build for ${{ matrix.build.name }}
runs-on: ${{ matrix.build.os }}
strategy:
fail-fast: false
matrix:
build:
- {os: ubuntu-24.04, variant: make, name: Linux, artifact: linux-x64}
- {os: ubuntu-24.04-arm, variant: make, name: Linux ARM, artifact: linux-arm}
- {os: ubuntu-24.04, variant: make-without-lto, name: Linux (w/o LTO), artifact: linux-x64-without-lto}
- {os: ubuntu-24.04-arm, variant: make-without-lto, name: Linux ARM (w/o LTO), artifact: linux-arm-without-lto}
- {os: ubuntu-24.04, variant: debian, name: Debian, artifact: debian-x64}
- {os: ubuntu-24.04-arm, variant: debian, name: Debian ARM, artifact: debian-arm}
- {os: ubuntu-24.04, variant: mingw, name: Windows with MinGW, artifact: windows-x64}
- {os: ubuntu-24.04, variant: woa-mingw, name: Windows on ARM with MinGW, artifact: windows-arm64}
- {os: macos-15, variant: make, name: macOS, artifact: macos-universal}
- {os: macos-15, variant: make-without-lto, name: macOS (w/o LTO), artifact: macos-universal-without-lto}
os: [windows-latest, ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout repo
uses: actions/checkout@v3
- name: Setup Toolchain
run: sudo ./scripts/setup-debian.sh ${{ matrix.build.variant }}
- name: Setup toolchain
if: runner.os == 'Linux'
- name: Build for ${{ matrix.build.name }}
run: ./scripts/build-ci.sh ${{ matrix.build.variant }}
- name: Get short SHA
run: echo "SHA7=$(echo ${GITHUB_SHA} | cut -c1-7)" >> $GITHUB_ENV
- name: Upload ${{ matrix.build.name }} to Artifact
uses: actions/upload-artifact@v4
with:
name: lpac-${{ env.SHA7 }}-${{ matrix.build.artifact }}
path: ${{ github.workspace }}/build/*.*
release:
name: Release
runs-on: ubuntu-24.04
if: startsWith(github.ref, 'refs/tags/v')
needs: build
permissions:
contents: write
steps:
- name: Download Artifact
uses: actions/download-artifact@v4
with:
merge-multiple: true
pattern: '*'
- name: Run SHA1SUM
id: checksum
run: |
echo 'sha1sum<<EOF' >> $GITHUB_OUTPUT
sha1sum * >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
- name: Release
uses: softprops/action-gh-release@v2
sudo apt-get update
sudo apt-get install -y libpcsclite-dev libcurl4-openssl-dev gcc make cmake gcc-mingw-w64 g++-mingw-w64 unzip
- name: Setup Cygwin
if: runner.os == 'Windows'
uses: egor-tensin/setup-cygwin@v4
with:
body: |
```plain
${{ steps.checksum.outputs.sha1sum }}
```
append_body: true
files: '*'
packages: cmake gcc-g++ make zip wget
- name: Build for Linux
if: runner.os == 'Linux'
run: |
mkdir build && cd build && cmake .. && make -j$(nproc)
chmod +x output/lpac
tar -czvf lpac-linux-x86_64.tar.gz -C output .
shell: bash
- name: Build for Windows(MinGW)
if: runner.os == 'Linux'
run: |
mkdir build-mingw && cd build-mingw && cmake -DLINUX_MINGW32=ON .. && make -j$(nproc)
wget https://curl.se/windows/dl-8.5.0_3/curl-8.5.0_3-win64-mingw.zip -O curl.zip && unzip curl.zip && mv curl-8.5.0_3-win64-mingw/bin/libcurl-x64.dll output/libcurl.dll
zip -r -j lpac-windows-x86_64-mingw.zip output/*
- name: Build for Windows(Cygwin)
if: runner.os == 'Windows'
run: |
mkdir build-cygwin && cd build-cygwin && cmake -DCYGWIN=ON .. && make
wget https://curl.se/windows/dl-8.5.0_3/curl-8.5.0_3-win64-mingw.zip -O curl.zip && unzip curl.zip && mv curl-8.5.0_3-win64-mingw/bin/libcurl-x64.dll output/libcurl.dll
cp C:\tools\cygwin\bin\cygwin1.dll output
zip -r -j lpac-windows-x86_64-cygwin.zip output/*
- name: Build for macOS
if: runner.os == 'macOS'
run: |
mkdir build && cd build && cmake .. && make -j$(sysctl -n hw.ncpu)
chmod +x output/lpac
zip -r -j lpac-macos-universal.zip output/*
shell: bash
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: build-artifacts
path: |
build-mingw/lpac-windows-x86_64-mingw.zip
build-cygwin/lpac-windows-x86_64-cygwin.zip
build/lpac-linux-x86_64.tar.gz
build/lpac-macos-universal.zip
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/v')
with:
files: |
build-mingw/lpac-windows-x86_64-mingw.zip
build-cygwin/lpac-windows-x86_64-cygwin.zip
build/lpac-linux-x86_64.tar.gz
build/lpac-macos-universal.zip

12
.gitignore vendored
View file

@ -9,16 +9,6 @@ install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps
build
.vscode*
.DS_Store
# version
/src/version.h
# for package files
lpac_*.deb
lpac-*.zip
# for clion ignores
.idea
cmake-build-*

View file

@ -1,71 +1,46 @@
cmake_minimum_required (VERSION 3.15)
option(LINUX_MINGW32 "Build for windows on Linux" OFF)
project (lpac
VERSION 2.1.0
HOMEPAGE_URL "https://github.com/estkme-group/lpac"
DESCRIPTION "C-based eUICC LPA."
LANGUAGES C)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(LPAC_CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH ${LPAC_CMAKE_MODULE_PATH})
if(NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
# Git auto-ignore out-of-source build directory
file(GENERATE OUTPUT .gitignore CONTENT "*")
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# add_compile_options(-Wall -Wextra -Wpedantic)
# Enable LTO when possible.
include(CheckIPOSupported)
check_ipo_supported(RESULT result OUTPUT output)
if(result)
if(NOT DEFINED CMAKE_INTERPROCEDURAL_OPTIMIZATION)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
else()
message(INFO "IPO is not supported: ${output}")
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
if (APPLE)
message(STATUS "Building for macOS")
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64")
set(CMAKE_SYSTEM_NAME Darwin)
endif()
if(UNIX)
include(GNUInstallDirs)
if(NOT CMAKE_INSTALL_RPATH)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}/lpac")
endif()
if(LINUX_MINGW32)
set(CMAKE_SYSTEM_NAME Windows)
set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
set(CMAKE_Fortran_COMPILER ${TOOLCHAIN_PREFIX}-gfortran)
set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
endif()
if(WIN32)
add_subdirectory(dlfcn-win32)
set(DL_LIBRARY dlfcn-win32)
else()
set(DL_LIBRARY dl)
if(CYGWIN)
set(CMAKE_SYSTEM_NAME Windows)
message(STATUS "Building for Cygwin")
add_definitions(-DHAVE_TIMEGM=1)
add_definitions(-DWIN32)
endif()
if(CPACK_GENERATOR)
set(CPACK_PACKAGE_VENDOR "eSTK.me Group")
cmake_minimum_required (VERSION 3.8)
project (lpac)
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "eSTK.me Group")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6")
set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "libcurl, libpcsclite, pcscd")
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
set(CPACK_RPM_PACKAGE_LICENSE "AGPL-3.0-only AND LGPL-2.0-only")
set(CPACK_RPM_PACKAGE_AUTOREQ "yes")
set(CPACK_RPM_PACKAGE_REQUIRES "libcurl, libpcsclite, pcscd")
include(CPack)
endif()
include_directories(.)
add_subdirectory(cjson)
add_subdirectory(euicc)
add_subdirectory(driver)
add_subdirectory(interface)
add_subdirectory(src)
if(LINUX_MINGW32)
add_subdirectory(dlfcn-win32)
endif()

373
README.md
View file

@ -1,51 +1,364 @@
# lpac
lpac is a cross-platform local profile agent program, compatible with [SGP.22 version 2.2.2](https://www.gsma.com/solutions-and-impact/technologies/esim/wp-content/uploads/2020/06/SGP.22-v2.2.2.pdf).
lpac is a cross platform local profile agent program.
Features:
- Support Activation Code and Confirmation Code
- Support Custom IMEI sent to server
- Support Profile Discovery (SM-DS)
- Support Activate Code and Confirm Code
- Support custom IMEI sent to server
- Support eSIM Discovery (Push Model)
- Profile management: list, enable, disable, delete and nickname
- Notification management: list, send and delete
- Lookup eUICC chip info
- etc
## Usage
Download:
[Github Release](https://github.com/estkme-group/lpac/releases/latest)
You can download lpac from [GitHub Release][latest], and read [USAGE](docs/USAGE.md) to use it.
If you can't run it you need to compile by yourself, see also [DEVELOPERS](docs/DEVELOPERS.md).
If you want to known which Linux distributions include lpac, see also [LINUX-DIST](docs/LINUX-DIST.md).
If you have any issue, please read [FAQ](docs/FAQ.md) first.
lpac is dynamic-linked, Release is built by Github action, if you can't run it you need to compile by yourself
[latest]: https://github.com/estkme-group/lpac/releases/latest
# Compile
## Software Ecosystem
<details>
<summary>Linux</summary>
- [EasyLPAC] (Windows, Linux and macOS)
- [{Open,Easy}EUICC][openeuicc] ([Mirror][openeuicc-mirror], Android)
- [eSIM Manager (lpa-gtk)](https://codeberg.org/lucaweiss/lpa-gtk) (Linux Mobile)
- [rlpa-server](https://github.com/estkme-group/rlpa-server) for eSTK.me Cloud Enhance function
- Debian/Ubuntu
[easylpac]: https://github.com/creamlike1024/EasyLPAC/releases/latest
[openeuicc]: https://gitea.angry.im/PeterCxy/OpenEUICC
[openeuicc-mirror]: https://github.com/estkme-group/openeuicc
```bash
sudo apt install build-essential cmake git g++ libpcsclite-dev libcurl4-openssl-dev
git clone --depth=1 https://github.com/estkme-group/lpac
cd lpac && mkdir build && cd build
cmake ..
make
```
then execute `./output/lpac` to use.
</details>
<details>
<summary>macOS</summary>
- Install [Homebrew](https://brew.sh/).
```bash
git clone --depth=1 https://github.com/estkme-group/lpac
cd lpac && mkdir build && cd build
cmake ..
make
```
</details>
<details>
<summary>Windows</summary>
Due to a [bug in asn1c](https://github.com/vlm/asn1c/issues/196), the MinGW version of lpac cannot send notification successfully. Building with Cygwin seems to avoid it.
Windows need prebuilt libcurl.dll, you can replace the download link to newest curl version.
- Build on Windows(Cygwin)
With `gcc-core` `gcc-g++` `make` `cmake` `unzip` `wget` installed
```bash
git clone --depth=1 https://github.com/estkme-group/lpac
cd lpac && mkdir build && cd build
cmake -DCYGWIN=ON .. && make
# Download libcurl
wget https://curl.se/windows/dl-8.4.0_6/curl-8.4.0_6-win64-mingw.zip -O curl.zip && unzip curl.zip && mv curl-8.4.0_6-win64-mingw/bin/libcurl-x64.dll output/libcurl.dll
```
To run it outside Cygwin shell, you need copy `cygwin1.dll` to the program folder to distribute.
`cygwin1.dll` is located in `C:\cygwin64\bin\cygwin1.dll` (Default Cygwin installation location)
- Build on Linux(MINGW)
```bash
sudo apt install build-essential cmake git g++ libpcsclite-dev libcurl4-openssl-dev gcc-mingw-w64 g++-mingw-w64
git clone --depth=1 https://github.com/estkme-group/lpac
cd lpac && mkdir build && cd build
cmake -DLINUX_MINGW32=ON .. && make
# Download libcurl
wget https://curl.se/windows/dl-8.4.0_6/curl-8.4.0_6-win64-mingw.zip -O curl.zip && unzip curl.zip && mv curl-8.4.0_6-win64-mingw/bin/libcurl-x64.dll output/libcurl.dll
```
- Build on Windows(MSYS2)
```bash
pacman -S mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja mingw-w64-x86_64-gcc
git clone --depth=1 https://github.com/estkme-group/lpac
cd lpac && mkdir build && cd build
cmake -DLINUX_MINGW32=ON .. && ninja
# Download libcurl
wget https://curl.se/windows/dl-8.4.0_6/curl-8.4.0_6-win64-mingw.zip -O curl.zip && unzip curl.zip && mv curl-8.4.0_6-win64-mingw/bin/libcurl-x64.dll output/libcurl.dll
```
</details>
# Usage
In Linux, you need install `pcscd`, `pcsclite` and `libcurl`.
APDU and HTTP interfaces of lpac has serval backends, you need specify `$APDU_INTERFACE` and `$HTTP_INTERFACE` environment variable to interface library path. If not specified, it will use `libapduinterface_pcsc` and `libhttpinterface_curl`.
APDU Backends:
- `libapduinterface_at`: use AT commands interface used by LTE module
- `libapduinterface_pcsc`: use PC/SC Smart Card API
- `libapduinterface_stdio`: use standard input/output
Using `libapduinterface_at` need access permission to serial port (normally `/dev/ttyUSBx`). On Arch Linux, you can add yourself to `uucp` group by `sudo usermod -aG uucp $USER`. On other distro, you may need add yourself into `dialout` group.
HTTP Backends:
- `libhttpinterface_curl`: use libcurl
- `libhttpinterface_stdio`: use standard input/ouput
## CLI
### Command format
```
lpac <subcommand> [subcommand] [parameters]
subcommand:
chip View and manage information about your eUICC card itself
profile Manage the profile of your eUICC card
notification Manage notifications within your eUICC card
driver View backend info
subcommand 2:
Please refer to the detailed instructions below
```
### Return value
The return contents of lpac instructions are all in json format, and the returns of all instructions comply with the following format.
```json
{
"type": "lpa",
"payload": {
"code": 0,
"message": "success",
"data": {[]}
}
}
```
- `"type": "lpa"`: fixed content
- `code`: if is 0, indicating successful execution, and other values are error codes.
- `message`: is success if the operation is successful, or the error type is returned if an error occurs.
- `data`: returns the returned content when the operation is successful, and is empty (but not NULL) when there is an error.
### Subcommand
#### chip
View the EID, default SM-DP+ server and SM-DS server of eUICC. euicc_info2 is also supported.
```
lpac chip <subcommand> [parameters]
subcommand:
info View information about your eUICC card itself
defaultsmdp Modify the default SM-DP+ server address of your eUICC card
Example: lpac chip defaultsmdp <the address of the SM-DP+ server you want to modify>
purge Reset the eUICC and will clear all profiles. Use with caution!
```
<details>
<summary>Return value example</summary>
```json
{
"type": "lpa",
"payload": {
"code": 0,
"message": "success",
"data": {
"eid": " EID ",
"default_smds": "testrootsmds.gsma.com",
"default_smdp": "",
"euicc_info2": {
"profile_version": "2.1.0",
"sgp22_version": "2.2.0",
"euicc_firmware_version": "4.6.0",
"uicc_firmware_version": "9.2.0",
"global_platform_version": "2.3.0",
"protection_profile_version": "0.0.1",
"sas_accreditation_number": "GI-BA-UP-0419",
"free_nvram": 295424,
"free_ram": 295424
}
}
}
}
```
</details>
#### profile
Profile management, you can list, set alias (nickname), enable, disable, delete, download and discovery Profiles.
```
lpac profile <subcommand> [parameters]
subcommand:
list enumerates your eUICC Profile
nickname sets an alias for the specified Profile
Example: lpac profile nickname <ICCID of Profile> <alias>
enable enables the specified Profile. The RefreshFlag status is enabled by default and can be omitted.
Example: lpac profile enable <ICCID/AID of Profile> [1/0]
disable disables the specified Profile. The RefreshFlag state is enabled by default and can be omitted.
Example: lpac profile disable <ICCID/AID of Profile> [1/0]
delete deletes the specified Profile
Example: lpac profile delete <ICCID/AID of Profile>
download Pull method to download new Profile
discovery Push method to download Profiles
```
There is no secondary confirmation for deleting a Profile, so please perform it with caution.
> [!NOTE]
> This function will only delete the Profile and issue a Notification, but it will not be sent automatically. You need to send it manually.
##### Download requires connection to SM-DP+ server and the following additional parameters:
- `-s`: SM-DP+ server, optional, if not provided, it will try to read the defaultsmdp attribute.
- `-m`: Matching ID, activation code. optional.
- `-c`: Confirmation Code, optional.
- `-i`: The IMEI of the device to which Profile is to be downloaded, optional.
<details>
<summary>Example</summary>
```bash
./lpac profile download -s rsp.truphone.com -m "QR-G-5C-1LS-1W1Z9P7"
```
</details>
##### Discovery requires connecting to the SM-DS server to do the profile push query
The following parameters can be used to customize the IMEI and SM-DS server:
- `-s`: SM-DS server. If not provided, it will be gsma official server "lpa.ds.gsma.com"
- `-i`: IMEI of the device to which Profile is to be downloaded, optional
<details>
<summary>Return value example of lpac profile list</summary>
```json
{
"type": "lpa",
"payload": {
"code": 0,
"message": "success",
"data": [
{
"iccid": "8999990000... ",
"isdpAid": "A0000005591010...",
"profileState": 1,
"profileNickname": "tel-u",
"serviceProviderName": "eSIM",
"profileName": "NEWARE_CUG_V001",
"profileClass": 2
},
{
"iccid": "894447860000...",
"isdpAid": "A0000005591011...",
"profileState": 0,
"serviceProviderName": "BetterRoaming",
"profileName": "BetterRoaming",
"profileClass": 2
}
]
}
}
```
- `iccid`: ICCID of Profile
- `isdpAid`: Aid of Profile
- `profileState`: State of Profile, 1 is enabled. You can enable multiple Profile only when device support MEP (Multiple Enabled Profiles)
- `profileNickname`: Nickname of Profile
- `serviceProviderName`: Telecom operators of Profile
- `profileName`: Name of Profile
- `profileClass`: Version of Profile
</details>
#### notification
Used for the management of Notifications, which are sent by telecom operators during Profile operations. You can enumerate (list), send (process), and remove (remove) Notifications.
```
lpac notification <subcommand> [parameters]
subcommand:
list Enumerates your eUICC pending Notification list
process Send Notification
Example: lpac notification process <sequence ID>
remove Remove Notification
Example: lpac notification remove <sequence ID>
```
> [!NOTE]
> Downstream developers or end users should process Notification as soon as possible when they exist to comply with GSMA specifications. lpac will not automatically delete the Notification after sending it, and you need to delete it manually.
<details>
<summary>Return value example of lpac notification list</summary>
```json
{
"type": "lpa",
"payload": {
"code": 0,
"message": "success",
"data": [
{
"seqNumber": 7,
"profileManagementOperation": 32,
"notificationAddress": "rsp-eu.simlessly.com",
"iccid": "8999990000"
},
{
"seqNumber": 8,
"profileManagementOperation": 64,
"notificationAddress": "rsp.truphone.com",
"iccid": "894447860000"
}
]
}
}
```
- `seqNumber`: Sequence ID
- `profileManagementOperation`: Profile status identifier
- `notificationAddress`: Profile's notification reporting server address
</details>
#### driver
Now there is only one command: `lpac driver apdu list` to get card reader list.
## FAQ
<details>
<summary>Q: Any subcommand of lpac will get error message like "SCardListReaders() failed:" and 8-digits error code, such as 80100069, 80100066, 8010002E, 8010000F and so on.</summary>
A:
- 80100069 means your UICC is not plugged correctly
- 80100066 means your card has no response, please clean the pin and plug in again
- 8010002E means communication error
- 8010000F means the card is not a eUICC, or detect wrong card reader like Yubikey. For latter one, you can use `lpac driver apdu list` to list all reader and use `$DRIVER_IFID` to specify correct card reader
- for others, Google is your friend.
</details>
<details>
<summary>Q: I can't download eSIM profile of xxx.</summary>
A: The verification of SM-DP+ servers of telecom operators is diverse. Please check whether the parameters you enter are consistent with those provided to you by the telecom operators. Some telecom operators issue profiles in the form of push, which may require the use of lpac's discovery and custom IMEI function.
</details>
## Thanks
[![Contributors][contrib]][contributors]
[contrib]: https://contrib.rocks/image?repo=estkme-group/lpac
[contributors]: https://github.com/estkme-group/lpac/graphs/contributors
<a href="https://github.com/estkme-group/lpac/graphs/contributors">
<img src="https://contrib.rocks/image?repo=estkme-group/lpac" alt=""/>
</a>
---
## License
- lpac ([/src](src), [/driver](driver)): AGPL-v3.0-only
- libeuicc ([/euicc](euicc)): LGPL-v2.1-only or Commercial License Agreement with ESTKME TECHNOLOGY LIMITED, Hong Kong
- cjson ([/cjson](cjson)): MIT
- dlfcn-win32 ([/dlfcn-win32](dlfcn-win32)): MIT
Copyright &copy; 2023-2025 ESTKME TECHNOLOGY LIMITED, Hong Kong
AGPL-3.0
Copyright (c) 2023-2024 eSTKme Group

3
asn1/generate.txt Normal file
View file

@ -0,0 +1,3 @@
asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example ../../../asn1/PKIXExplicit88.asn ../../../asn1/PKIXImplicit88.asn ../../../asn1/rsp.asn
find "." -type f \( -name "*.c" -o -name "*.h" \) | while read -r file; do for header in $(find "." -type f -name "*.h"); do header_file=$(basename "$header"); sed -i "/#include <${header_file}>/c\#include \"${header_file}\"" "$file"; done; done

View file

@ -11,15 +11,12 @@ id-rsp OBJECT IDENTIFIER ::= {joint-iso-itu-t(2) international-organizations(23)
-- Basic types, for size constraints
Octet8 ::= OCTET STRING (SIZE(8))
Octet4 ::= OCTET STRING (SIZE(4))
Octet16 ::= OCTET STRING (SIZE(16))
OctetTo16 ::= OCTET STRING (SIZE(1..16))
Octet32 ::= OCTET STRING (SIZE(32))
Octet1 ::= OCTET STRING(SIZE(1))
Octet2 ::= OCTET STRING (SIZE(2))
VersionType ::= OCTET STRING(SIZE(3)) -- major/minor/revision version are coded as binary value on byte 1/2/3, e.g. '02 00 0C' for v2.0.12.
-- If revision is not used (e.g. v2.1), byte 3 SHALL be set to '00'.
Iccid ::= [APPLICATION 26] OCTET STRING (SIZE(10)) -- ICCID as coded in EFiccid, corresponding tag is '5A'
RemoteOpId ::= [2] INTEGER {installBoundProfilePackage(1)}
TransactionId ::= OCTET STRING (SIZE(1..16))
@ -44,7 +41,7 @@ EUICCInfo2 ::= [34] SEQUENCE { -- Tag 'BF22'
euiccFirmwareVer [3] VersionType, -- eUICC Firmware version
extCardResource [4] OCTET STRING, -- Extended Card Resource Information according to ETSI TS 102 226
uiccCapability [5] UICCCapability,
ts102241Version [6] VersionType OPTIONAL,
javacardVersion [6] VersionType OPTIONAL,
globalplatformVersion [7] VersionType OPTIONAL,
rspCapability [8] RspCapability,
euiccCiPKIdListForVerification [9] SEQUENCE OF SubjectKeyIdentifier, -- List of CI Public Key Identifiers supported on the eUICC for signature verification
@ -66,8 +63,7 @@ RspCapability ::= BIT STRING {
additionalProfile(0), -- at least one more Profile can be installed
crlSupport(1), -- CRL
rpmSupport(2), -- Remote Profile Management
testProfileSupport (3), -- support for test profile
deviceInfoExtensibilitySupport (4) -- support for ASN.1 extensibility in the Device Info
testProfileSupport (3) -- support for test profile
}
-- Definition of CertificationDataObject
@ -111,19 +107,12 @@ UICCCapability ::= BIT STRING {
multipleUsimSupport(16), -- Multiple USIM applications are supported within the same Profile
multipleIsimSupport(17), -- Multiple ISIM applications are supported within the same Profile
multipleCsimSupport(18), -- Multiple CSIM applications are supported within the same Profile
berTlvFileSupport(19), -- BER TLV files
dfLinkSupport(20), -- Linked Directory Files
catTp(21), -- Support of CAT TP
getIdentity(22), -- Support of the GET IDENTITY command as defined in ETSI TS 102 221 [6]
profile-a-x25519(23), -- Support of ECIES Profile A as defined in 3GPP TS 33.501 [87]
profile-b-p256(24), -- Support of ECIES Profile B as defined in 3GPP TS 33.501 [87]
suciCalculatorApi(25) -- Support of the associated API for SUCI derivation as defined in 3GPP 31.130 [88]
multipleCsimSupport(18) -- Multiple CSIM applications are supported within the same Profile
}
-- Definition of DeviceInfo
DeviceInfo ::= SEQUENCE {
tac Octet4,
tac Octet8,
deviceCapabilities DeviceCapabilities,
imei Octet8 OPTIONAL
}
@ -135,12 +124,10 @@ DeviceCapabilities ::= SEQUENCE { -- Highest fully supported release for each de
cdma2000onexSupportedRelease VersionType OPTIONAL,
cdma2000hrpdSupportedRelease VersionType OPTIONAL,
cdma2000ehrpdSupportedRelease VersionType OPTIONAL,
eutranEpcSupportedRelease VersionType OPTIONAL,
eutranSupportedRelease VersionType OPTIONAL,
contactlessSupportedRelease VersionType OPTIONAL,
rspCrlSupportedVersion VersionType OPTIONAL,
nrEpcSupportedRelease VersionType OPTIONAL,
nr5gcSupportedRelease VersionType OPTIONAL,
eutran5gcSupportedRelease VersionType OPTIONAL
rspRpmSupportedVersion VersionType OPTIONAL
}
ProfileInfoListRequest ::= [45] SEQUENCE { -- Tag 'BF2D'
@ -167,9 +154,9 @@ ProfileInfo ::= [PRIVATE 3] SEQUENCE { -- Tag 'E3'
profileName [18] UTF8String (SIZE(0..64)) OPTIONAL, -- Tag '92'
iconType [19] IconType OPTIONAL, -- Tag '93'
icon [20] OCTET STRING (SIZE(0..1024)) OPTIONAL, -- Tag '94', see condition in ES10c:GetProfilesInfo
profileClass [21] ProfileClass OPTIONAL, -- Tag '95'
profileClass [21] ProfileClass DEFAULT operational, -- Tag '95'
notificationConfigurationInfo [22] SEQUENCE OF NotificationConfigurationInformation OPTIONAL, -- Tag 'B6'
profileOwner [23] OperatorId OPTIONAL, -- Tag 'B7'
profileOwner [23] OperatorID OPTIONAL, -- Tag 'B7'
dpProprietaryData [24] DpProprietaryData OPTIONAL, -- Tag 'B8'
profilePolicyRules [25] PprIds OPTIONAL, -- Tag '99'
refArDo [118] SEQUENCE OF RefArDo OPTIONAL -- Tag 'BF76'
@ -188,10 +175,11 @@ RefArDo ::= [PRIVATE 2] SEQUENCE { -- Tag 'E2'
PprIds ::= BIT STRING {-- Definition of Profile Policy Rules identifiers
pprUpdateControl(0), -- defines how to update PPRs via ES6
ppr1(1), -- Indicator for PPR1 'Disabling of this Profile is not allowed'
ppr2(2) -- Indicator for PPR2 'Deletion of this Profile is not allowed'
ppr2(2), -- Indicator for PPR2 'Deletion of this Profile is not allowed'
ppr3(3) -- Indicator for PPR3 'Deletion of this Profile is required upon its successful disabling'
}
OperatorId ::= SEQUENCE {
OperatorID ::= SEQUENCE {
mccMnc OCTET STRING (SIZE(3)), -- MCC and MNC coded as defined in 3GPP TS 24.008 [32]
gid1 OCTET STRING OPTIONAL, -- referring to content of EF GID1 (file identifier '6F3E') as defined in 3GPP TS 31.102 [54]
gid2 OCTET STRING OPTIONAL -- referring to content of EF GID2 (file identifier '6F3F') as defined in 3GPP TS 31.102 [54]
@ -207,9 +195,9 @@ StoreMetadataRequest ::= [37] SEQUENCE { -- Tag 'BF25'
profileName [18] UTF8String (SIZE(0..64)), -- Tag '92' (corresponds to 'Short Description' defined in SGP.21 [2])
iconType [19] IconType OPTIONAL, -- Tag '93' (JPG or PNG)
icon [20] OCTET STRING (SIZE(0..1024)) OPTIONAL, -- Tag '94'(Data of the icon. Size 64 x 64 pixel. This field SHALL only be present if iconType is present)
profileClass [21] ProfileClass DEFAULT operational, -- Tag '95'
profileClass [21] ProfileClass OPTIONAL, -- Tag '95' (default if absent: 'operational')
notificationConfigurationInfo [22] SEQUENCE OF NotificationConfigurationInformation OPTIONAL,
profileOwner [23] OperatorId OPTIONAL, -- Tag 'B7'
profileOwner [23] OperatorID OPTIONAL, -- Tag 'B7'
profilePolicyRules [25] PprIds OPTIONAL -- Tag '99'
}
@ -247,7 +235,7 @@ PrepareDownloadRequest ::= [33] SEQUENCE { -- Tag 'BF21'
}
SmdpSigned2 ::= SEQUENCE {
transactionId [0] TransactionId, -- The TransactionID generated by the SM-DP+
transactionId [0] TransactionId, -- The TransactionID generated by the SM DP+
ccRequiredFlag BOOLEAN, --Indicates if the Confirmation Code is required
bppEuiccOtpk [APPLICATION 73] OCTET STRING OPTIONAL -- otPK.EUICC.ECKA already used for binding the BPP, tag '5F49'
}
@ -278,7 +266,7 @@ DownloadErrorCode ::= INTEGER {invalidCertificate(1), invalidSignature(2), unsup
-- Definition of data objects for command AuthenticateServer--------------------
AuthenticateServerRequest ::= [56] SEQUENCE { -- Tag 'BF38'
serverSigned1 ServerSigned1, -- Signed information
serverSignature1 [APPLICATION 55] OCTET STRING, -- tag 5F37
serverSignature1 [APPLICATION 55] OCTET STRING, -- tag ?5F37?
euiccCiPKIdToBeUsed SubjectKeyIdentifier, -- CI Public Key Identifier to be used
serverCertificate Certificate, -- RSP Server Certificate CERT.XXauth.ECDSA
ctxParams1 CtxParams1
@ -292,7 +280,7 @@ ServerSigned1 ::= SEQUENCE {
}
CtxParams1 ::= CHOICE {
ctxParamsForCommonAuthentication CtxParamsForCommonAuthentication -- New contextual data objects MAY be defined for extensibility
ctxParamsForCommonAuthentication CtxParamsForCommonAuthentication -- New contextual data objects may be defined for extensibility
}
CtxParamsForCommonAuthentication ::= SEQUENCE {
@ -333,7 +321,7 @@ CancelSessionRequest ::= [65] SEQUENCE { -- Tag 'BF41'
reason CancelSessionReason
}
CancelSessionReason ::= INTEGER {endUserRejection(0), postponed(1), timeout(2), pprNotAllowed(3), metadataMismatch(4), loadBppExecutionError(5), undefinedReason(127)}
CancelSessionReason ::= INTEGER {endUserRejection(0), postponed(1), timeout(2), pprNotAllowed(3)}
CancelSessionResponse ::= [65] CHOICE { -- Tag 'BF41'
cancelSessionResponseOk CancelSessionResponseOk,
@ -351,13 +339,23 @@ EuiccCancelSessionSigned ::= SEQUENCE {
reason CancelSessionReason
}
-- asn1c caused some bug when process nested id, so workaround here
BoundProfilePackageTLV87 ::= [7] OCTET STRING
BoundProfilePackageTLV88 ::= [8] OCTET STRING
BoundProfilePackageTLV86 ::= [6] OCTET STRING
SeqBoundProfilePackageTLV87 ::= [0] SEQUENCE OF BoundProfilePackageTLV87
SeqBoundProfilePackageTLV88 ::= [1] SEQUENCE OF BoundProfilePackageTLV88
SeqSecondBoundProfilePackageTLV87 ::= [2] SEQUENCE OF BoundProfilePackageTLV87
SeqBoundProfilePackageTLV86 ::= [3] SEQUENCE OF BoundProfilePackageTLV86
-- Definition of Bound Profile Package --------------------------
BoundProfilePackage ::= [54] SEQUENCE { -- Tag 'BF36'
initialiseSecureChannelRequest [35] InitialiseSecureChannelRequest, -- Tag 'BF23'
firstSequenceOf87 [0] SEQUENCE OF [7] OCTET STRING, -- sequence of '87' TLVs
sequenceOf88 [1] SEQUENCE OF [8] OCTET STRING, -- sequence of '88' TLVs
secondSequenceOf87 [2] SEQUENCE OF [7] OCTET STRING OPTIONAL, -- sequence of '87' TLVs
sequenceOf86 [3] SEQUENCE OF [6] OCTET STRING -- sequence of '86' TLVs
firstSequenceOf87 SeqBoundProfilePackageTLV87, -- sequence of '87' TLVs
sequenceOf88 SeqBoundProfilePackageTLV88, -- sequence of '88' TLVs
secondSequenceOf87 SeqSecondBoundProfilePackageTLV87 OPTIONAL, -- sequence of '87' TLVs
sequenceOf86 SeqBoundProfilePackageTLV86 -- sequence of '86' TLVs
}
-- Definition of Get eUICC Challenge --------------------------
@ -368,7 +366,7 @@ GetEuiccChallengeResponse ::= [46] SEQUENCE { -- Tag 'BF2E'
euiccChallenge Octet16 -- random eUICC challenge
}
-- Definition of Profile Installation Result
-- Definition of Profile Installation Resulceipt
ProfileInstallationResult ::= [55] SEQUENCE { -- Tag 'BF37'
profileInstallationResultData [39] ProfileInstallationResultData,
euiccSignPIR EuiccSignPIR
@ -377,14 +375,14 @@ ProfileInstallationResult ::= [55] SEQUENCE { -- Tag 'BF37'
ProfileInstallationResultData ::= [39] SEQUENCE { -- Tag 'BF27'
transactionId[0] TransactionId, -- The TransactionID generated by the SM-DP+
notificationMetadata[47] NotificationMetadata,
smdpOid OBJECT IDENTIFIER, -- SM-DP+ OID (same value as in CERT.DPpb.ECDSA)
smdpOid OBJECT IDENTIFIER OPTIONAL, -- SM-DP+ OID (same value as in CERT.DPpb.ECDSA)
finalResult [2] CHOICE {
successResult SuccessResult,
errorResult ErrorResult
}
}
EuiccSignPIR ::= [APPLICATION 55] OCTET STRING -- Tag '5F37', eUICCs signature
EuiccSignPIR ::= [APPLICATION 55] OCTET STRING -- Tag '5F37', eUICC?s signature
SuccessResult ::= SEQUENCE {
aid [APPLICATION 15] OCTET STRING (SIZE (5..16)), -- AID of ISD-P
@ -411,7 +409,7 @@ ErrorReason ::= INTEGER {
installFailedDueToIccidAlreadyExistsOnEuicc(9), installFailedDueToInsufficientMemoryForProfile(10),
installFailedDueToInterruption(11),
installFailedDueToPEProcessingError (12),
installFailedDueToDataMismatch(13),
installFailedDueToIccidMismatch(13),
testProfileInstallFailedDueToInvalidNaaKey(14),
pprNotAllowed(15),
installFailedDueToUnknownError(127)
@ -428,7 +426,7 @@ ListNotificationResponse ::= [40] CHOICE { -- Tag 'BF28'
NotificationMetadata ::= [47] SEQUENCE { -- Tag 'BF2F'
seqNumber [0] INTEGER,
profileManagementOperation [1] NotificationEvent, --Only one bit SHALL be set to 1
profileManagementOperation [1] NotificationEvent, --Only one bit set to 1
notificationAddress UTF8String, -- FQDN to forward the notification
iccid Iccid OPTIONAL
}
@ -538,7 +536,7 @@ EnableProfileRequest ::= [49] SEQUENCE { -- Tag 'BF31'
}
EnableProfileResponse ::= [49] SEQUENCE { -- Tag 'BF31'
enableResult INTEGER {ok(0), iccidOrAidNotFound (1), profileNotInDisabledState(2), disallowedByPolicy(3), wrongProfileReenabling(4), catBusy(5), undefinedError(127)}
enableResult INTEGER {ok(0), iccidOrAidNotFound (1), profileNotInDisabledState(2), disallowedByPolicy(3), wrongProfileReenabling(4), undefinedError(127)}
}
-- Definition of Disable Profile --------------------------
@ -551,7 +549,7 @@ DisableProfileRequest ::= [50] SEQUENCE { -- Tag 'BF32'
}
DisableProfileResponse ::= [50] SEQUENCE { -- Tag 'BF32'
disableResult INTEGER {ok(0), iccidOrAidNotFound (1), profileNotInEnabledState(2), disallowedByPolicy(3), catBusy(5), undefinedError(127)}
disableResult INTEGER {ok(0), iccidOrAidNotFound (1), profileNotInEnabledState(2), disallowedByPolicy(3), undefinedError(127)}
}
-- Definition of Delete Profile --------------------------
@ -573,7 +571,7 @@ EuiccMemoryResetRequest ::= [52] SEQUENCE { -- Tag 'BF34'
}
EuiccMemoryResetResponse ::= [52] SEQUENCE { -- Tag 'BF34'
resetResult INTEGER {ok(0), nothingToDelete(1), catBusy(5), undefinedError(127)}
resetResult INTEGER {ok(0), nothingToDelete(1), undefinedError(127)}
}
-- Definition of Get EID --------------------------
@ -599,15 +597,13 @@ GetRatResponse ::= [67] SEQUENCE { -- Tag 'BF43'
RulesAuthorisationTable ::= SEQUENCE OF ProfilePolicyAuthorisationRule
ProfilePolicyAuthorisationRule ::= SEQUENCE {
pprIds PprIds,
allowedOperators SEQUENCE OF OperatorId,
allowedOperators SEQUENCE OF OperatorID,
pprFlags BIT STRING {consentRequired(0)}
}
-- Definition of data structure containing the list of CRL segments
SegmentedCrlList ::= SEQUENCE OF CertificateList
-- Definition of data structure command for loading a CRL
LoadCRLRequest ::= [53] SEQUENCE { -- Tag 'BF35'
-- A CRL
-- A CRL-A
crl CertificateList
}
@ -618,9 +614,11 @@ loadCRLResponseError LoadCRLResponseError
}
LoadCRLResponseOk ::= SEQUENCE {
missingParts SEQUENCE OF INTEGER OPTIONAL
missingParts SEQUENCE OF SEQUENCE {
number INTEGER (0..MAX)
} OPTIONAL
}
LoadCRLResponseError ::= INTEGER {invalidSignature(1), invalidCRLFormat(2), notEnoughMemorySpace(3), verificationKeyNotFound(4), fresherCrlAlreadyLoaded(5), baseCrlMissing(6), undefinedError(127)}
LoadCRLResponseError ::= INTEGER {invalidSignature(1), invalidCRLFormat(2), notEnoughMemorySpace(3), verificationKeyNotFound(4), undefinedError(127)}
-- Definition of the extension for Certificate Expiration Date
id-rsp-expDate OBJECT IDENTIFIER ::= {id-rspExt 1}
@ -693,7 +691,6 @@ AuthenticateClientResponseEs9 ::= [59] CHOICE { -- Tag 'BF3B'
noEligibleProfile(8),
ciPKUnknown(9),
invalidTransactionId(10),
insufficientMemory(11),
undefinedError(127)
}
}
@ -701,9 +698,7 @@ AuthenticateClientResponseEs9 ::= [59] CHOICE { -- Tag 'BF3B'
AuthenticateClientOk ::= SEQUENCE {
transactionId [0] TransactionId,
profileMetaData [37] StoreMetadataRequest,
smdpSigned2 SmdpSigned2, -- Signed information
smdpSignature2 [APPLICATION 55] OCTET STRING, -- tag '5F37'
smdpCertificate Certificate -- CERT.DPpb.ECDSA
prepareDownloadRequest [33] PrepareDownloadRequest
}
GetBoundProfilePackageRequest ::= [58] SEQUENCE { -- Tag 'BF3A'
@ -718,8 +713,6 @@ GetBoundProfilePackageResponse ::= [58] CHOICE { -- Tag 'BF3A'
confirmationCodeMissing(2),
confirmationCodeRefused(3),
confirmationCodeRetriesExceeded(4),
bppRebindingRefused(5),
downloadOrderExpired(6),
invalidTransactionId(95),
undefinedError(127)
}

View file

@ -1,3 +1,3 @@
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} LIB_CJSON_SRCS)
include_directories(.)
aux_source_directory(. LIB_CJSON_SRCS)
add_library(cjson-static STATIC ${LIB_CJSON_SRCS})
target_include_directories(cjson-static PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)

View file

@ -1,15 +0,0 @@
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR "aarch64")
set(CMAKE_C_COMPILER "zig" cc -target aarch64-windows-gnu)
set(CMAKE_CXX_COMPILER "zig" c++ -target aarch64-windows-gnu)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -s")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -s")
if(WIN32)
set(SCRIPT_SUFFIX ".cmd")
else()
set(SCRIPT_SUFFIX ".sh")
endif()
set(CMAKE_AR "${CMAKE_CURRENT_LIST_DIR}/zig-ar${SCRIPT_SUFFIX}")
set(CMAKE_RANLIB "${CMAKE_CURRENT_LIST_DIR}/zig-ranlib${SCRIPT_SUFFIX}")

View file

@ -1,25 +0,0 @@
# from https://github.com/nocnokneo/cmake-git-versioning-example
if(GIT_EXECUTABLE)
get_filename_component(SRC_DIR ${SRC} DIRECTORY)
# Generate a git-describe version string from Git repository tags
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --always --tags --dirty --match "v*"
WORKING_DIRECTORY ${SRC_DIR}
OUTPUT_VARIABLE GIT_DESCRIBE_VERSION
RESULT_VARIABLE GIT_DESCRIBE_ERROR_CODE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT GIT_DESCRIBE_ERROR_CODE)
set(LPAC_VERSION ${GIT_DESCRIBE_VERSION})
endif()
endif()
# Final fallback: Just use a bogus version string that is semantically older
# than anything else and spit out a warning to the developer.
if(NOT DEFINED LPAC_VERSION)
set(LPAC_VERSION v0.0.0-unknown)
message(WARNING "Failed to determine LPAC_VERSION from Git tags. Using default version \"${LPAC_VERSION}\".")
endif()
configure_file(${SRC} ${DST} @ONLY)

View file

@ -1,15 +0,0 @@
set(CMAKE_SYSTEM_NAME Windows)
set(TOOLCHAIN_PREFIX i686-w64-mingw32)
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
set(CMAKE_Fortran_COMPILER ${TOOLCHAIN_PREFIX}-gfortran)
set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

View file

@ -1,13 +0,0 @@
set(CMAKE_SYSTEM_NAME Windows)
set(TOOLCHAIN_PREFIX ${TOOLCHAIN_BIN_PATH}/aarch64-w64-mingw32)
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
set(CMAKE_Fortran_COMPILER ${TOOLCHAIN_PREFIX}-gfortran)
set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

View file

@ -1,15 +0,0 @@
set(CMAKE_SYSTEM_NAME Windows)
set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
set(CMAKE_Fortran_COMPILER ${TOOLCHAIN_PREFIX}-gfortran)
set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

View file

@ -1,2 +0,0 @@
@echo off
zig ar %*

View file

@ -1,2 +0,0 @@
#!/bin/sh
zig ar "$@"

View file

@ -1,2 +0,0 @@
@echo off
zig ranlib %*

View file

@ -1,2 +0,0 @@
#!/bin/sh
zig ranlib "$@"

View file

@ -1,3 +1,3 @@
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} LIB_DLFCN_SRCS)
include_directories(.)
aux_source_directory(. LIB_DLFCN_SRCS)
add_library(dlfcn-win32 STATIC ${LIB_DLFCN_SRCS})
target_include_directories(dlfcn-win32 PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)

View file

@ -1,17 +0,0 @@
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View file

@ -418,7 +418,7 @@ void *dlopen( const char *file, int mode )
* Behavior and doesn't provide expected search paths.
* See also: https://github.com/dlfcn-win32/dlfcn-win32/issues/104
*/
hModule = LoadLibraryExA( lpFileName, NULL, 0 );
hModule = LoadLibraryExA( lpFileName, NULL, NULL );
if( !hModule )
{
@ -758,7 +758,7 @@ static BOOL is_import_thunk( const void *addr )
#endif
}
/* Return address from the import address table (iat),
/* Return adress from the import address table (iat),
* if the original address points to a thunk table entry.
*/
static void *get_address_from_import_address_table( void *iat, DWORD iat_size, const void *addr )

View file

@ -1,90 +0,0 @@
# Developer Manual
## Coding Standard
lpac is written with C99 and compatible with [SGP.22 version 2.2.2](https://www.gsma.com/solutions-and-impact/technologies/esim/wp-content/uploads/2020/06/SGP.22-v2.2.2.pdf).
## How to Compile
### Linux
#### Debian/Ubuntu
``` bash
# clone this repo in the top-level folder
# install dependencies
./scripts/setup-debian.sh
```
Run `cmake` and `make`, compiled output will be in `output` directory.
If you want to get a Deb package, run `cmake -DCPACK_GENERATOR=DEB` then `make`.
#### Droidian
Same as normal Debian/Ubuntu, however, in order to build the GBinder backends, you will need `libgbinder-dev`, `glib2.0-dev`, and you will have to pass `-DLPAC_WITH_APDU_GBINDER=ON` when invoking `cmake`.
---
### macOS
Install [Homebrew](https://brew.sh/).
Run `cmake` and `make`, compiled output will be in `output` directory.
---
### Windows(x86_64)
Windows need libcurl.dll to run.
Download libcurl from <https://curl.se/download.html> and place it as `libcurl.dll` in `output` directory.
Install prerequisites, run `cmake` and `make`, compiled output will be in `output` directory.
#### Build on Linux(MINGW)
Require `build-essential` `cmake` `git` `g++` `libpcsclite-dev` `libcurl4-openssl-dev` `gcc-mingw-w64` `g++-mingw-w64` installed.
#### Build on Windows(MSYS2)
Require `mingw-w64-x86_64-cmake` `mingw-w64-x86_64-gcc` installed.
#### Build on Windows(Cygwin)
Require `gcc-core` `gcc-g++` `make` `cmake` `unzip` `wget` installed.
To run it outside Cygwin shell, you need copy `cygwin1.dll` to the program folder to distribute.
`cygwin1.dll` is located in `C:\cygwin64\bin\cygwin1.dll` (Default Cygwin installation location)
---
### Windows on ARM
#### Cross compile on Windows/Linux host(arm64,x86_64 and more architecture) with zig
Install [zig](https://ziglang.org/download/)
```bash
# clone this repo in the top-level folder
./scripts/build-woa.sh zig
```
#### Cross compile on Linux x86_64 host(GNU toolchain)
```bash
# clone this repo in the top-level folder
./scripts/build-woa.sh mingw
```
#### Build on Native Windows on ARM(MSYS2)
It is possible to build on **WoA devices** with [MSYS2 ARM64 Support](https://www.msys2.org/wiki/arm64/)
You may need to install `mingw-w64-clang-aarch64-cmake`, `mingw-w64-clang-aarch64-clang` and modify `cmake/linux-mingw64.cmake`(replace toolchain).
Download prebuilt curl dll is also needed. Refer to the previous compilation steps.
## Debug
Please see [debug environment variables](ENVVARS.md#debug)

View file

@ -1,31 +0,0 @@
# Environment Variables
## General
* `LPAC_CUSTOM_ES10X_MSS`: specify maximum segment size for ES10x APDU backend. (default: 120, min: 6, max: 255)
* `LPAC_CUSTOM_ISD_R_AID`: specify which AID will be used to open the logic channel. (hex string, 32 chars)
* `LPAC_APDU`: specify which APDU backend will be used. Values:
- `at`: use AT commands interface used by LTE module
- `pcsc`: use PC/SC Smart Card API
- `stdio`: use standard input/output
- `qmi`: use QMI
- `qmi_qrtr`: use QMI over QRTR
- `mbim`: use MBIM
- GBinder-based backends for `libhybris` (Halium) distributions:
- `gbinder_hidl`: use HIDL IRadio (SoC launched before Android 13)
* `LPAC_HTTP`: specify which HTTP backend will be used.
- `curl`: use libcurl
- `stdio`: use standard input/output
* `AT_DEVICE`: specify which serial port device will be used by AT APDU backend.
* `QMI_DEVICE`: specify which QMI device will be used by QMI APDU backend.
* `UIM_SLOT`: specify which UIM slot will be used by QMI and MBIM APDU backends. (default: 1, slot number starts from 1)
* `DRIVER_IFID`: specify which PC/SC interface will be used by PC/SC APDU backend.
* `MBIM_DEVICE`: specify which MBIM device will be used by MBIM APDU backend. (default: `/dev/cdc-wdm0`)
* `MBIM_USE_PROXY`: tell the MBIM APDU backend to use the mbim-proxy. (default: 0, anything other than 0 means true)
## Debug
* `LIBEUICC_DEBUG_APDU`: enable debug output for APDU.
* `LIBEUICC_DEBUG_HTTP`: enable debug output for HTTP.
* `AT_DEBUG`: enable debug output for AT APDU backend.
* `GBINDER_APDU_DEBUG`: enable debug output for GBinder APDU backend. MUST be `true` to take effect.

View file

@ -1,18 +0,0 @@
## FAQ
### Any subcommand of lpac will get error message like "SCardListReaders() failed:" and 8-digits error code, such as 80100069, 80100066, 8010002E, 8010000F and so on.
- [80100069] means your UICC is not plugged correctly
- [80100066] means your card has no response, please clean the pin and plug in again
- [8010002E] means communication error
- [8010000F] means the card is not a eUICC, or detect wrong card reader like Yubikey. For latter one, you can use `lpac driver apdu list` to list all reader and use `$DRIVER_IFID` to specify correct card reader
- for others, Google is your friend.
[80100069]: https://pcsclite.apdu.fr/api/group__ErrorCodes.html#gaa2efd953946973972b1afc5d0343820c
[80100066]: https://pcsclite.apdu.fr/api/group__ErrorCodes.html#ga359a9e85e3b7c83c76507a096452b74f
[8010002E]: https://pcsclite.apdu.fr/api/group__ErrorCodes.html#ga81b59e9319d3fcd0d957d98781b3ebd2
[8010000F]: https://pcsclite.apdu.fr/api/group__ErrorCodes.html#ga36d821a0458f935ddbe345f10408a988
### I can't download eSIM profile of xxx.
The verification of SM-DP+ servers of telecom operators is diverse. Please check whether the parameters you enter are consistent with those provided to you by the telecom operators. Some telecom operators issue profiles in the form of push, which may require the use of lpac's discovery and custom IMEI function.

View file

@ -1,59 +0,0 @@
# Linux distributions
> [!CAUTION]
>
> **All Linux distribution packages are unofficially maintained.**
## OpenWrt
> Minimum available release: Snapshot
> (Added on 2024-05-15)
```shell
opkg install lpac
```
see <https://github.com/openwrt/packages/blob/master/utils/lpac/Makefile>
## Alpine
> Minimum available release: [v3.20.0](https://pkgs.alpinelinux.org/packages?name=lpac&branch=v3.20)
> (Release date: 2024-05-22).
```shell
pkg install lpac
```
see <https://github.com/alpinelinux/aports/blob/master/community/lpac/APKBUILD>
## Arch Linux
> Need to enable [archlinuxcn repo](https://github.com/archlinuxcn/repo#readme) first
>
> If you want to use AUR, the package name is [lpac-git](https://aur.archlinux.org/packages/lpac-git)
```shell
pacman -S lpac
# or
pacman -S lpac-git
```
see <https://github.com/archlinuxcn/repo/blob/master/archlinuxcn/lpac/PKGBUILD> \
see <https://github.com/archlinuxcn/repo/blob/master/archlinuxcn/lpac-git/PKGBUILD>
## Nix OS
> Need to enable [NUR](https://github.com/nix-community/NUR#readme "Nix User Repository") first
```shell
nix-env -i lpac
```
see <https://github.com/nix-community/nur-combined/blob/master/repos/linyinfeng/pkgs/lpac/default.nix>
## Ubuntu and Debian/Devuan
> Minimum available release: Ubuntu [14.04 Trusty Tahr](https://releases.ubuntu.com/14.04/)
> (Published on 2024-09-01)
see <https://launchpad.net/~daniel-gimpelevich/+archive/ubuntu/ssl/+sourcepub/17063242/+listing-archive-extra>

View file

@ -1,333 +0,0 @@
## Usage
In Linux, you need to install `pcscd`, `pcsclite` and `libcurl`.
APDU and HTTP interfaces of lpac has several backends, you need to specify `$LPAC_APDU` and `$LPAC_HTTP` environment variables to interface library path. If not specified, it will use `pcsc` and `curl`. See also [environment variables](ENVVARS.md).
Using `at` APDU backend need access permission to serial port (normally `/dev/ttyUSBx`). On Arch Linux, you can add yourself to `uucp` group by `sudo usermod -aG uucp $USER`. On other distro, you may need to add yourself into `dialout` group. If your serial port is not `/dev/ttyUSB0`, please use `$AT_DEVICE` to specify which one you want to use.
## CLI
### Command format
```plain
lpac <subcommand> [subcommand] [parameters]
subcommand:
chip View and manage information about your eUICC card itself
profile Manage the profile of your eUICC card
notification Manage notifications within your eUICC card
driver View libXXXXinterface info
subcommand 2:
Please refer to the detailed instructions below
```
### Return value
The return contents of lpac instructions are all in json format, and the returns of all instructions comply with the following format.
```jsonc
{
"type": "lpa",
"payload": {
"code": 0,
"message": "success",
"data": {/* .... */}
}
}
```
- `"type": "lpa"`: fixed content
- `code`: if is 0, indicating successful execution, and other values are error codes.
- `message`: is success if the operation is successful, or the error type is returned if an error occurs.
- `data`: returns the returned content when the operation is successful, and is empty (but not NULL) when there is an error.
### Subcommand
#### chip
View the EID, default SM-DP+ server and SM-DS server of eUICC. euicc_info2 is also supported.
```plain
lpac chip <subcommand> [parameters]
subcommand:
info View information about your eUICC card itself
defaultsmdp Modify the default SM-DP+ server address of your eUICC card
Example: lpac chip defaultsmdp <the address of the SM-DP+ server you want to modify>
purge Reset the eUICC and will clear all profiles. Use with caution!
```
<details>
<summary>Return value example</summary>
```json
{
"type": "lpa",
"payload": {
"code": 0,
"message": "success",
"data": {
"eidValue": "[EID]",
"EuiccConfiguredAddresses": {
"defaultDpAddress": null,
"rootDsAddress": "testrootsmds.gsma.com"
},
"EUICCInfo2": {
"profileVersion": "2.1.0",
"svn": "2.2.0",
"euiccFirmwareVer": "4.6.0",
"extCardResource": {
"installedApplication": 0,
"freeNonVolatileMemory": 291666,
"freeVolatileMemory": 5970
},
"uiccCapability": [
"usimSupport",
"isimSupport",
"csimSupport",
"akaMilenage",
"akaCave",
"akaTuak128",
"akaTuak256",
"gbaAuthenUsim",
"gbaAuthenISim",
"eapClient",
"javacard",
"multipleUsimSupport",
"multipleIsimSupport"
],
"ts102241Version": "9.2.0",
"globalplatformVersion": "2.3.0",
"rspCapability": [
"additionalProfile",
"testProfileSupport"
],
"euiccCiPKIdListForVerification": [
"81370f5125d0b1d408d4c3b232e6d25e795bebfb"
],
"euiccCiPKIdListForSigning": [
"81370f5125d0b1d408d4c3b232e6d25e795bebfb"
],
"euiccCategory": null,
"forbiddenProfilePolicyRules": [
"pprUpdateControl",
"ppr1"
],
"ppVersion": "0.0.1",
"sasAcreditationNumber": "GI-BA-UP-0419",
"certificationDataObject": {
"platformLabel": "1.2.840.1234567/myPlatformLabel",
"discoveryBaseURL": "https://mycompany.com/myDLOARegistrar"
}
}
}
}
}
```
\* Starting from SGP.22 v2.1, `javacardVersion` is renamed to `ts102241Version` \
\*\* SGP.22 has been a typo, `sasAcreditationNumber` should be `sasAccreditationNumber`
</details>
#### profile
Profile management, you can list, set alias (nickname), enable, disable, delete, download and discovery Profiles.
```plain
lpac profile <subcommand> [parameters]
subcommand:
list enumerates your eUICC Profile
nickname sets an alias for the specified Profile
Example: lpac profile nickname <ICCID of Profile> <alias>
enable enables the specified Profile. The RefreshFlag status is enabled by default and can be omitted.
Example: lpac profile enable <ICCID/AID of Profile> [1/0]
disable disables the specified Profile. The RefreshFlag state is enabled by default and can be omitted.
Example: lpac profile disable <ICCID/AID of Profile> [1/0]
delete deletes the specified Profile
Example: lpac profile delete <ICCID/AID of Profile>
download Download profile from SM-DP server
discovery Detect available profile registered on SM-DS server
```
> [!NOTE]
> Some eUICC chips have trouble when enabling profile (e.g. These removable eUICC cards from ECP), try AID, ICCID, refreshFlag with 1 or 0 to find out the working way for these chips.
There is no secondary confirmation for deleting a Profile, so please perform it with caution.
> [!NOTE]
> This function will only delete the Profile and issue a Notification, but it will not be sent automatically. You need to send it manually.
##### Download requires connection to SM-DP+ server and the following additional parameters:
- `-s`: SM-DP+ server, optional, if not provided, it will try to read the default sm-dp+ attribute.
- `-m`: Matching ID, activation code. optional.
- `-c`: Confirmation Code, optional.
- `-i`: The IMEI of the device to which Profile is to be downloaded, optional.
- `-a`: LPA qrcode activation code string, e.g: `LPA:1$<sm-dp+ domain>$<matching id>`, if provided, this option takes precedence over the `-s` and `-m` options, optional.
- `-p`: Interactive preview mode, optional.
<details>
<summary>Example</summary>
```bash
./lpac profile download -s rsp.truphone.com -m "QR-G-5C-1LS-1W1Z9P7"
# LPA qrcode activation code string
./lpac profile download -a 'LPA:1$rsp.truphone.com$QR-G-5C-1LS-1W1Z9P7'
```
</details>
##### Discovery requires connecting to the SM-DS server to query registered profile
The following parameters can be used to customize the IMEI and SM-DS server:
- `-s`: SM-DS server. If not provided, it will be gsma official server "lpa.ds.gsma.com"
- `-i`: IMEI of the device to which Profile is to be downloaded, optional
<details>
<summary>Return value example of lpac profile list</summary>
```json
{
"type": "lpa",
"payload": {
"code": 0,
"message": "success",
"data": [
{
"iccid": "89353...",
"isdpAid": "A0000005591010FFFFFFFF8900001000",
"profileState": "disabled",
"profileNickname": null,
"serviceProviderName": "Vodafone IE",
"profileName": "Vodafone IE eSIM",
"iconType": "png",
"icon": "iVBO...",
"profileClass": "operational"
},
{
"iccid": "89012...",
"isdpAid": "A0000005591010FFFFFFFF8900001100",
"profileState": "disabled",
"profileNickname": null,
"serviceProviderName": "T-Mobile",
"profileName": "CONVSIM5G_Adaptive",
"iconType": "png",
"icon": "iVBO...",
"profileClass": "operational"
},
{
"iccid": "89444...",
"isdpAid": "A0000005591010FFFFFFFF8900001200",
"profileState": "enabled",
"profileNickname": null,
"serviceProviderName": "BetterRoaming",
"profileName": "BetterRoaming",
"iconType": "none",
"icon": null,
"profileClass": "operational"
},
{
"iccid": "89852...",
"isdpAid": "A0000005591010FFFFFFFF8900001300",
"profileState": "disabled",
"profileNickname": null,
"serviceProviderName": "Redtea Mobile",
"profileName": "RedteaGO",
"iconType": "none",
"icon": null,
"profileClass": "operational"
}
]
}
}
```
- `iccid`: ICCID of Profile
- `isdpAid`: Aid of Profile
- `profileState`: State of Profile, "Enabled" or "Disabled"
- `profileNickname`: Nickname of Profile
- `serviceProviderName`: Telecom operators of Profile
- `profileName`: Name of Profile
- `iconType`: Profile icon data struct, "none", "png", "jpg"
- `icon`: Profile icon data in base64
- `profileClass`: Type of Profile
</details>
#### notification
Used for the management of Notifications, which are sent by telecom operators during Profile operations. You can enumerate (list), send (process), and remove (remove) Notifications.
```plain
lpac notification <subcommand> [parameters]
subcommand:
list Enumerates your eUICC pending Notification list
process Send Notification
Example: lpac notification process <sequence ID>
remove Remove Notification
Example: lpac notification remove <sequence ID>
```
> [!NOTE]
> Downstream developers or end users should process Notification as soon as possible when they exist to comply with GSMA specifications. lpac will not automatically delete the Notification after sending it. You can pass `-r` to `notification process` or you need to delete it manually.
<details>
<summary>Return value example of lpac notification list</summary>
```json
{
"type": "lpa",
"payload": {
"code": 0,
"message": "success",
"data": [
{
"seqNumber": 178,
"profileManagementOperation": "install",
"notificationAddress": "rsp-eu.redteamobile.com",
"iccid": "89852..."
},
{
"seqNumber": 215,
"profileManagementOperation": "disable",
"notificationAddress": "cust-005-v4-prod-atl2.gdsb.net",
"iccid": "89012..."
},
{
"seqNumber": 216,
"profileManagementOperation": "enable",
"notificationAddress": "rsp.truphone.com",
"iccid": "89444..."
}
]
}
}
```
- `seqNumber`: Sequence ID
- `profileManagementOperation`: Which operation generated this notification
- `notificationAddress`: Profile's notification reporting server address
</details>
##### Processing requires connection to server and the following optional parameters:
The following parameters can be used to customize the behavior of `notification process`:
- `-a`: Process all notifications
- `-r`: Automatically remove processed notifications
##### Removing supports the following optional parameters:
The following parameters can be used to customize the behavior of `notification remove`:
- `-a`: Remove all notifications
#### driver
Now, there is only one command: `lpac driver apdu list` to get the card reader list.

View file

@ -1,144 +0,0 @@
include(CMakeDependentOption)
cmake_dependent_option(LPAC_DYNAMIC_DRIVERS "Build lpac/libeuicc driver backends as a dynamic library" OFF "LPAC_DYNAMIC_LIBEUICC" OFF)
option(LPAC_WITH_APDU_PCSC "Build APDU PCSC Backend (requires PCSC libraries)" ON)
if(LINUX)
option(LPAC_WITH_APDU_AT "Build APDU AT Backend" ON)
else()
option(LPAC_WITH_APDU_AT "Build APDU AT Backend" OFF)
endif()
option(LPAC_WITH_APDU_GBINDER "Build APDU Gbinder backend for libhybris devices (requires gbinder headers)" OFF)
option(LPAC_WITH_APDU_QMI "Build QMI backend for Qualcomm devices (requires libqmi)" OFF)
option(LPAC_WITH_APDU_QMI_QRTR "Build QMI-over-QRTR backend for Qualcomm devices (requires libqrtr and libqmi headers)" OFF)
option(LPAC_WITH_APDU_MBIM "Build MBIM backend for MBIM devices (requires libmbim)" OFF)
option(LPAC_WITH_HTTP_CURL "Build HTTP Curl interface" ON)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} DIR_INTERFACE_SRCS)
if(LPAC_DYNAMIC_DRIVERS)
add_library(euicc-drivers SHARED ${DIR_INTERFACE_SRCS})
list(APPEND LIBEUICC_DRIVERS_REQUIRES "libeuicc = ${PROJECT_VERSION}")
else()
add_library(euicc-drivers STATIC ${DIR_INTERFACE_SRCS})
endif()
target_link_libraries(euicc-drivers euicc cjson-static)
target_include_directories(euicc-drivers PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_sources(euicc-drivers PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/apdu/stdio.c)
target_sources(euicc-drivers PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/http/stdio.c)
if(LPAC_WITH_APDU_PCSC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLPAC_WITH_APDU_PCSC")
target_sources(euicc-drivers PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/apdu/pcsc.c)
if(WIN32)
target_sources(euicc-drivers PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/apdu/pcsc_win32.c)
target_link_libraries(euicc-drivers winscard)
elseif(APPLE)
target_link_libraries(euicc-drivers "-framework PCSC")
if(LPAC_DYNAMIC_DRIVERS)
# for pkg-config
set(LIBEUICC_DRIVERS_EXTRA_CFLAGS "-framework PCSC")
endif()
else()
find_package(PCSCLite)
target_link_libraries(euicc-drivers PCSCLite::PCSCLite)
if(LPAC_DYNAMIC_DRIVERS)
list(APPEND LIBEUICC_DRIVERS_REQUIRES "libpcsclite")
endif()
endif()
endif()
if(LPAC_WITH_APDU_AT)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLPAC_WITH_APDU_AT")
target_sources(euicc-drivers PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/apdu/at.c)
endif()
if(LPAC_WITH_APDU_GBINDER)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLPAC_WITH_APDU_GBINDER")
target_sources(euicc-drivers PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/apdu/gbinder_hidl.c)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GBINDER REQUIRED IMPORTED_TARGET libgbinder)
pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0)
target_link_libraries(euicc-drivers PkgConfig::GBINDER PkgConfig::GLIB)
if(LPAC_DYNAMIC_DRIVERS)
list(APPEND LIBEUICC_DRIVERS_REQUIRES "libgbinder")
list(APPEND LIBEUICC_DRIVERS_REQUIRES "glib-2.0")
endif()
endif()
if(LPAC_WITH_APDU_QMI)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLPAC_WITH_APDU_QMI")
target_sources(euicc-drivers PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/apdu/qmi.c
${CMAKE_CURRENT_SOURCE_DIR}/apdu/qmi_helpers.c
${CMAKE_CURRENT_SOURCE_DIR}/apdu/qmi_common.c)
find_package(PkgConfig REQUIRED)
pkg_check_modules(QMI_GLIB REQUIRED IMPORTED_TARGET qmi-glib>=1.35.5)
target_link_libraries(euicc-drivers PkgConfig::QMI_GLIB)
if(LPAC_DYNAMIC_DRIVERS)
list(APPEND LIBEUICC_DRIVERS_REQUIRES "qmi-glib")
endif()
endif()
if(LPAC_WITH_APDU_QMI_QRTR)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLPAC_WITH_APDU_QMI_QRTR")
target_sources(euicc-drivers PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/apdu/qmi_qrtr.c
${CMAKE_CURRENT_SOURCE_DIR}/apdu/qmi_helpers.c
${CMAKE_CURRENT_SOURCE_DIR}/apdu/qmi_common.c)
find_package(PkgConfig REQUIRED)
pkg_check_modules(QRTR_GLIB REQUIRED IMPORTED_TARGET qrtr-glib)
pkg_check_modules(QMI_GLIB REQUIRED IMPORTED_TARGET qmi-glib>=1.35.5)
target_link_libraries(euicc-drivers PkgConfig::QRTR_GLIB PkgConfig::QMI_GLIB)
if(LPAC_DYNAMIC_DRIVERS)
list(APPEND LIBEUICC_DRIVERS_REQUIRES "qrtr-glib")
list(APPEND LIBEUICC_DRIVERS_REQUIRES "qmi-glib")
endif()
endif()
if(LPAC_WITH_APDU_MBIM)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLPAC_WITH_APDU_MBIM")
target_sources(euicc-drivers PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/apdu/mbim.c
${CMAKE_CURRENT_SOURCE_DIR}/apdu/mbim_helpers.c)
find_package(PkgConfig REQUIRED)
pkg_check_modules(MBIM_GLIB REQUIRED IMPORTED_TARGET mbim-glib)
target_link_libraries(euicc-drivers PkgConfig::MBIM_GLIB PkgConfig::MBIM_GLIB)
if(LPAC_DYNAMIC_DRIVERS)
list(APPEND LIBEUICC_DRIVERS_REQUIRES "mbim-glib")
endif()
endif()
if(LPAC_WITH_HTTP_CURL)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLPAC_WITH_HTTP_CURL")
target_sources(euicc-drivers PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/http/curl.c)
if(WIN32)
target_link_libraries(euicc-drivers ${DL_LIBRARY})
else()
find_package(CURL REQUIRED)
target_link_libraries(euicc-drivers curl)
if(LPAC_DYNAMIC_DRIVERS)
list(APPEND LIBEUICC_DRIVERS_REQUIRES "libcurl")
endif()
endif()
endif()
if(LPAC_DYNAMIC_DRIVERS)
# Install headers
file(GLOB ALL_HEADERS "*.h")
foreach(header ${ALL_HEADERS})
if(${header} MATCHES "^.*\.private\.h$")
list(REMOVE_ITEM ALL_HEADERS ${header})
endif()
endforeach()
set_target_properties(euicc-drivers PROPERTIES PUBLIC_HEADER "${ALL_HEADERS}")
# Install a pkg-config file (mainly for Linux; macOS is untested; Win32 is not supported)
if(UNIX)
list(JOIN LIBEUICC_DRIVERS_REQUIRES ", " LIBEUICC_DRIVERS_REQUIRES)
configure_file(libeuicc-drivers.pc.in libeuicc-drivers.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libeuicc-drivers.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
endif()
set_target_properties(euicc-drivers PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR})
install(TARGETS euicc-drivers LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/euicc)
endif()

View file

@ -1,661 +0,0 @@
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate. Many developers of free software are heartened and
encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<https://www.gnu.org/licenses/>.

View file

@ -1,4 +0,0 @@
#pragma once
#include <driver.private.h>
extern const struct euicc_driver driver_apdu_at;

View file

@ -1,328 +0,0 @@
// vim: expandtab sw=4 ts=4:
#include "gbinder_hidl.h"
#include <euicc/euicc.h>
#include <euicc/hexutil.h>
#include <euicc/interface.h>
#include <gbinder.h>
#include <stdio.h>
#include <stdlib.h>
#define DEBUG (getenv("GBINDER_APDU_DEBUG") != NULL && strcmp("true", getenv("GBINDER_APDU_DEBUG")) == 0)
#define HIDL_SERVICE_DEVICE "/dev/hwbinder"
#define HIDL_SERVICE_IFACE "android.hardware.radio@1.0::IRadio"
#define HIDL_SERVICE_IFACE_CALLBACK "android.hardware.radio@1.0::IRadioResponse"
// ref: IRadio
#define HIDL_SERVICE_SET_RESPONSE_FUNCTIONS GBINDER_FIRST_CALL_TRANSACTION
#define HIDL_SERVICE_ICC_OPEN_LOGICAL_CHANNEL (GBINDER_FIRST_CALL_TRANSACTION + 105)
#define HIDL_SERVICE_ICC_CLOSE_LOGICAL_CHANNEL (GBINDER_FIRST_CALL_TRANSACTION + 106)
#define HIDL_SERVICE_ICC_TRANSMIT_APDU_LOGICAL_CHANNEL (GBINDER_FIRST_CALL_TRANSACTION + 107)
// ref: IRadioResponse
#define HIDL_SERVICE_ICC_OPEN_LOGICAL_CHANNEL_CALLBACK (GBINDER_FIRST_CALL_TRANSACTION + 104)
#define HIDL_SERVICE_ICC_CLOSE_LOGICAL_CHANNEL_CALLBACK (GBINDER_FIRST_CALL_TRANSACTION + 105)
#define HIDL_SERVICE_ICC_TRANSMIT_APDU_LOGICAL_CHANNEL_CALLBACK (GBINDER_FIRST_CALL_TRANSACTION + 106)
static int lastChannelId = -1;
struct radio_response_info {
int32_t type;
int32_t serial;
int32_t error;
};
struct icc_io_result {
int32_t sw1;
int32_t sw2;
GBinderHidlString simResponse;
};
struct sim_apdu {
int32_t sessionId;
int32_t cla;
int32_t instruction;
int32_t p1;
int32_t p2;
int32_t p3;
GBinderHidlString data;
};
static const GBinderWriterField sim_apdu_f[] = {
GBINDER_WRITER_FIELD_HIDL_STRING(struct sim_apdu, data),
GBINDER_WRITER_FIELD_END()
};
static const GBinderWriterType sim_apdu_t = {
GBINDER_WRITER_STRUCT_NAME_AND_SIZE(struct sim_apdu), sim_apdu_f
};
static GBinderServiceManager *sm;
// IRadioResponse
static GBinderLocalObject *response_callback;
// IRadio
static GBinderRemoteObject *remote;
static GBinderClient *client;
static GMainLoop *binder_loop;
static int lastIntResp = -1;
static int lastRadioErr = 0;
static struct icc_io_result lastIccIoResult = {0};
static GBinderLocalReply *radio_response_transact(
GBinderLocalObject *obj,
GBinderRemoteRequest *req,
guint code, guint flags, int *status, void *user_data)
{
GBinderReader reader;
gbinder_remote_request_init_reader(req, &reader);
const struct radio_response_info *resp =
gbinder_reader_read_hidl_struct(&reader, struct radio_response_info);
lastRadioErr = resp->error;
if (lastRadioErr != 0)
goto out;
switch (code) {
case HIDL_SERVICE_ICC_OPEN_LOGICAL_CHANNEL_CALLBACK:
gbinder_reader_read_int32(&reader, &lastIntResp);
break;
case HIDL_SERVICE_ICC_TRANSMIT_APDU_LOGICAL_CHANNEL_CALLBACK: {
const struct icc_io_result *icc_io_res = gbinder_reader_read_hidl_struct(&reader, struct icc_io_result);
// We cannot rely on the *req pointer being valid after we return
lastIccIoResult.sw1 = icc_io_res->sw1;
lastIccIoResult.sw2 = icc_io_res->sw2;
lastIccIoResult.simResponse.data.str = strndup(icc_io_res->simResponse.data.str, icc_io_res->simResponse.len);
lastIccIoResult.simResponse.len = icc_io_res->simResponse.len;
lastIccIoResult.simResponse.owns_buffer = TRUE;
break;
}
}
out:
g_main_loop_quit(binder_loop);
return NULL;
}
static void cleanup_channel(int id)
{
GBinderLocalRequest *req = gbinder_client_new_request(client);
GBinderWriter writer;
gbinder_local_request_init_writer(req, &writer);
gbinder_writer_append_int32(&writer, 1000);
gbinder_writer_append_int32(&writer, id);
gbinder_client_transact_sync_oneway(client, HIDL_SERVICE_ICC_CLOSE_LOGICAL_CHANNEL, req);
gbinder_local_request_unref(req);
g_main_loop_run(binder_loop);
}
static void cleanup(void)
{
if (lastChannelId != -1) {
fprintf(stderr, "Cleaning up leaked APDU channel %d\n", lastChannelId);
cleanup_channel(lastChannelId);
lastChannelId = -1;
}
}
static void sighandler(int sig)
{
// This would trigger atexit() hooks
exit(0);
}
static int try_open_slot(int slotId, const uint8_t *aid, uint32_t aid_len)
{
// First, try to connect to the HIDL service for this slot
char fqname[255];
snprintf(fqname, 255, "%s/slot%d", HIDL_SERVICE_IFACE, slotId);
fprintf(stderr, "Attempting to connect to %s\n", fqname);
int status = 0;
sm = gbinder_servicemanager_new(HIDL_SERVICE_DEVICE);
remote = gbinder_remote_object_ref(
gbinder_servicemanager_get_service_sync(sm, fqname, &status));
client = gbinder_client_new(remote, HIDL_SERVICE_IFACE);
if (!client) {
fprintf(stderr, "Failed to connect to IRadio\n");
gbinder_client_unref(client);
gbinder_remote_object_unref(remote);
gbinder_servicemanager_unref(sm);
return -1;
}
response_callback = gbinder_servicemanager_new_local_object(
sm, HIDL_SERVICE_IFACE_CALLBACK, radio_response_transact, NULL);
GBinderLocalRequest *req = gbinder_client_new_request(client);
GBinderWriter writer;
gbinder_local_request_init_writer(req, &writer);
gbinder_writer_append_local_object(&writer, response_callback);
gbinder_writer_append_local_object(&writer, NULL);
gbinder_client_transact_sync_reply(client, HIDL_SERVICE_SET_RESPONSE_FUNCTIONS, req, &status);
gbinder_local_request_unref(req);
if (status < 0) {
fprintf(stderr, "Failed to call IRadio::setResponseFunctions");
return -1;
}
// Now, try to open the AID
uint8_t aid_hex[255];
euicc_hexutil_bin2hex(aid_hex, 255, aid, aid_len);
req = gbinder_client_new_request(client);
gbinder_local_request_init_writer(req, &writer);
gbinder_writer_append_int32(&writer, 1000);
gbinder_writer_append_hidl_string_copy(&writer, aid_hex);
gbinder_writer_append_int32(&writer, 0);
status = gbinder_client_transact_sync_oneway(client, HIDL_SERVICE_ICC_OPEN_LOGICAL_CHANNEL, req);
gbinder_local_request_unref(req);
if (status < 0) {
fprintf(stderr, "Failed to call IRadio::iccOpenLogicalChannel: %d\n", status);
return status;
}
g_main_loop_run(binder_loop);
if (lastRadioErr != 0) {
fprintf(stderr, "Failed to open APDU logical channel: %d\n", lastRadioErr);
return -lastRadioErr;
}
fprintf(stderr, "opened logical channel id: %d\n", lastIntResp);
return lastIntResp;
}
static int apdu_interface_connect(struct euicc_ctx *ctx)
{
return 0;
}
static void apdu_interface_disconnect(struct euicc_ctx *ctx)
{
cleanup();
}
static int apdu_interface_logic_channel_open(struct euicc_ctx *ctx, const uint8_t *aid, uint8_t aid_len)
{
// We only start to use gbinder connection here, because only now can we detect whether
// a given slot is a valid eSIM slot. This way we can automatically fall back in the case
// where a device has only one eSIM -- we don't want to force the user to choose in this case.
int res = try_open_slot(1, aid, aid_len);
if (res < 0)
res = try_open_slot(2, aid, aid_len);
if (res >= 0)
lastChannelId = res;
return res;
}
static void apdu_interface_logic_channel_close(struct euicc_ctx *ctx, uint8_t channel)
{
cleanup_channel(channel);
if (lastChannelId == channel)
lastChannelId = -1;
// Only do this cleanup here, because on exit these objects will be destroyed anyway
gbinder_client_unref(client);
gbinder_remote_object_unref(remote);
gbinder_servicemanager_unref(sm);
}
static int apdu_interface_transmit(struct euicc_ctx *ctx, uint8_t **rx, uint32_t *rx_len, const uint8_t *tx, uint32_t tx_len)
{
GBinderLocalRequest *req = gbinder_client_new_request(client);
GBinderWriter writer;
gbinder_local_request_init_writer(req, &writer);
gbinder_writer_append_int32(&writer, 1000);
uint8_t tx_hex[4096] = {0};
euicc_hexutil_bin2hex(tx_hex, 4096, &tx[5], tx_len - 5);
if (DEBUG)
fprintf(stderr, "APDU req: %s\n", tx_hex);
struct sim_apdu apdu = {
.sessionId = lastChannelId,
.cla = tx[0],
.instruction = tx[1],
.p1 = tx[2],
.p2 = tx[3],
.p3 = tx[4],
.data = {
.data = {
.str = (const char *) tx_hex
},
.len = strlen(tx_hex) + 1,
.owns_buffer = FALSE,
},
};
gbinder_writer_append_struct(&writer, &apdu, &sim_apdu_t, NULL);
int status = gbinder_client_transact_sync_oneway(client, HIDL_SERVICE_ICC_TRANSMIT_APDU_LOGICAL_CHANNEL, req);
gbinder_local_request_unref(req);
if (status < 0) {
fprintf(stderr, "Failed to call IRadio::iccTransmitApduLogicalChannel: %d\n", status);
return status;
}
g_main_loop_run(binder_loop);
if (lastRadioErr != 0) {
return -lastRadioErr;
}
if (DEBUG)
fprintf(stderr, "APDU resp: %d%d %d %s\n", lastIccIoResult.sw1, lastIccIoResult.sw2, lastIccIoResult.simResponse.len, lastIccIoResult.simResponse.data.str);
*rx_len = lastIccIoResult.simResponse.len / 2 + 2;
*rx = calloc(*rx_len, sizeof(uint8_t));
euicc_hexutil_hex2bin_r(*rx, *rx_len, lastIccIoResult.simResponse.data.str, lastIccIoResult.simResponse.len);
(*rx)[*rx_len - 2] = lastIccIoResult.sw1;
(*rx)[*rx_len - 1] = lastIccIoResult.sw2;
// see radio_response_transact -- this is our buffer.
free((void *) lastIccIoResult.simResponse.data.str);
return 0;
}
static int libapduinterface_init(struct euicc_apdu_interface *ifstruct)
{
ifstruct->connect = apdu_interface_connect;
ifstruct->disconnect = apdu_interface_disconnect;
ifstruct->logic_channel_open = apdu_interface_logic_channel_open;
ifstruct->logic_channel_close = apdu_interface_logic_channel_close;
ifstruct->transmit = apdu_interface_transmit;
// Install cleanup routine
atexit(cleanup);
signal(SIGINT, sighandler);
// The glib loop is detached from any client object, so create it here.
binder_loop = g_main_loop_new(NULL, FALSE);
return 0;
}
static int libapduinterface_main(int argc, char **argv)
{
return 0;
}
static void libapduinterface_fini(struct euicc_apdu_interface *ifstruct)
{
}
const struct euicc_driver driver_apdu_gbinder_hidl = {
.type = DRIVER_APDU,
.name = "gbinder_hidl",
.init = (int (*)(void *))libapduinterface_init,
.main = libapduinterface_main,
.fini = (void (*)(void *))libapduinterface_fini,
};

View file

@ -1,4 +0,0 @@
#pragma once
#include <driver.private.h>
extern const struct euicc_driver driver_apdu_gbinder_hidl;

View file

@ -1,367 +0,0 @@
// SPDX-License-Identifier: MIT
/*
* Copyright (c) 2024, Frans Klaver <frans.klaver@vislink.com>
*/
#include "mbim.h"
#include <libmbim-glib.h>
#include <stdio.h>
#include <euicc/interface.h>
#include <euicc/euicc.h>
#include "mbim_helpers.h"
struct mbim_data {
const char *device_path;
int last_channel_id;
gboolean use_proxy;
guint32 uim_slot;
GMainContext *context;
MbimDevice *device;
};
static gboolean is_sim_available(struct mbim_data *mbim_priv)
{
MbimMessage *request = mbim_message_subscriber_ready_status_query_new(NULL);
g_autoptr(MbimMessage) response = mbim_device_command_sync(
mbim_priv->device, mbim_priv->context, request, NULL
);
if (!response)
return FALSE;
MbimSubscriberReadyState ready_state;
if (!mbim_message_subscriber_ready_status_response_parse(
response, &ready_state, NULL, NULL, NULL, NULL, NULL, NULL
)) {
return FALSE;
}
switch (ready_state) {
case MBIM_SUBSCRIBER_READY_STATE_NO_ESIM_PROFILE:
case MBIM_SUBSCRIBER_READY_STATE_INITIALIZED:
return TRUE;
default:
return FALSE;
}
}
static int select_sim_slot(struct mbim_data *mbim_priv)
{
g_autoptr(GError) error = NULL;
MbimMessage *current_slot_request =
mbim_message_ms_basic_connect_extensions_device_slot_mappings_query_new(NULL);
g_autoptr(MbimMessage) current_slot_response = mbim_device_command_sync(
mbim_priv->device, mbim_priv->context, current_slot_request, &error
);
if (!current_slot_response) {
fprintf(stderr, "error: device didn't respond: %s\n", error->message);
return -1;
}
guint32 current_slot_count;
g_autoptr(MbimSlotArray) current_slots = NULL;
if (!mbim_message_ms_basic_connect_extensions_device_slot_mappings_response_parse(
current_slot_response, &current_slot_count, &current_slots, &error
)) {
fprintf(stderr, "error: sim select response could not be parsed: %s\n", error->message);
return -1;
}
if (current_slot_count && current_slots[0]->slot == mbim_priv->uim_slot) {
return 0;
}
g_autoptr(GPtrArray) new_slot_array = g_ptr_array_new_with_free_func(g_free);
MbimSlot *new_slot = g_new(MbimSlot, 1);
new_slot->slot = mbim_priv->uim_slot;
g_ptr_array_add(new_slot_array, new_slot);
MbimMessage *update_slot_request = mbim_message_ms_basic_connect_extensions_device_slot_mappings_set_new(
new_slot_array->len, (const MbimSlot **)new_slot_array->pdata, &error
);
if (!update_slot_request) {
fprintf(stderr, "error: unable to select sim slot: %s\n", error->message);
return -1;
}
g_autoptr(MbimMessage) update_slot_response = mbim_device_command_sync(
mbim_priv->device, mbim_priv->context, update_slot_request, &error
);
if (!update_slot_response) {
fprintf(stderr, "error: device didn't respond: %s\n", error->message);
return -1;
}
guint32 slot_count;
g_autoptr(MbimSlotArray) updated_slots = NULL;
if (!mbim_message_ms_basic_connect_extensions_device_slot_mappings_response_parse(
update_slot_response, &slot_count, &updated_slots, &error
)) {
fprintf(stderr, "error: sim select response could not be parsed: %s\n", error->message);
return -1;
}
int retries = 20;
while (retries--) {
if (is_sim_available(mbim_priv)) {
return 0;
}
}
fprintf(stderr, "sim did not become available\n");
return -1;
}
static int apdu_interface_connect(struct euicc_ctx *ctx)
{
struct mbim_data *mbim_priv = ctx->apdu.interface->userdata;
g_autoptr(GError) error = NULL;
GFile *file;
file = g_file_new_for_path(mbim_priv->device_path);
mbim_priv->context = g_main_context_new();
mbim_priv->device = mbim_device_new_from_path(file, mbim_priv->context, &error);
if (!mbim_priv->device) {
fprintf(stderr, "error: create mbim device from path failed: %s\n", error->message);
return -1;
}
MbimDeviceOpenFlags open_flags = MBIM_DEVICE_OPEN_FLAGS_NONE;
if (mbim_priv->use_proxy)
open_flags |= MBIM_DEVICE_OPEN_FLAGS_PROXY;
mbim_device_open_sync(mbim_priv->device, open_flags, mbim_priv->context, &error);
if (error) {
fprintf(stderr, "error: open mbim device failed: %s\n", error->message);
return -1;
}
return select_sim_slot(mbim_priv);
}
/*
* Allocate storage in rx and copy the contents of response_data there. Also
* tack the status at the end, as the MBIM protocol separates the status from
* the rest of the response.
*/
static int copy_data_with_status(
uint8_t **rx, uint32_t *rx_len,
const guint8 *response_data, guint32 response_size,
guint32 status)
{
*rx_len = response_size + 2;
*rx = malloc(*rx_len);
if (!*rx)
return -1;
memcpy(*rx, response_data, response_size);
(*rx)[*rx_len - 2] = status & 0xff;
(*rx)[*rx_len - 1] = (status >> 8) & 0xff;
return 0;
}
static int mbim_apdu_interface_transmit(
struct euicc_ctx *ctx,
uint8_t **rx, uint32_t *rx_len,
const uint8_t *tx, uint32_t tx_len)
{
struct mbim_data *mbim_priv = ctx->apdu.interface->userdata;
g_autoptr(GError) error = NULL;
MbimMessage *request = mbim_message_ms_uicc_low_level_access_apdu_set_new(
mbim_priv->last_channel_id,
MBIM_UICC_SECURE_MESSAGING_NONE,
MBIM_UICC_CLASS_BYTE_TYPE_INTER_INDUSTRY,
tx_len,
tx,
&error
);
if (!request) {
fprintf(stderr, "error: creating apdu message failed: %s\n", error->message);
return -1;
}
g_autoptr(MbimMessage) response = mbim_device_command_sync(
mbim_priv->device, mbim_priv->context, request, &error
);
if (!response) {
fprintf(stderr, "error: no apdu response received: %s\n", error->message);
return -1;
}
guint32 status = 0;
guint32 response_size = 0;
const guint8 *response_data = NULL;
if (!mbim_message_ms_uicc_low_level_access_apdu_response_parse(
response, &status, &response_size, &response_data, &error
)) {
fprintf(stderr, "error: unable to parse apdu response: %s\n", error->message);
return -1;
}
return copy_data_with_status(rx, rx_len, response_data, response_size, status);
}
static int mbim_apdu_interface_logic_channel_open(
struct euicc_ctx *ctx,
const uint8_t *aid,
uint8_t aid_len)
{
struct mbim_data *mbim_priv = ctx->apdu.interface->userdata;
g_autoptr(GError) error = NULL;
guint8 channel_id;
MbimMessage *request = mbim_message_ms_uicc_low_level_access_open_channel_set_new(
aid_len, aid, 0, 1, &error
);
if (!request) {
fprintf(stderr, "error: creating channel message failed: %s\n", error->message);
return -1;
}
g_autoptr(MbimMessage) response = mbim_device_command_sync(
mbim_priv->device, mbim_priv->context, request, &error
);
if (!response) {
fprintf(stderr, "error: no channel response received: %s\n", error->message);
return -1;
}
guint32 status = 0;
guint32 channel = -1;
guint32 response_size = 0;
const guint8 *response_data = NULL;
if (!mbim_message_ms_uicc_low_level_access_open_channel_response_parse(
response, &status, &channel, &response_size, &response_data, &error
)) {
fprintf(stderr, "error: unable to parse channel response: %s\n", error->message);
return -1;
}
mbim_priv->last_channel_id = channel;
return channel;
}
static void mbim_apdu_interface_logic_channel_close(struct euicc_ctx *ctx, uint8_t channel)
{
struct mbim_data *mbim_priv = ctx->apdu.interface->userdata;
g_autoptr(GError) error = NULL;
MbimMessage *request = mbim_message_ms_uicc_low_level_access_close_channel_set_new(
channel, 1, &error
);
if (!request) {
fprintf(stderr, "error: creating channel message failed: %s\n", error->message);
return;
}
g_autoptr(MbimMessage) response = mbim_device_command_sync(
mbim_priv->device, mbim_priv->context, request, &error
);
if (!response) {
fprintf(stderr, "error: no channel response received: %s\n", error->message);
return;
}
guint32 status = 0;
if (!mbim_message_ms_uicc_low_level_access_close_channel_response_parse(
response, &status, &error
)) {
fprintf(stderr, "error: unable to parse channel response: %s\n", error->message);
return;
}
if (channel == mbim_priv->last_channel_id)
mbim_priv->last_channel_id = -1;
}
static void mbim_apdu_interface_disconnect(struct euicc_ctx *ctx)
{
struct mbim_data *mbim_priv = ctx->apdu.interface->userdata;
g_autoptr(GError) error = NULL;
if (mbim_priv->last_channel_id > 0)
{
fprintf(stderr, "Cleaning up leaked APDU channel %d\n", mbim_priv->last_channel_id);
mbim_apdu_interface_logic_channel_close(NULL, mbim_priv->last_channel_id);
mbim_priv->last_channel_id = -1;
}
mbim_device_close_sync(mbim_priv->device, mbim_priv->context, &error);
g_main_context_unref(mbim_priv->context);
mbim_priv->context = NULL;
}
static int libapduinterface_init(struct euicc_apdu_interface *ifstruct)
{
struct mbim_data *mbim_priv;
guint32 uim_slot = 0;
/*
* We're using the same UIM_SLOT environment variable as the QMI backends.
* QMI uses 1-based indexing for the sim slots. MBIM uses 0-based indexing,
* so account for that.
*/
const char *env_uim_slot = getenv("UIM_SLOT");
if (env_uim_slot) {
uim_slot = atoi(env_uim_slot);
if (uim_slot == 0) {
fprintf(stderr, "error: Invalid UIM_SLOT: '%s'\n", env_uim_slot);
return -1;
}
uim_slot--;
}
mbim_priv = malloc(sizeof(struct mbim_data));
if (!mbim_priv) {
fprintf(stderr, "Failed allocating memory\n");
return -1;
}
mbim_priv->uim_slot = uim_slot;
const char *use_proxy = getenv("MBIM_USE_PROXY");
if (use_proxy && strcmp(use_proxy, "0") != 0) {
mbim_priv->use_proxy = TRUE;
}
if (!(mbim_priv->device_path = getenv("MBIM_DEVICE"))) {
mbim_priv->device_path = "/dev/cdc-wdm0";
}
memset(ifstruct, 0, sizeof(struct euicc_apdu_interface));
ifstruct->connect = apdu_interface_connect;
ifstruct->disconnect = mbim_apdu_interface_disconnect;
ifstruct->logic_channel_open = mbim_apdu_interface_logic_channel_open;
ifstruct->logic_channel_close = mbim_apdu_interface_logic_channel_close;
ifstruct->transmit = mbim_apdu_interface_transmit;
ifstruct->userdata = mbim_priv;
return 0;
}
static int libapduinterface_main(int argc, char **argv)
{
return 0;
}
static void libapduinterface_fini(struct euicc_apdu_interface *ifstruct)
{
g_free(ifstruct->userdata);
}
const struct euicc_driver driver_apdu_mbim = {
.type = DRIVER_APDU,
.name = "mbim",
.init = (int (*)(void *))libapduinterface_init,
.main = libapduinterface_main,
.fini = (void (*)(void *))libapduinterface_fini,
};

View file

@ -1,8 +0,0 @@
// SPDX-License-Identifier: MIT
/*
* Copyright (c) 2024, Frans Klaver <frans.klaver@vislink.com>
*/
#pragma once
#include <driver.private.h>
extern const struct euicc_driver driver_apdu_mbim;

View file

@ -1,111 +0,0 @@
// SPDX-License-Identifier: MIT
/*
Copyright (c) 2024, Frans Klaver <frans.klaver@vislink.com>
*/
#include "mbim_helpers.h"
#include <libmbim-glib.h>
static void
async_result_ready(GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
GAsyncResult **result_out = user_data;
g_assert(*result_out == NULL);
*result_out = g_object_ref(res);
}
MbimDevice *
mbim_device_new_from_path(GFile *file,
GMainContext *context,
GError **error)
{
g_autoptr(GMainContextPusher) pusher = NULL;
g_autoptr(GAsyncResult) result = NULL;
g_autofree gchar *id = NULL;
pusher = g_main_context_pusher_new(context);
id = g_file_get_path (file);
if (id)
mbim_device_new(file,
NULL,
async_result_ready,
&result);
while (!result)
g_main_context_iteration(context, TRUE);
return mbim_device_new_finish(result, error);
}
gboolean
mbim_device_open_sync(MbimDevice *device,
MbimDeviceOpenFlags open_flags,
GMainContext *context,
GError **error)
{
g_autoptr(GMainContextPusher) pusher = NULL;
g_autoptr(GAsyncResult) result = NULL;
pusher = g_main_context_pusher_new(context);
mbim_device_open_full(device,
open_flags,
15,
NULL,
async_result_ready,
&result);
while (!result)
g_main_context_iteration(context, TRUE);
return mbim_device_open_finish(device, result, error);
}
MbimMessage *
mbim_device_command_sync(MbimDevice *device, GMainContext *context, MbimMessage *request, GError **error)
{
g_autoptr(GMainContextPusher) pusher = NULL;
g_autoptr(GAsyncResult) result = NULL;
pusher = g_main_context_pusher_new(context);
mbim_device_command(device, request, 10, NULL, async_result_ready, &result);
mbim_message_unref(request);
while (result == NULL)
g_main_context_iteration(context, TRUE);
MbimMessage *response = mbim_device_command_finish(device, result, error);
if (!response) {
return NULL;
}
if (!mbim_message_response_get_result(response, MBIM_MESSAGE_TYPE_COMMAND_DONE, error)) {
return NULL;
}
return response;
}
gboolean
mbim_device_close_sync(
MbimDevice *device,
GMainContext *context,
GError **error)
{
g_autoptr(GMainContextPusher) pusher = NULL;
g_autoptr(GAsyncResult) result = NULL;
pusher = g_main_context_pusher_new(context);
mbim_device_close(device, 20, NULL, async_result_ready, &result);
while (result == NULL)
g_main_context_iteration(context, TRUE);
return mbim_device_close_finish(device, result, error);
}

View file

@ -1,32 +0,0 @@
// SPDX-License-Identifier: MIT
/*
* Copyright (c) 2024, Frans Klaver <frans.klaver@vislink.com>
*/
#pragma once
#include <libmbim-glib.h>
MbimDevice *
mbim_device_new_from_path(
GFile *file,
GMainContext *context,
GError **error);
gboolean
mbim_device_open_sync(
MbimDevice *device,
MbimDeviceOpenFlags open_flags,
GMainContext *context,
GError **error);
gboolean
mbim_device_close_sync(
MbimDevice *device,
GMainContext *context,
GError **error);
MbimMessage *
mbim_device_command_sync(
MbimDevice *device,
GMainContext *context,
MbimMessage *request,
GError **error);

View file

@ -1,4 +0,0 @@
#pragma once
#include <driver.private.h>
extern const struct euicc_driver driver_apdu_pcsc;

View file

@ -1,83 +0,0 @@
#ifdef _WIN32
#include "pcsc_win32.h"
#define PCSC_ERROR_CASE(NAME) case NAME: return #NAME
const char *pcsc_stringify_error(const LONG err) {
switch (err) {
PCSC_ERROR_CASE(SCARD_S_SUCCESS);
PCSC_ERROR_CASE(SCARD_F_INTERNAL_ERROR);
PCSC_ERROR_CASE(SCARD_E_CANCELLED);
PCSC_ERROR_CASE(SCARD_E_INVALID_HANDLE);
PCSC_ERROR_CASE(SCARD_E_INVALID_PARAMETER);
PCSC_ERROR_CASE(SCARD_E_INVALID_TARGET);
PCSC_ERROR_CASE(SCARD_E_NO_MEMORY);
PCSC_ERROR_CASE(SCARD_F_WAITED_TOO_LONG);
PCSC_ERROR_CASE(SCARD_E_INSUFFICIENT_BUFFER);
PCSC_ERROR_CASE(SCARD_E_UNKNOWN_READER);
PCSC_ERROR_CASE(SCARD_E_TIMEOUT);
PCSC_ERROR_CASE(SCARD_E_SHARING_VIOLATION);
PCSC_ERROR_CASE(SCARD_E_NO_SMARTCARD);
PCSC_ERROR_CASE(SCARD_E_UNKNOWN_CARD);
PCSC_ERROR_CASE(SCARD_E_CANT_DISPOSE);
PCSC_ERROR_CASE(SCARD_E_PROTO_MISMATCH);
PCSC_ERROR_CASE(SCARD_E_NOT_READY);
PCSC_ERROR_CASE(SCARD_E_INVALID_VALUE);
PCSC_ERROR_CASE(SCARD_E_SYSTEM_CANCELLED);
PCSC_ERROR_CASE(SCARD_F_COMM_ERROR);
PCSC_ERROR_CASE(SCARD_F_UNKNOWN_ERROR);
PCSC_ERROR_CASE(SCARD_E_INVALID_ATR);
PCSC_ERROR_CASE(SCARD_E_NOT_TRANSACTED);
PCSC_ERROR_CASE(SCARD_E_READER_UNAVAILABLE);
PCSC_ERROR_CASE(SCARD_P_SHUTDOWN);
PCSC_ERROR_CASE(SCARD_E_PCI_TOO_SMALL);
PCSC_ERROR_CASE(SCARD_E_READER_UNSUPPORTED);
PCSC_ERROR_CASE(SCARD_E_DUPLICATE_READER);
PCSC_ERROR_CASE(SCARD_E_CARD_UNSUPPORTED);
PCSC_ERROR_CASE(SCARD_E_NO_SERVICE);
PCSC_ERROR_CASE(SCARD_E_SERVICE_STOPPED);
PCSC_ERROR_CASE(SCARD_E_UNEXPECTED);
PCSC_ERROR_CASE(SCARD_E_ICC_INSTALLATION);
PCSC_ERROR_CASE(SCARD_E_ICC_CREATEORDER);
PCSC_ERROR_CASE(SCARD_E_UNSUPPORTED_FEATURE);
PCSC_ERROR_CASE(SCARD_E_DIR_NOT_FOUND);
PCSC_ERROR_CASE(SCARD_E_FILE_NOT_FOUND);
PCSC_ERROR_CASE(SCARD_E_NO_DIR);
PCSC_ERROR_CASE(SCARD_E_NO_FILE);
PCSC_ERROR_CASE(SCARD_E_NO_ACCESS);
PCSC_ERROR_CASE(SCARD_E_WRITE_TOO_MANY);
PCSC_ERROR_CASE(SCARD_E_BAD_SEEK);
PCSC_ERROR_CASE(SCARD_E_INVALID_CHV);
PCSC_ERROR_CASE(SCARD_E_UNKNOWN_RES_MNG);
PCSC_ERROR_CASE(SCARD_E_NO_SUCH_CERTIFICATE);
PCSC_ERROR_CASE(SCARD_E_CERTIFICATE_UNAVAILABLE);
PCSC_ERROR_CASE(SCARD_E_NO_READERS_AVAILABLE);
PCSC_ERROR_CASE(SCARD_E_COMM_DATA_LOST);
PCSC_ERROR_CASE(SCARD_E_NO_KEY_CONTAINER);
PCSC_ERROR_CASE(SCARD_E_SERVER_TOO_BUSY);
PCSC_ERROR_CASE(SCARD_E_PIN_CACHE_EXPIRED);
PCSC_ERROR_CASE(SCARD_E_NO_PIN_CACHE);
PCSC_ERROR_CASE(SCARD_E_READ_ONLY_CARD);
PCSC_ERROR_CASE(SCARD_W_UNSUPPORTED_CARD);
PCSC_ERROR_CASE(SCARD_W_UNRESPONSIVE_CARD);
PCSC_ERROR_CASE(SCARD_W_UNPOWERED_CARD);
PCSC_ERROR_CASE(SCARD_W_RESET_CARD);
PCSC_ERROR_CASE(SCARD_W_REMOVED_CARD);
PCSC_ERROR_CASE(SCARD_W_SECURITY_VIOLATION);
PCSC_ERROR_CASE(SCARD_W_WRONG_CHV);
PCSC_ERROR_CASE(SCARD_W_CHV_BLOCKED);
PCSC_ERROR_CASE(SCARD_W_EOF);
PCSC_ERROR_CASE(SCARD_W_CANCELLED_BY_USER);
PCSC_ERROR_CASE(SCARD_W_CARD_NOT_AUTHENTICATED);
PCSC_ERROR_CASE(SCARD_W_CACHE_ITEM_NOT_FOUND);
PCSC_ERROR_CASE(SCARD_W_CACHE_ITEM_STALE);
PCSC_ERROR_CASE(ERROR_IO_DEVICE);
PCSC_ERROR_CASE(ERROR_BROKEN_PIPE);
default:
return "Unknown error";
}
}
#undef PCSC_ERROR_CASE
#endif

View file

@ -1,6 +0,0 @@
#pragma once
#ifdef _WIN32
#include <winscard.h>
const char *pcsc_stringify_error(LONG);
#endif

View file

@ -1,101 +0,0 @@
// SPDX-License-Identifier: MIT
/*
* Copyright (c) 2024, Robert Marko <robert.marko@sartura.hr>
*/
#include "qmi.h"
#include <stdio.h>
#include "qmi_common.h"
static int apdu_interface_connect(struct euicc_ctx *ctx)
{
struct qmi_data *qmi_priv = ctx->apdu.interface->userdata;
g_autoptr(GError) error = NULL;
QmiDevice *device = NULL;
QmiClient *client = NULL;
const char *device_path;
GFile *file;
if (!(device_path = getenv("QMI_DEVICE"))) {
fprintf(stderr, "No QMI device path specified!\n");
return -1;
}
file = g_file_new_for_path(device_path);
qmi_priv->context = g_main_context_new();
device = qmi_device_new_from_path(file, qmi_priv->context, &error);
if (!device) {
fprintf(stderr, "error: create QMI device from path failed: %s\n", error->message);
return -1;
}
qmi_device_open_sync(device, QMI_DEVICE_OPEN_FLAGS_PROXY, qmi_priv->context, &error);
if (error) {
fprintf(stderr, "error: open QMI device failed: %s\n", error->message);
return -1;
}
client = qmi_device_allocate_client_sync(device, qmi_priv->context, &error);
if (!client) {
fprintf(stderr, "error: allocate QMI client failed: %s\n", error->message);
return -1;
}
qmi_priv->uimClient = QMI_CLIENT_UIM(client);
return 0;
}
static int libapduinterface_init(struct euicc_apdu_interface *ifstruct)
{
struct qmi_data *qmi_priv;
qmi_priv = calloc(1, sizeof(struct qmi_data));
if(!qmi_priv) {
fprintf(stderr, "Failed allocating memory\n");
return -1;
}
memset(ifstruct, 0, sizeof(struct euicc_apdu_interface));
ifstruct->connect = apdu_interface_connect;
ifstruct->disconnect = qmi_apdu_interface_disconnect;
ifstruct->logic_channel_open = qmi_apdu_interface_logic_channel_open;
ifstruct->logic_channel_close = qmi_apdu_interface_logic_channel_close;
ifstruct->transmit = qmi_apdu_interface_transmit;
/*
* Allow the user to select the SIM card slot via environment variable.
* Use the primary SIM slot if not set.
*/
if (getenv("UIM_SLOT"))
qmi_priv->uimSlot = atoi(getenv("UIM_SLOT"));
else
qmi_priv->uimSlot = 1;
ifstruct->userdata = qmi_priv;
return 0;
}
static int libapduinterface_main(int argc, char **argv)
{
return 0;
}
static void libapduinterface_fini(struct euicc_apdu_interface *ifstruct)
{
struct qmi_data *qmi_priv = ifstruct->userdata;
qmi_cleanup(qmi_priv);
free(qmi_priv);
}
const struct euicc_driver driver_apdu_qmi = {
.type = DRIVER_APDU,
.name = "qmi",
.init = (int (*)(void *))libapduinterface_init,
.main = libapduinterface_main,
.fini = (void (*)(void *))libapduinterface_fini,
};

View file

@ -1,8 +0,0 @@
// SPDX-License-Identifier: MIT
/*
* Copyright (c) 2024, Robert Marko <robert.marko@sartura.hr>
*/
#pragma once
#include <driver.private.h>
extern const struct euicc_driver driver_apdu_qmi;

View file

@ -1,163 +0,0 @@
// SPDX-License-Identifier: MIT
/*
* Copyright (c) 2024, Luca Weiss <luca.weiss@fairphone.com>
*/
#include <stdio.h>
#include "qmi_common.h"
int qmi_apdu_interface_transmit(struct euicc_ctx *ctx, uint8_t **rx, uint32_t *rx_len, const uint8_t *tx, uint32_t tx_len)
{
struct qmi_data *qmi_priv = ctx->apdu.interface->userdata;
g_autoptr(GError) error = NULL;
g_autoptr(GArray) apdu_data = NULL;
/* Convert tx into request GArray */
apdu_data = g_array_new(FALSE, FALSE, sizeof(guint8));
for (uint32_t i = 0; i < tx_len; i++)
g_array_append_val(apdu_data, tx[i]);
QmiMessageUimSendApduInput *input;
input = qmi_message_uim_send_apdu_input_new();
qmi_message_uim_send_apdu_input_set_slot(input, qmi_priv->uimSlot, NULL);
qmi_message_uim_send_apdu_input_set_channel_id(input, qmi_priv->lastChannelId, NULL);
qmi_message_uim_send_apdu_input_set_apdu(input, apdu_data, NULL);
QmiMessageUimSendApduOutput *output;
output = qmi_client_uim_send_apdu_sync(qmi_priv->uimClient, input, qmi_priv->context, &error);
qmi_message_uim_send_apdu_input_unref(input);
if (!qmi_message_uim_send_apdu_output_get_result(output, &error))
{
fprintf(stderr, "error: send apdu operation failed: %s\n", error->message);
return -1;
}
GArray *apdu_res = NULL;
if (!qmi_message_uim_send_apdu_output_get_apdu_response(output, &apdu_res, &error))
{
fprintf(stderr, "error: get apdu response operation failed: %s\n", error->message);
return -1;
}
/* Convert response GArray into rx */
*rx_len = apdu_res->len;
*rx = malloc(*rx_len);
if (!*rx)
return -1;
for (guint i = 0; i < apdu_res->len; i++)
(*rx)[i] = apdu_res->data[i];
qmi_message_uim_send_apdu_output_unref(output);
return 0;
}
int qmi_apdu_interface_logic_channel_open(struct euicc_ctx *ctx, const uint8_t *aid, uint8_t aid_len)
{
struct qmi_data *qmi_priv = ctx->apdu.interface->userdata;
g_autoptr(GError) error = NULL;
guint8 channel_id;
GArray *aid_data = g_array_new(FALSE, FALSE, sizeof(guint8));
for (int i = 0; i < aid_len; i++)
g_array_append_val(aid_data, aid[i]);
QmiMessageUimOpenLogicalChannelInput *input;
input = qmi_message_uim_open_logical_channel_input_new();
qmi_message_uim_open_logical_channel_input_set_slot(input, qmi_priv->uimSlot, NULL);
qmi_message_uim_open_logical_channel_input_set_aid(input, aid_data, NULL);
QmiMessageUimOpenLogicalChannelOutput *output;
output = qmi_client_uim_open_logical_channel_sync(qmi_priv->uimClient, input, qmi_priv->context, &error);
qmi_message_uim_open_logical_channel_input_unref(input);
g_array_unref(aid_data);
if (!output)
{
fprintf(stderr, "error: send Open Logical Channel command failed: %s\n", error->message);
return -1;
}
if (!qmi_message_uim_open_logical_channel_output_get_result(output, &error))
{
fprintf(stderr, "error: open logical channel operation failed: %s\n", error->message);
return -1;
}
if (!qmi_message_uim_open_logical_channel_output_get_channel_id(output, &channel_id, &error))
{
fprintf(stderr, "error: get channel id operation failed: %s\n", error->message);
return -1;
}
qmi_priv->lastChannelId = channel_id;
g_debug("Opened logical channel with id %d", channel_id);
qmi_message_uim_open_logical_channel_output_unref(output);
return channel_id;
}
void qmi_apdu_interface_logic_channel_close(struct euicc_ctx *ctx, uint8_t channel)
{
struct qmi_data *qmi_priv = ctx->apdu.interface->userdata;
g_autoptr(GError) error = NULL;
QmiMessageUimLogicalChannelInput *input;
input = qmi_message_uim_logical_channel_input_new();
qmi_message_uim_logical_channel_input_set_slot(input, qmi_priv->uimSlot, NULL);
qmi_message_uim_logical_channel_input_set_channel_id(input, channel, NULL);
QmiMessageUimLogicalChannelOutput *output;
output = qmi_client_uim_logical_channel_sync(qmi_priv->uimClient, input, qmi_priv->context, &error);
qmi_message_uim_logical_channel_input_unref(input);
if (error)
{
fprintf(stderr, "error: send Close Logical Channel command failed: %s\n", error->message);
return;
}
if (!qmi_message_uim_logical_channel_output_get_result(output, &error))
{
fprintf(stderr, "error: logical channel operation failed: %s\n", error->message);
return;
}
/* Mark channel as having been cleaned up */
if (channel == qmi_priv->lastChannelId)
qmi_priv->lastChannelId = -1;
g_debug("Closed logical channel with id %d", channel);
qmi_message_uim_logical_channel_output_unref(output);
}
void qmi_apdu_interface_disconnect(struct euicc_ctx *ctx)
{
struct qmi_data *qmi_priv = ctx->apdu.interface->userdata;
g_autoptr(GError) error = NULL;
QmiClient *client = QMI_CLIENT(qmi_priv->uimClient);
QmiDevice *device = QMI_DEVICE(qmi_client_get_device(client));
qmi_device_release_client_sync(device, client, qmi_priv->context, &error);
qmi_priv->uimClient = NULL;
g_main_context_unref(qmi_priv->context);
qmi_priv->context = NULL;
}
void qmi_cleanup(struct qmi_data *qmi_priv)
{
if (qmi_priv->lastChannelId > 0)
{
fprintf(stderr, "Cleaning up leaked APDU channel %d\n", qmi_priv->lastChannelId);
qmi_apdu_interface_logic_channel_close(NULL, qmi_priv->lastChannelId);
qmi_priv->lastChannelId = -1;
}
}

View file

@ -1,21 +0,0 @@
// SPDX-License-Identifier: MIT
/*
* Copyright (c) 2024, Luca Weiss <luca.weiss@fairphone.com>
*/
#pragma once
#include <euicc/interface.h>
#include <euicc/euicc.h>
#include "qmi_helpers.h"
struct qmi_data {
int lastChannelId;
int uimSlot;
GMainContext *context;
QmiClientUim *uimClient;
};
int qmi_apdu_interface_transmit(struct euicc_ctx *ctx, uint8_t **rx, uint32_t *rx_len, const uint8_t *tx, uint32_t tx_len);
int qmi_apdu_interface_logic_channel_open(struct euicc_ctx *ctx, const uint8_t *aid, uint8_t aid_len);
void qmi_apdu_interface_logic_channel_close(struct euicc_ctx *ctx, uint8_t channel);
void qmi_apdu_interface_disconnect(struct euicc_ctx *ctx);
void qmi_cleanup(struct qmi_data *qmi_priv);

View file

@ -1,234 +0,0 @@
// SPDX-License-Identifier: MIT
/*
* Copyright (c) 2024, Luca Weiss <luca.weiss@fairphone.com>
*/
#include "qmi_helpers.h"
static void
async_result_ready(GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
GAsyncResult **result_out = user_data;
g_assert(*result_out == NULL);
*result_out = g_object_ref(res);
}
#ifdef LPAC_WITH_APDU_QMI_QRTR
QrtrBus *
qrtr_bus_new_sync(GMainContext *context,
GError **error)
{
g_autoptr(GMainContextPusher) pusher = NULL;
g_autoptr(GAsyncResult) result = NULL;
pusher = g_main_context_pusher_new(context);
qrtr_bus_new(1000, /* ms */
NULL,
async_result_ready,
&result);
while (result == NULL)
g_main_context_iteration(context, TRUE);
return qrtr_bus_new_finish(result, error);
}
QmiDevice *
qmi_device_new_from_node_sync(QrtrNode *node,
GMainContext *context,
GError **error)
{
g_autoptr(GMainContextPusher) pusher = NULL;
g_autoptr(GAsyncResult) result = NULL;
pusher = g_main_context_pusher_new(context);
qmi_device_new_from_node(node,
NULL,
async_result_ready,
&result);
while (result == NULL)
g_main_context_iteration(context, TRUE);
return qmi_device_new_from_node_finish(result, error);
}
#endif
#ifdef LPAC_WITH_APDU_QMI
QmiDevice *
qmi_device_new_from_path(GFile *file,
GMainContext *context,
GError **error)
{
g_autoptr(GMainContextPusher) pusher = NULL;
g_autoptr(GAsyncResult) result = NULL;
g_autofree gchar *id = NULL;
pusher = g_main_context_pusher_new(context);
id = g_file_get_path (file);
if (id)
qmi_device_new(file,
NULL,
async_result_ready,
&result);
while (result == NULL)
g_main_context_iteration(context, TRUE);
return qmi_device_new_finish(result, error);
}
#endif
gboolean
qmi_device_open_sync(QmiDevice *device,
QmiDeviceOpenFlags flags,
GMainContext *context,
GError **error)
{
g_autoptr(GMainContextPusher) pusher = NULL;
g_autoptr(GAsyncResult) result = NULL;
pusher = g_main_context_pusher_new(context);
qmi_device_open(device,
flags,
15,
NULL,
async_result_ready,
&result);
while (result == NULL)
g_main_context_iteration(context, TRUE);
return qmi_device_open_finish(device, result, error);
}
QmiClient *
qmi_device_allocate_client_sync(QmiDevice *device,
GMainContext *context,
GError **error)
{
g_autoptr(GMainContextPusher) pusher = NULL;
g_autoptr(GAsyncResult) result = NULL;
pusher = g_main_context_pusher_new(context);
qmi_device_allocate_client(device,
QMI_SERVICE_UIM,
QMI_CID_NONE,
10,
NULL,
async_result_ready,
&result);
while (result == NULL)
g_main_context_iteration(context, TRUE);
return qmi_device_allocate_client_finish(device, result, error);
}
gboolean
qmi_device_release_client_sync(QmiDevice *device,
QmiClient *client,
GMainContext *context,
GError **error)
{
g_autoptr(GMainContextPusher) pusher = NULL;
g_autoptr(GAsyncResult) result = NULL;
pusher = g_main_context_pusher_new(context);
qmi_device_release_client(device,
client,
QMI_DEVICE_RELEASE_CLIENT_FLAGS_RELEASE_CID,
10,
NULL,
async_result_ready,
&result);
while (result == NULL)
g_main_context_iteration(context, TRUE);
return qmi_device_release_client_finish(device, result, error);
}
QmiMessageUimOpenLogicalChannelOutput *
qmi_client_uim_open_logical_channel_sync(
QmiClientUim *client,
QmiMessageUimOpenLogicalChannelInput *input,
GMainContext *context,
GError **error)
{
g_autoptr(GMainContextPusher) pusher = NULL;
g_autoptr(GAsyncResult) result = NULL;
pusher = g_main_context_pusher_new(context);
qmi_client_uim_open_logical_channel(client,
input,
10,
NULL,
async_result_ready,
&result);
while (result == NULL)
g_main_context_iteration(context, TRUE);
return qmi_client_uim_open_logical_channel_finish(client, result, error);
}
QmiMessageUimLogicalChannelOutput *
qmi_client_uim_logical_channel_sync(
QmiClientUim *client,
QmiMessageUimLogicalChannelInput *input,
GMainContext *context,
GError **error)
{
g_autoptr(GMainContextPusher) pusher = NULL;
g_autoptr(GAsyncResult) result = NULL;
pusher = g_main_context_pusher_new(context);
qmi_client_uim_logical_channel(client,
input,
10,
NULL,
async_result_ready,
&result);
while (result == NULL)
g_main_context_iteration(context, TRUE);
return qmi_client_uim_logical_channel_finish(client, result, error);
}
QmiMessageUimSendApduOutput *
qmi_client_uim_send_apdu_sync(
QmiClientUim *client,
QmiMessageUimSendApduInput *input,
GMainContext *context,
GError **error)
{
g_autoptr(GMainContextPusher) pusher = NULL;
g_autoptr(GAsyncResult) result = NULL;
pusher = g_main_context_pusher_new(context);
qmi_client_uim_send_apdu(client,
input,
10,
NULL,
async_result_ready,
&result);
while (result == NULL)
g_main_context_iteration(context, TRUE);
return qmi_client_uim_send_apdu_finish(client, result, error);
}

View file

@ -1,69 +0,0 @@
// SPDX-License-Identifier: MIT
/*
* Copyright (c) 2024, Luca Weiss <luca.weiss@fairphone.com>
*/
#pragma once
#include <libqmi-glib.h>
#ifdef LPAC_WITH_APDU_QMI_QRTR
#include <libqrtr-glib.h>
QrtrBus *qrtr_bus_new_sync(
GMainContext *context,
GError **error);
QmiDevice *
qmi_device_new_from_node_sync(
QrtrNode *node,
GMainContext *context,
GError **error);
#endif
#ifdef LPAC_WITH_APDU_QMI
QmiDevice *
qmi_device_new_from_path(
GFile *file,
GMainContext *context,
GError **error);
#endif
gboolean
qmi_device_open_sync(
QmiDevice *device,
QmiDeviceOpenFlags flags,
GMainContext *context,
GError **error);
QmiClient *
qmi_device_allocate_client_sync(
QmiDevice *device,
GMainContext *context,
GError **error);
gboolean
qmi_device_release_client_sync(
QmiDevice *device,
QmiClient *client,
GMainContext *context,
GError **error);
QmiMessageUimOpenLogicalChannelOutput *
qmi_client_uim_open_logical_channel_sync(
QmiClientUim *client,
QmiMessageUimOpenLogicalChannelInput *input,
GMainContext *context,
GError **error);
QmiMessageUimLogicalChannelOutput *
qmi_client_uim_logical_channel_sync(
QmiClientUim *client,
QmiMessageUimLogicalChannelInput *input,
GMainContext *context,
GError **error);
QmiMessageUimSendApduOutput *
qmi_client_uim_send_apdu_sync(
QmiClientUim *client,
QmiMessageUimSendApduInput *input,
GMainContext *context,
GError **error);

View file

@ -1,136 +0,0 @@
// SPDX-License-Identifier: MIT
/*
* Copyright (c) 2024, Luca Weiss <luca.weiss@fairphone.com>
*/
#include "qmi_qrtr.h"
#include <euicc/interface.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <libqrtr-glib.h>
#include "qmi_common.h"
static QrtrBus *bus = NULL;
static int apdu_interface_connect(struct euicc_ctx *ctx)
{
struct qmi_data *qmi_priv = ctx->apdu.interface->userdata;
g_autoptr(GError) error = NULL;
QrtrNode *node = NULL;
QmiDevice *device = NULL;
QmiClient *client = NULL;
bool found = false;
qmi_priv->context = g_main_context_new();
bus = qrtr_bus_new_sync(qmi_priv->context, &error);
if (bus == NULL)
{
fprintf(stderr, "error: connect to QRTR bus failed: %s\n", error->message);
return -1;
}
/* Find QRTR node for UIM service */
for (GList *l = qrtr_bus_peek_nodes(bus); l != NULL; l = l->next)
{
node = l->data;
if (node && qrtr_node_lookup_port(node, QMI_SERVICE_UIM) >= 0)
{
found = true;
break;
}
}
if (!found)
{
fprintf(stderr, "error: find QRTR node with UIM service failed\n");
return -1;
}
device = qmi_device_new_from_node_sync(node, qmi_priv->context, &error);
if (!device)
{
fprintf(stderr, "error: create QMI device from QRTR node failed: %s\n", error->message);
return -1;
}
qmi_device_open_sync(device, QMI_DEVICE_OPEN_FLAGS_NONE, qmi_priv->context, &error);
if (error)
{
fprintf(stderr, "error: open QMI device failed: %s\n", error->message);
return -1;
}
client = qmi_device_allocate_client_sync(device, qmi_priv->context, &error);
if (!client)
{
fprintf(stderr, "error: allocate QMI client failed: %s\n", error->message);
return -1;
}
qmi_priv->uimClient = QMI_CLIENT_UIM(client);
return 0;
}
static int libapduinterface_init(struct euicc_apdu_interface *ifstruct)
{
struct qmi_data *qmi_priv;
qmi_priv = malloc(sizeof(struct qmi_data));
if(!qmi_priv) {
fprintf(stderr, "Failed allocating memory\n");
return -1;
}
memset(ifstruct, 0, sizeof(struct euicc_apdu_interface));
ifstruct->connect = apdu_interface_connect;
ifstruct->disconnect = qmi_apdu_interface_disconnect;
ifstruct->logic_channel_open = qmi_apdu_interface_logic_channel_open;
ifstruct->logic_channel_close = qmi_apdu_interface_logic_channel_close;
ifstruct->transmit = qmi_apdu_interface_transmit;
/*
* Allow the user to select the SIM card slot via environment variable.
* Use the primary SIM slot if not set.
*/
if (getenv("UIM_SLOT"))
{
qmi_priv->uimSlot = atoi(getenv("UIM_SLOT"));
}
else
{
qmi_priv->uimSlot = 1;
}
ifstruct->userdata = qmi_priv;
return 0;
}
static int libapduinterface_main(int argc, char **argv)
{
return 0;
}
static void libapduinterface_fini(struct euicc_apdu_interface *ifstruct)
{
struct qmi_data *qmi_priv = ifstruct->userdata;
qmi_cleanup(qmi_priv);
free(qmi_priv);
}
const struct euicc_driver driver_apdu_qmi_qrtr = {
.type = DRIVER_APDU,
.name = "qmi_qrtr",
.init = (int (*)(void *))libapduinterface_init,
.main = libapduinterface_main,
.fini = (void (*)(void *))libapduinterface_fini,
};

View file

@ -1,8 +0,0 @@
// SPDX-License-Identifier: MIT
/*
* Copyright (c) 2024, Luca Weiss <luca.weiss@fairphone.com>
*/
#pragma once
#include <driver.private.h>
extern const struct euicc_driver driver_apdu_qmi_qrtr;

View file

@ -1,4 +0,0 @@
#pragma once
#include <driver.private.h>
extern const struct euicc_driver driver_apdu_stdio;

View file

@ -1,135 +0,0 @@
#include "driver.h"
#include "driver.private.h"
#include <stdio.h>
#include <string.h>
#ifdef LPAC_WITH_APDU_GBINDER
#include "driver/apdu/gbinder_hidl.h"
#endif
#ifdef LPAC_WITH_APDU_MBIM
#include "driver/apdu/mbim.h"
#endif
#ifdef LPAC_WITH_APDU_QMI
#include "driver/apdu/qmi.h"
#endif
#ifdef LPAC_WITH_APDU_QMI_QRTR
#include "driver/apdu/qmi_qrtr.h"
#endif
#ifdef LPAC_WITH_APDU_PCSC
#include "driver/apdu/pcsc.h"
#endif
#ifdef LPAC_WITH_APDU_AT
#include "driver/apdu/at.h"
#endif
#ifdef LPAC_WITH_HTTP_CURL
#include "driver/http/curl.h"
#endif
#include "driver/apdu/stdio.h"
#include "driver/http/stdio.h"
static const struct euicc_driver *drivers[] = {
#ifdef LPAC_WITH_APDU_GBINDER
&driver_apdu_gbinder_hidl,
#endif
#ifdef LPAC_WITH_APDU_MBIM
&driver_apdu_mbim,
#endif
#ifdef LPAC_WITH_APDU_QMI
&driver_apdu_qmi,
#endif
#ifdef LPAC_WITH_APDU_QMI_QRTR
&driver_apdu_qmi_qrtr,
#endif
#ifdef LPAC_WITH_APDU_PCSC
&driver_apdu_pcsc,
#endif
#ifdef LPAC_WITH_APDU_AT
&driver_apdu_at,
#endif
#ifdef LPAC_WITH_HTTP_CURL
&driver_http_curl,
#endif
&driver_apdu_stdio,
&driver_http_stdio,
NULL,
};
static const struct euicc_driver *_driver_apdu = NULL;
static const struct euicc_driver *_driver_http = NULL;
struct euicc_apdu_interface euicc_driver_interface_apdu;
struct euicc_http_interface euicc_driver_interface_http;
int (*euicc_driver_main_apdu)(int argc, char **argv) = NULL;
int (*euicc_driver_main_http)(int argc, char **argv) = NULL;
static const struct euicc_driver *_find_driver(enum euicc_driver_type type, const char *name)
{
for (int i = 0; drivers[i] != NULL; i++)
{
const struct euicc_driver *d = drivers[i];
if (d->type != type)
{
continue;
}
if (name == NULL)
{
return d;
}
if (strcmp(d->name, name) == 0)
{
return d;
}
}
return NULL;
}
int euicc_driver_init(const char *apdu_driver_name, const char *http_driver_name)
{
_driver_apdu = _find_driver(DRIVER_APDU, apdu_driver_name);
if (_driver_apdu == NULL)
{
fprintf(stderr, "No APDU driver found\n");
return -1;
}
_driver_http = _find_driver(DRIVER_HTTP, http_driver_name);
if (_driver_http == NULL)
{
fprintf(stderr, "No HTTP driver found\n");
return -1;
}
if (_driver_apdu->init(&euicc_driver_interface_apdu))
{
fprintf(stderr, "APDU driver init failed\n");
return -1;
}
if (_driver_http->init(&euicc_driver_interface_http))
{
fprintf(stderr, "HTTP driver init failed\n");
return -1;
}
euicc_driver_main_apdu = _driver_apdu->main;
euicc_driver_main_http = _driver_http->main;
return 0;
}
void euicc_driver_fini()
{
if (_driver_apdu != NULL)
{
_driver_apdu->fini(&euicc_driver_interface_apdu);
}
if (_driver_http != NULL)
{
_driver_http->fini(&euicc_driver_interface_http);
}
}

View file

@ -1,12 +0,0 @@
#pragma once
#include <stddef.h>
#include <inttypes.h>
#include <euicc/interface.h>
extern struct euicc_apdu_interface euicc_driver_interface_apdu;
extern struct euicc_http_interface euicc_driver_interface_http;
extern int (*euicc_driver_main_apdu)(int argc, char **argv);
extern int (*euicc_driver_main_http)(int argc, char **argv);
int euicc_driver_init(const char *apdu_driver_name, const char *http_driver_name);
void euicc_driver_fini(void);

View file

@ -1,16 +0,0 @@
#pragma once
enum euicc_driver_type
{
DRIVER_APDU,
DRIVER_HTTP,
};
struct euicc_driver
{
enum euicc_driver_type type;
const char *name;
int (*init)(void *interface);
int (*main)(int argc, char **argv);
void (*fini)(void *interface);
};

View file

@ -1,205 +0,0 @@
#include "curl.h"
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <euicc/interface.h>
#ifndef _WIN32
#include <curl/curl.h>
#else
#include <dlfcn-win32/dlfcn.h>
#define CURL_GLOBAL_DEFAULT ((1 << 0) | (1 << 1))
#define CURLE_OK 0
#define CURLOPT_URL 10002
#define CURLOPT_WRITEFUNCTION 20011
#define CURLOPT_WRITEDATA 10001
#define CURLOPT_SSL_VERIFYPEER 64
#define CURLOPT_SSL_VERIFYHOST 81
#define CURLOPT_HTTPHEADER 10023
#define CURLOPT_POSTFIELDS 10015
#define CURLOPT_POSTFIELDSIZE 60
#define CURLINFO_RESPONSE_CODE 2097154
typedef void CURL;
typedef int CURLcode;
typedef int CURLoption;
typedef int CURLINFO;
static void *libcurl_interface_dlhandle = NULL;
#endif
struct http_trans_response_data
{
uint8_t *data;
size_t size;
};
static struct libcurl_interface
{
CURLcode (*_curl_global_init)(long flags);
CURL *(*_curl_easy_init)(void);
CURLcode (*_curl_easy_setopt)(CURL *curl, CURLoption option, ...);
CURLcode (*_curl_easy_perform)(CURL *curl);
CURLcode (*_curl_easy_getinfo)(CURL *curl, CURLINFO info, ...);
const char *(*_curl_easy_strerror)(CURLcode);
void (*_curl_easy_cleanup)(CURL *curl);
struct curl_slist *(*_curl_slist_append)(struct curl_slist *list, const char *data);
void (*_curl_slist_free_all)(struct curl_slist *list);
} libcurl;
static size_t http_trans_write_callback(void *contents, size_t size, size_t nmemb, void *userp)
{
size_t realsize = size * nmemb;
struct http_trans_response_data *mem = (struct http_trans_response_data *)userp;
mem->data = realloc(mem->data, mem->size + realsize + 1);
if (mem->data == NULL)
{
/* out of memory! */
printf("not enough memory (realloc returned NULL)\n");
return 0;
}
memcpy(&(mem->data[mem->size]), contents, realsize);
mem->size += realsize;
mem->data[mem->size] = 0;
return realsize;
}
static int http_interface_transmit(struct euicc_ctx *ctx, const char *url, uint32_t *rcode, uint8_t **rx, uint32_t *rx_len, const uint8_t *tx, uint32_t tx_len, const char **h)
{
int fret = 0;
CURL *curl;
CURLcode res;
struct http_trans_response_data responseData = {0};
struct curl_slist *headers = NULL, *nheaders = NULL;
long response_code;
(*rx) = NULL;
(*rcode) = 0;
curl = libcurl._curl_easy_init();
if (!curl)
{
goto err;
}
libcurl._curl_easy_setopt(curl, CURLOPT_URL, url);
libcurl._curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, http_trans_write_callback);
libcurl._curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&responseData);
libcurl._curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
libcurl._curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
for (int i = 0; h[i] != NULL; i++)
{
nheaders = libcurl._curl_slist_append(headers, h[i]);
if (nheaders == NULL)
{
goto err;
}
headers = nheaders;
}
libcurl._curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
if (tx != NULL)
{
libcurl._curl_easy_setopt(curl, CURLOPT_POSTFIELDS, tx);
libcurl._curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, tx_len);
}
res = libcurl._curl_easy_perform(curl);
if (res != CURLE_OK)
{
fprintf(stderr, "curl_easy_perform() failed: %s\n", libcurl._curl_easy_strerror(res));
goto err;
}
libcurl._curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code);
*rcode = response_code;
*rx = responseData.data;
*rx_len = responseData.size;
fret = 0;
goto exit;
err:
fret = -1;
free(responseData.data);
exit:
libcurl._curl_easy_cleanup(curl);
libcurl._curl_slist_free_all(headers);
return fret;
}
static int _init_libcurl(void)
{
#ifdef _WIN32
if (!(libcurl_interface_dlhandle = dlopen("libcurl.dll", RTLD_LAZY)))
{
fprintf(stderr, "libcurl init err: %s\n", dlerror());
return -1;
}
libcurl._curl_global_init = dlsym(libcurl_interface_dlhandle, "curl_global_init");
libcurl._curl_easy_init = dlsym(libcurl_interface_dlhandle, "curl_easy_init");
libcurl._curl_easy_setopt = dlsym(libcurl_interface_dlhandle, "curl_easy_setopt");
libcurl._curl_easy_perform = dlsym(libcurl_interface_dlhandle, "curl_easy_perform");
libcurl._curl_easy_getinfo = dlsym(libcurl_interface_dlhandle, "curl_easy_getinfo");
libcurl._curl_easy_strerror = dlsym(libcurl_interface_dlhandle, "curl_easy_strerror");
libcurl._curl_easy_cleanup = dlsym(libcurl_interface_dlhandle, "curl_easy_cleanup");
libcurl._curl_slist_append = dlsym(libcurl_interface_dlhandle, "curl_slist_append");
libcurl._curl_slist_free_all = dlsym(libcurl_interface_dlhandle, "curl_slist_free_all");
#else
libcurl._curl_global_init = curl_global_init;
libcurl._curl_easy_init = curl_easy_init;
libcurl._curl_easy_setopt = curl_easy_setopt;
libcurl._curl_easy_perform = curl_easy_perform;
libcurl._curl_easy_getinfo = curl_easy_getinfo;
libcurl._curl_easy_strerror = curl_easy_strerror;
libcurl._curl_easy_cleanup = curl_easy_cleanup;
libcurl._curl_slist_append = curl_slist_append;
libcurl._curl_slist_free_all = curl_slist_free_all;
#endif
return 0;
}
static int libhttpinterface_init(struct euicc_http_interface *ifstruct)
{
memset(ifstruct, 0, sizeof(struct euicc_http_interface));
if (_init_libcurl() != 0)
{
return -1;
}
if (libcurl._curl_global_init(CURL_GLOBAL_DEFAULT) != CURLE_OK)
{
return -1;
}
ifstruct->transmit = http_interface_transmit;
return 0;
}
static int libhttpinterface_main(int argc, char **argv)
{
return 0;
}
static void libhttpinterface_fini(struct euicc_http_interface *ifstruct)
{
}
const struct euicc_driver driver_http_curl = {
.type = DRIVER_HTTP,
.name = "curl",
.init = (int (*)(void *))libhttpinterface_init,
.main = libhttpinterface_main,
.fini = (void (*)(void *))libhttpinterface_fini,
};

View file

@ -1,4 +0,0 @@
#pragma once
#include <driver.private.h>
extern const struct euicc_driver driver_http_curl;

View file

@ -1,4 +0,0 @@
#pragma once
#include <driver.private.h>
extern const struct euicc_driver driver_http_stdio;

View file

@ -1,11 +0,0 @@
prefix="@CMAKE_INSTALL_PREFIX@"
exec_prefix="${prefix}"
libdir="${prefix}/lib"
includedir="${prefix}/include"
Name: libeuicc-drivers
Description: An "official" collection of drivers (backends) and their loader for use with libeuicc
Version: @PROJECT_VERSION@
Requires: @LIBEUICC_DRIVERS_REQUIRES@
Cflags: -I${includedir} @LIBEUICC_DRIVERS_EXTRA_CFLAGS@
Libs: -L${libdir} -leuicc-drivers

View file

@ -1,30 +1,7 @@
option(LPAC_DYNAMIC_LIBEUICC "Build and install libeuicc as a dynamic library" OFF)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} LIB_EUICC_SRCS)
if(LPAC_DYNAMIC_LIBEUICC)
add_library(euicc SHARED ${LIB_EUICC_SRCS})
else()
add_subdirectory(asn1c)
include_directories(asn1c)
include_directories(asn1c/asn1)
aux_source_directory(. LIB_EUICC_SRCS)
add_library (euicc STATIC ${LIB_EUICC_SRCS})
endif()
target_link_libraries(euicc euiccasn1)
target_link_libraries(euicc cjson-static)
target_include_directories(euicc PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)
if(LPAC_DYNAMIC_LIBEUICC)
# Install headers
file(GLOB ALL_HEADERS "*.h")
foreach(header ${ALL_HEADERS})
if(${header} MATCHES "^.*\.private\.h$")
list(REMOVE_ITEM ALL_HEADERS ${header})
endif()
endforeach()
set_target_properties(euicc PROPERTIES PUBLIC_HEADER "${ALL_HEADERS}")
# Only useful on Windows, and will lead to invalid arguments on ld.gold.
if(WIN32)
set_target_properties(euicc PROPERTIES LINK_FLAGS "-Wl,--export-all-symbols")
endif()
# Install a pkg-config file
configure_file(libeuicc.pc.in libeuicc.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libeuicc.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
# Configure libeuicc.so installation
set_target_properties(euicc PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR})
install(TARGETS euicc LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/euicc)
endif()

View file

@ -0,0 +1,10 @@
include_directories(.)
aux_source_directory(asn1 LIB_EUICC_ASN1_SRCS)
add_library (euiccasn1 STATIC ${LIB_EUICC_ASN1_SRCS})
target_compile_definitions(euiccasn1 PRIVATE HAVE_CONFIG_H)
option(LINUX_MINGW32 "Build for windows on Linux" OFF)
if(LINUX_MINGW32)
add_subdirectory(mingw32)
target_link_libraries(euiccasn1 euiccasn1mingw32)
endif()

277
euicc/asn1c/asn1/ANY.c Normal file
View file

@ -0,0 +1,277 @@
/*
* Copyright (c) 2004-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
*/
#include "asn_internal.h"
#include "ANY.h"
#include <errno.h>
asn_OCTET_STRING_specifics_t asn_SPC_ANY_specs = {
sizeof(ANY_t),
offsetof(ANY_t, _asn_ctx),
ASN_OSUBV_ANY
};
asn_TYPE_operation_t asn_OP_ANY = {
OCTET_STRING_free,
OCTET_STRING_print,
OCTET_STRING_compare,
OCTET_STRING_decode_ber,
OCTET_STRING_encode_der,
OCTET_STRING_decode_xer_hex,
ANY_encode_xer,
#ifdef ASN_DISABLE_OER_SUPPORT
0,
0,
#else
0,
0,
#endif /* ASN_DISABLE_OER_SUPPORT */
#ifdef ASN_DISABLE_PER_SUPPORT
0, 0,
#else
ANY_decode_uper,
ANY_encode_uper,
#endif /* ASN_DISABLE_PER_SUPPORT */
0, /* Random fill is not defined for ANY type */
0 /* Use generic outmost tag fetcher */
};
asn_TYPE_descriptor_t asn_DEF_ANY = {
"ANY",
"ANY",
&asn_OP_ANY,
0, 0, 0, 0,
{ 0, 0, asn_generic_no_constraint }, /* No constraints */
0, 0, /* No members */
&asn_SPC_ANY_specs,
};
#undef RETURN
#define RETURN(_code) \
do { \
asn_dec_rval_t tmprval; \
tmprval.code = _code; \
tmprval.consumed = consumed_myself; \
return tmprval; \
} while(0)
asn_enc_rval_t
ANY_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb,
void *app_key) {
if(flags & XER_F_CANONICAL) {
/*
* Canonical XER-encoding of ANY type is not supported.
*/
ASN__ENCODE_FAILED;
}
/* Dump as binary */
return OCTET_STRING_encode_xer(td, sptr, ilevel, flags, cb, app_key);
}
struct _callback_arg {
uint8_t *buffer;
size_t offset;
size_t size;
};
static int ANY__consume_bytes(const void *buffer, size_t size, void *key);
int
ANY_fromType(ANY_t *st, asn_TYPE_descriptor_t *td, void *sptr) {
struct _callback_arg arg;
asn_enc_rval_t erval;
if(!st || !td) {
errno = EINVAL;
return -1;
}
if(!sptr) {
if(st->buf) FREEMEM(st->buf);
st->size = 0;
return 0;
}
arg.offset = arg.size = 0;
arg.buffer = 0;
erval = der_encode(td, sptr, ANY__consume_bytes, &arg);
if(erval.encoded == -1) {
if(arg.buffer) FREEMEM(arg.buffer);
return -1;
}
assert((size_t)erval.encoded == arg.offset);
if(st->buf) FREEMEM(st->buf);
st->buf = arg.buffer;
st->size = arg.offset;
return 0;
}
ANY_t *
ANY_new_fromType(asn_TYPE_descriptor_t *td, void *sptr) {
ANY_t tmp;
ANY_t *st;
if(!td || !sptr) {
errno = EINVAL;
return 0;
}
memset(&tmp, 0, sizeof(tmp));
if(ANY_fromType(&tmp, td, sptr)) return 0;
st = (ANY_t *)CALLOC(1, sizeof(ANY_t));
if(st) {
*st = tmp;
return st;
} else {
FREEMEM(tmp.buf);
return 0;
}
}
int
ANY_to_type(ANY_t *st, asn_TYPE_descriptor_t *td, void **struct_ptr) {
asn_dec_rval_t rval;
void *newst = 0;
if(!st || !td || !struct_ptr) {
errno = EINVAL;
return -1;
}
if(st->buf == 0) {
/* Nothing to convert, make it empty. */
*struct_ptr = (void *)0;
return 0;
}
rval = ber_decode(0, td, (void **)&newst, st->buf, st->size);
if(rval.code == RC_OK) {
*struct_ptr = newst;
return 0;
} else {
/* Remove possibly partially decoded data. */
ASN_STRUCT_FREE(*td, newst);
return -1;
}
}
static int ANY__consume_bytes(const void *buffer, size_t size, void *key) {
struct _callback_arg *arg = (struct _callback_arg *)key;
if((arg->offset + size) >= arg->size) {
size_t nsize = (arg->size ? arg->size << 2 : 16) + size;
void *p = REALLOC(arg->buffer, nsize);
if(!p) return -1;
arg->buffer = (uint8_t *)p;
arg->size = nsize;
}
memcpy(arg->buffer + arg->offset, buffer, size);
arg->offset += size;
assert(arg->offset < arg->size);
return 0;
}
#ifndef ASN_DISABLE_PER_SUPPORT
asn_dec_rval_t
ANY_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints, void **sptr,
asn_per_data_t *pd) {
const asn_OCTET_STRING_specifics_t *specs =
td->specifics ? (const asn_OCTET_STRING_specifics_t *)td->specifics
: &asn_SPC_ANY_specs;
size_t consumed_myself = 0;
int repeat;
ANY_t *st = (ANY_t *)*sptr;
(void)opt_codec_ctx;
(void)constraints;
/*
* Allocate the structure.
*/
if(!st) {
st = (ANY_t *)(*sptr = CALLOC(1, specs->struct_size));
if(!st) RETURN(RC_FAIL);
}
ASN_DEBUG("PER Decoding ANY type");
st->size = 0;
do {
ssize_t raw_len;
ssize_t len_bytes;
ssize_t len_bits;
void *p;
int ret;
/* Get the PER length */
raw_len = uper_get_length(pd, -1, 0, &repeat);
if(raw_len < 0) RETURN(RC_WMORE);
if(raw_len == 0 && st->buf) break;
ASN_DEBUG("Got PER length len %" ASN_PRI_SIZE ", %s (%s)", raw_len,
repeat ? "repeat" : "once", td->name);
len_bytes = raw_len;
len_bits = len_bytes * 8;
p = REALLOC(st->buf, st->size + len_bytes + 1);
if(!p) RETURN(RC_FAIL);
st->buf = (uint8_t *)p;
ret = per_get_many_bits(pd, &st->buf[st->size], 0, len_bits);
if(ret < 0) RETURN(RC_WMORE);
consumed_myself += len_bits;
st->size += len_bytes;
} while(repeat);
st->buf[st->size] = 0; /* nul-terminate */
RETURN(RC_OK);
}
asn_enc_rval_t
ANY_encode_uper(const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints, const void *sptr,
asn_per_outp_t *po) {
const ANY_t *st = (const ANY_t *)sptr;
asn_enc_rval_t er = {0, 0, 0};
const uint8_t *buf;
size_t size;
int ret;
(void)constraints;
if(!st || (!st->buf && st->size)) ASN__ENCODE_FAILED;
buf = st->buf;
size = st->size;
do {
int need_eom = 0;
ssize_t may_save = uper_put_length(po, size, &need_eom);
if(may_save < 0) ASN__ENCODE_FAILED;
ret = per_put_many_bits(po, buf, may_save * 8);
if(ret) ASN__ENCODE_FAILED;
buf += may_save;
size -= may_save;
assert(!(may_save & 0x07) || !size);
if(need_eom && uper_put_length(po, 0, 0))
ASN__ENCODE_FAILED; /* End of Message length */
} while(size);
ASN__ENCODED_OK(er);
}
#endif /* ASN_DISABLE_PER_SUPPORT */

60
euicc/asn1c/asn1/ANY.h Normal file
View file

@ -0,0 +1,60 @@
/*-
* Copyright (c) 2004-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
*/
#ifndef ASN_TYPE_ANY_H
#define ASN_TYPE_ANY_H
#include "OCTET_STRING.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct ANY {
uint8_t *buf; /* BER-encoded ANY contents */
int size; /* Size of the above buffer */
asn_struct_ctx_t _asn_ctx; /* Parsing across buffer boundaries */
} ANY_t;
extern asn_TYPE_descriptor_t asn_DEF_ANY;
extern asn_TYPE_operation_t asn_OP_ANY;
extern asn_OCTET_STRING_specifics_t asn_SPC_ANY_specs;
asn_struct_free_f ANY_free;
asn_struct_print_f ANY_print;
ber_type_decoder_f ANY_decode_ber;
der_type_encoder_f ANY_encode_der;
xer_type_encoder_f ANY_encode_xer;
per_type_decoder_f ANY_decode_uper;
per_type_encoder_f ANY_encode_uper;
#define ANY_free OCTET_STRING_free
#define ANY_print OCTET_STRING_print
#define ANY_compare OCTET_STRING_compare
#define ANY_constraint asn_generic_no_constraint
#define ANY_decode_ber OCTET_STRING_decode_ber
#define ANY_encode_der OCTET_STRING_encode_der
#define ANY_decode_xer OCTET_STRING_decode_xer_hex
/******************************
* Handy conversion routines. *
******************************/
/* Convert another ASN.1 type into the ANY. This implies DER encoding. */
int ANY_fromType(ANY_t *, asn_TYPE_descriptor_t *td, void *struct_ptr);
ANY_t *ANY_new_fromType(asn_TYPE_descriptor_t *td, void *struct_ptr);
/* Convert the contents of the ANY type into the specified type. */
int ANY_to_type(ANY_t *, asn_TYPE_descriptor_t *td, void **struct_ptr);
#define ANY_fromBuf(s, buf, size) OCTET_STRING_fromBuf((s), (buf), (size))
#define ANY_new_fromBuf(buf, size) OCTET_STRING_new_fromBuf( \
&asn_DEF_ANY, (buf), (size))
#ifdef __cplusplus
}
#endif
#endif /* ASN_TYPE_ANY_H */

View file

@ -0,0 +1,68 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "PKIX1Implicit88"
* found in "../../../asn1/PKIXImplicit88.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#include "AccessDescription.h"
asn_TYPE_member_t asn_MBR_AccessDescription_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct AccessDescription, accessMethod),
(ASN_TAG_CLASS_UNIVERSAL | (6 << 2)),
0,
&asn_DEF_OBJECT_IDENTIFIER,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"accessMethod"
},
{ ATF_NOFLAGS, 0, offsetof(struct AccessDescription, accessLocation),
-1 /* Ambiguous tag (CHOICE?) */,
0,
&asn_DEF_GeneralName,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"accessLocation"
},
};
static const ber_tlv_tag_t asn_DEF_AccessDescription_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_AccessDescription_tag2el_1[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* accessMethod */
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 1, 0, 0 }, /* otherName */
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* rfc822Name */
{ (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 1, 0, 0 }, /* dNSName */
{ (ASN_TAG_CLASS_CONTEXT | (3 << 2)), 1, 0, 0 }, /* x400Address */
{ (ASN_TAG_CLASS_CONTEXT | (4 << 2)), 1, 0, 0 }, /* directoryName */
{ (ASN_TAG_CLASS_CONTEXT | (5 << 2)), 1, 0, 0 }, /* ediPartyName */
{ (ASN_TAG_CLASS_CONTEXT | (6 << 2)), 1, 0, 0 }, /* uniformResourceIdentifier */
{ (ASN_TAG_CLASS_CONTEXT | (7 << 2)), 1, 0, 0 }, /* iPAddress */
{ (ASN_TAG_CLASS_CONTEXT | (8 << 2)), 1, 0, 0 } /* registeredID */
};
asn_SEQUENCE_specifics_t asn_SPC_AccessDescription_specs_1 = {
sizeof(struct AccessDescription),
offsetof(struct AccessDescription, _asn_ctx),
asn_MAP_AccessDescription_tag2el_1,
10, /* Count of tags in the map */
0, 0, 0, /* Optional elements (not needed) */
-1, /* First extension addition */
};
asn_TYPE_descriptor_t asn_DEF_AccessDescription = {
"AccessDescription",
"AccessDescription",
&asn_OP_SEQUENCE,
asn_DEF_AccessDescription_tags_1,
sizeof(asn_DEF_AccessDescription_tags_1)
/sizeof(asn_DEF_AccessDescription_tags_1[0]), /* 1 */
asn_DEF_AccessDescription_tags_1, /* Same as above */
sizeof(asn_DEF_AccessDescription_tags_1)
/sizeof(asn_DEF_AccessDescription_tags_1[0]), /* 1 */
{ 0, 0, SEQUENCE_constraint },
asn_MBR_AccessDescription_1,
2, /* Elements count */
&asn_SPC_AccessDescription_specs_1 /* Additional specs */
};

View file

@ -0,0 +1,42 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "PKIX1Implicit88"
* found in "../../../asn1/PKIXImplicit88.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#ifndef _AccessDescription_H_
#define _AccessDescription_H_
#include "asn_application.h"
/* Including external dependencies */
#include "OBJECT_IDENTIFIER.h"
#include "GeneralName.h"
#include "constr_SEQUENCE.h"
#ifdef __cplusplus
extern "C" {
#endif
/* AccessDescription */
typedef struct AccessDescription {
OBJECT_IDENTIFIER_t accessMethod;
GeneralName_t accessLocation;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} AccessDescription_t;
/* Implementation */
extern asn_TYPE_descriptor_t asn_DEF_AccessDescription;
extern asn_SEQUENCE_specifics_t asn_SPC_AccessDescription_specs_1;
extern asn_TYPE_member_t asn_MBR_AccessDescription_1[2];
#ifdef __cplusplus
}
#endif
#endif /* _AccessDescription_H_ */
#include "asn_internal.h"

View file

@ -0,0 +1,218 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "PKIX1Explicit88"
* found in "../../../asn1/PKIXExplicit88.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#include "AdministrationDomainName.h"
static const int permitted_alphabet_table_2[256] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* . */
2, 3, 4, 5, 6, 7, 8, 9,10,11, 0, 0, 0, 0, 0, 0, /* 0123456789 */
};
static const int permitted_alphabet_code2value_2[11] = {
32,48,49,50,51,52,53,54,55,56,57,};
static int check_permitted_alphabet_2(const void *sptr) {
const int *table = permitted_alphabet_table_2;
/* The underlying type is NumericString */
const NumericString_t *st = (const NumericString_t *)sptr;
const uint8_t *ch = st->buf;
const uint8_t *end = ch + st->size;
for(; ch < end; ch++) {
uint8_t cv = *ch;
if(!table[cv]) return -1;
}
return 0;
}
static const int permitted_alphabet_table_3[256] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
1, 0, 0, 0, 0, 0, 0, 2, 3, 4, 0, 5, 6, 7, 8, 9, /* . '() +,-./ */
10,11,12,13,14,15,16,17,18,19,20, 0, 0,21, 0,22, /* 0123456789: = ? */
0,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37, /* ABCDEFGHIJKLMNO */
38,39,40,41,42,43,44,45,46,47,48, 0, 0, 0, 0, 0, /* PQRSTUVWXYZ */
0,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63, /* abcdefghijklmno */
64,65,66,67,68,69,70,71,72,73,74, 0, 0, 0, 0, 0, /* pqrstuvwxyz */
};
static const int permitted_alphabet_code2value_3[74] = {
32,39,40,41,43,44,45,46,47,48,49,50,51,52,53,54,
55,56,57,58,61,63,65,66,67,68,69,70,71,72,73,74,
75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,
97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,
113,114,115,116,117,118,119,120,121,122,};
static int check_permitted_alphabet_3(const void *sptr) {
const int *table = permitted_alphabet_table_3;
/* The underlying type is PrintableString */
const PrintableString_t *st = (const PrintableString_t *)sptr;
const uint8_t *ch = st->buf;
const uint8_t *end = ch + st->size;
for(; ch < end; ch++) {
uint8_t cv = *ch;
if(!table[cv]) return -1;
}
return 0;
}
static int
memb_numeric_constraint_1(const asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
const NumericString_t *st = (const NumericString_t *)sptr;
size_t size;
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
"%s: value not given (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
size = st->size;
if((size <= 16)
&& !check_permitted_alphabet_2(st)) {
/* Constraint check succeeded */
return 0;
} else {
ASN__CTFAIL(app_key, td, sptr,
"%s: constraint failed (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
}
static int asn_PER_MAP_numeric_2_v2c(unsigned int value) {
if(value >= sizeof(permitted_alphabet_table_2)/sizeof(permitted_alphabet_table_2[0]))
return -1;
return permitted_alphabet_table_2[value] - 1;
}
static int asn_PER_MAP_numeric_2_c2v(unsigned int code) {
if(code >= sizeof(permitted_alphabet_code2value_2)/sizeof(permitted_alphabet_code2value_2[0]))
return -1;
return permitted_alphabet_code2value_2[code];
}
static int
memb_printable_constraint_1(const asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
const PrintableString_t *st = (const PrintableString_t *)sptr;
size_t size;
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
"%s: value not given (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
size = st->size;
if((size <= 16)
&& !check_permitted_alphabet_3(st)) {
/* Constraint check succeeded */
return 0;
} else {
ASN__CTFAIL(app_key, td, sptr,
"%s: constraint failed (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
}
static int asn_PER_MAP_printable_3_v2c(unsigned int value) {
if(value >= sizeof(permitted_alphabet_table_3)/sizeof(permitted_alphabet_table_3[0]))
return -1;
return permitted_alphabet_table_3[value] - 1;
}
static int asn_PER_MAP_printable_3_c2v(unsigned int code) {
if(code >= sizeof(permitted_alphabet_code2value_3)/sizeof(permitted_alphabet_code2value_3[0]))
return -1;
return permitted_alphabet_code2value_3[code];
}
static asn_oer_constraints_t asn_OER_memb_numeric_constr_2 CC_NOTUSED = {
{ 0, 0 },
-1 /* (SIZE(0..16)) */};
static asn_per_constraints_t asn_PER_memb_numeric_constr_2 CC_NOTUSED = {
{ APC_CONSTRAINED, 4, 4, 32, 57 } /* (32..57) */,
{ APC_CONSTRAINED, 5, 5, 0, 16 } /* (SIZE(0..16)) */,
asn_PER_MAP_numeric_2_v2c, /* Value to PER code map */
asn_PER_MAP_numeric_2_c2v /* PER code to value map */
};
static asn_oer_constraints_t asn_OER_memb_printable_constr_3 CC_NOTUSED = {
{ 0, 0 },
-1 /* (SIZE(0..16)) */};
static asn_per_constraints_t asn_PER_memb_printable_constr_3 CC_NOTUSED = {
{ APC_CONSTRAINED, 7, 7, 32, 122 } /* (32..122) */,
{ APC_CONSTRAINED, 5, 5, 0, 16 } /* (SIZE(0..16)) */,
asn_PER_MAP_printable_3_v2c, /* Value to PER code map */
asn_PER_MAP_printable_3_c2v /* PER code to value map */
};
static asn_oer_constraints_t asn_OER_type_AdministrationDomainName_constr_1 CC_NOTUSED = {
{ 0, 0 },
-1};
asn_per_constraints_t asn_PER_type_AdministrationDomainName_constr_1 CC_NOTUSED = {
{ APC_CONSTRAINED, 1, 1, 0, 1 } /* (0..1) */,
{ APC_UNCONSTRAINED, -1, -1, 0, 0 },
0, 0 /* No PER value map */
};
asn_TYPE_member_t asn_MBR_AdministrationDomainName_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct AdministrationDomainName, choice.numeric),
(ASN_TAG_CLASS_UNIVERSAL | (18 << 2)),
0,
&asn_DEF_NumericString,
0,
{ &asn_OER_memb_numeric_constr_2, &asn_PER_memb_numeric_constr_2, memb_numeric_constraint_1 },
0, 0, /* No default value */
"numeric"
},
{ ATF_NOFLAGS, 0, offsetof(struct AdministrationDomainName, choice.printable),
(ASN_TAG_CLASS_UNIVERSAL | (19 << 2)),
0,
&asn_DEF_PrintableString,
0,
{ &asn_OER_memb_printable_constr_3, &asn_PER_memb_printable_constr_3, memb_printable_constraint_1 },
0, 0, /* No default value */
"printable"
},
};
static const ber_tlv_tag_t asn_DEF_AdministrationDomainName_tags_1[] = {
(ASN_TAG_CLASS_APPLICATION | (2 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_AdministrationDomainName_tag2el_1[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (18 << 2)), 0, 0, 0 }, /* numeric */
{ (ASN_TAG_CLASS_UNIVERSAL | (19 << 2)), 1, 0, 0 } /* printable */
};
asn_CHOICE_specifics_t asn_SPC_AdministrationDomainName_specs_1 = {
sizeof(struct AdministrationDomainName),
offsetof(struct AdministrationDomainName, _asn_ctx),
offsetof(struct AdministrationDomainName, present),
sizeof(((struct AdministrationDomainName *)0)->present),
asn_MAP_AdministrationDomainName_tag2el_1,
2, /* Count of tags in the map */
0, 0,
-1 /* Extensions start */
};
asn_TYPE_descriptor_t asn_DEF_AdministrationDomainName = {
"AdministrationDomainName",
"AdministrationDomainName",
&asn_OP_CHOICE,
asn_DEF_AdministrationDomainName_tags_1,
sizeof(asn_DEF_AdministrationDomainName_tags_1)
/sizeof(asn_DEF_AdministrationDomainName_tags_1[0]), /* 1 */
asn_DEF_AdministrationDomainName_tags_1, /* Same as above */
sizeof(asn_DEF_AdministrationDomainName_tags_1)
/sizeof(asn_DEF_AdministrationDomainName_tags_1[0]), /* 1 */
{ &asn_OER_type_AdministrationDomainName_constr_1, &asn_PER_type_AdministrationDomainName_constr_1, CHOICE_constraint },
asn_MBR_AdministrationDomainName_1,
2, /* Elements count */
&asn_SPC_AdministrationDomainName_specs_1 /* Additional specs */
};

View file

@ -0,0 +1,53 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "PKIX1Explicit88"
* found in "../../../asn1/PKIXExplicit88.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#ifndef _AdministrationDomainName_H_
#define _AdministrationDomainName_H_
#include "asn_application.h"
/* Including external dependencies */
#include "NumericString.h"
#include "PrintableString.h"
#include "constr_CHOICE.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Dependencies */
typedef enum AdministrationDomainName_PR {
AdministrationDomainName_PR_NOTHING, /* No components present */
AdministrationDomainName_PR_numeric,
AdministrationDomainName_PR_printable
} AdministrationDomainName_PR;
/* AdministrationDomainName */
typedef struct AdministrationDomainName {
AdministrationDomainName_PR present;
union AdministrationDomainName_u {
NumericString_t numeric;
PrintableString_t printable;
} choice;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} AdministrationDomainName_t;
/* Implementation */
extern asn_TYPE_descriptor_t asn_DEF_AdministrationDomainName;
extern asn_CHOICE_specifics_t asn_SPC_AdministrationDomainName_specs_1;
extern asn_TYPE_member_t asn_MBR_AdministrationDomainName_1[2];
extern asn_per_constraints_t asn_PER_type_AdministrationDomainName_constr_1;
#ifdef __cplusplus
}
#endif
#endif /* _AdministrationDomainName_H_ */
#include "asn_internal.h"

View file

@ -0,0 +1,61 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "PKIX1Explicit88"
* found in "../../../asn1/PKIXExplicit88.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#include "AlgorithmIdentifier.h"
asn_TYPE_member_t asn_MBR_AlgorithmIdentifier_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct AlgorithmIdentifier, algorithm),
(ASN_TAG_CLASS_UNIVERSAL | (6 << 2)),
0,
&asn_DEF_OBJECT_IDENTIFIER,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"algorithm"
},
{ ATF_ANY_TYPE | ATF_POINTER, 1, offsetof(struct AlgorithmIdentifier, parameters),
-1 /* Ambiguous tag (ANY?) */,
0,
&asn_DEF_ANY,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"parameters"
},
};
static const int asn_MAP_AlgorithmIdentifier_oms_1[] = { 1 };
static const ber_tlv_tag_t asn_DEF_AlgorithmIdentifier_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_AlgorithmIdentifier_tag2el_1[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 } /* algorithm */
};
asn_SEQUENCE_specifics_t asn_SPC_AlgorithmIdentifier_specs_1 = {
sizeof(struct AlgorithmIdentifier),
offsetof(struct AlgorithmIdentifier, _asn_ctx),
asn_MAP_AlgorithmIdentifier_tag2el_1,
1, /* Count of tags in the map */
asn_MAP_AlgorithmIdentifier_oms_1, /* Optional members */
1, 0, /* Root/Additions */
-1, /* First extension addition */
};
asn_TYPE_descriptor_t asn_DEF_AlgorithmIdentifier = {
"AlgorithmIdentifier",
"AlgorithmIdentifier",
&asn_OP_SEQUENCE,
asn_DEF_AlgorithmIdentifier_tags_1,
sizeof(asn_DEF_AlgorithmIdentifier_tags_1)
/sizeof(asn_DEF_AlgorithmIdentifier_tags_1[0]), /* 1 */
asn_DEF_AlgorithmIdentifier_tags_1, /* Same as above */
sizeof(asn_DEF_AlgorithmIdentifier_tags_1)
/sizeof(asn_DEF_AlgorithmIdentifier_tags_1[0]), /* 1 */
{ 0, 0, SEQUENCE_constraint },
asn_MBR_AlgorithmIdentifier_1,
2, /* Elements count */
&asn_SPC_AlgorithmIdentifier_specs_1 /* Additional specs */
};

View file

@ -0,0 +1,42 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "PKIX1Explicit88"
* found in "../../../asn1/PKIXExplicit88.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#ifndef _AlgorithmIdentifier_H_
#define _AlgorithmIdentifier_H_
#include "asn_application.h"
/* Including external dependencies */
#include "OBJECT_IDENTIFIER.h"
#include "ANY.h"
#include "constr_SEQUENCE.h"
#ifdef __cplusplus
extern "C" {
#endif
/* AlgorithmIdentifier */
typedef struct AlgorithmIdentifier {
OBJECT_IDENTIFIER_t algorithm;
ANY_t *parameters /* OPTIONAL */;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} AlgorithmIdentifier_t;
/* Implementation */
extern asn_TYPE_descriptor_t asn_DEF_AlgorithmIdentifier;
extern asn_SEQUENCE_specifics_t asn_SPC_AlgorithmIdentifier_specs_1;
extern asn_TYPE_member_t asn_MBR_AlgorithmIdentifier_1[2];
#ifdef __cplusplus
}
#endif
#endif /* _AlgorithmIdentifier_H_ */
#include "asn_internal.h"

View file

@ -0,0 +1,60 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "PKIX1Implicit88"
* found in "../../../asn1/PKIXImplicit88.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#include "AnotherName.h"
asn_TYPE_member_t asn_MBR_AnotherName_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct AnotherName, type_id),
(ASN_TAG_CLASS_UNIVERSAL | (6 << 2)),
0,
&asn_DEF_OBJECT_IDENTIFIER,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"type-id"
},
{ ATF_NOFLAGS, 0, offsetof(struct AnotherName, value),
(ASN_TAG_CLASS_CONTEXT | (0 << 2)),
+1, /* EXPLICIT tag at current level */
&asn_DEF_ANY,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"value"
},
};
static const ber_tlv_tag_t asn_DEF_AnotherName_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_AnotherName_tag2el_1[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* type-id */
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 1, 0, 0 } /* value */
};
asn_SEQUENCE_specifics_t asn_SPC_AnotherName_specs_1 = {
sizeof(struct AnotherName),
offsetof(struct AnotherName, _asn_ctx),
asn_MAP_AnotherName_tag2el_1,
2, /* Count of tags in the map */
0, 0, 0, /* Optional elements (not needed) */
-1, /* First extension addition */
};
asn_TYPE_descriptor_t asn_DEF_AnotherName = {
"AnotherName",
"AnotherName",
&asn_OP_SEQUENCE,
asn_DEF_AnotherName_tags_1,
sizeof(asn_DEF_AnotherName_tags_1)
/sizeof(asn_DEF_AnotherName_tags_1[0]), /* 1 */
asn_DEF_AnotherName_tags_1, /* Same as above */
sizeof(asn_DEF_AnotherName_tags_1)
/sizeof(asn_DEF_AnotherName_tags_1[0]), /* 1 */
{ 0, 0, SEQUENCE_constraint },
asn_MBR_AnotherName_1,
2, /* Elements count */
&asn_SPC_AnotherName_specs_1 /* Additional specs */
};

View file

@ -0,0 +1,42 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "PKIX1Implicit88"
* found in "../../../asn1/PKIXImplicit88.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#ifndef _AnotherName_H_
#define _AnotherName_H_
#include "asn_application.h"
/* Including external dependencies */
#include "OBJECT_IDENTIFIER.h"
#include "ANY.h"
#include "constr_SEQUENCE.h"
#ifdef __cplusplus
extern "C" {
#endif
/* AnotherName */
typedef struct AnotherName {
OBJECT_IDENTIFIER_t type_id;
ANY_t value;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} AnotherName_t;
/* Implementation */
extern asn_TYPE_descriptor_t asn_DEF_AnotherName;
extern asn_SEQUENCE_specifics_t asn_SPC_AnotherName_specs_1;
extern asn_TYPE_member_t asn_MBR_AnotherName_1[2];
#ifdef __cplusplus
}
#endif
#endif /* _AnotherName_H_ */
#include "asn_internal.h"

View file

@ -0,0 +1,96 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "PKIX1Explicit88"
* found in "../../../asn1/PKIXExplicit88.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#include "Attribute.h"
static asn_TYPE_member_t asn_MBR_values_3[] = {
{ ATF_ANY_TYPE | ATF_POINTER, 0, 0,
-1 /* Ambiguous tag (ANY?) */,
0,
&asn_DEF_AttributeValue,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
""
},
};
static const ber_tlv_tag_t asn_DEF_values_tags_3[] = {
(ASN_TAG_CLASS_UNIVERSAL | (17 << 2))
};
static asn_SET_OF_specifics_t asn_SPC_values_specs_3 = {
sizeof(struct Attribute__values),
offsetof(struct Attribute__values, _asn_ctx),
0, /* XER encoding is XMLDelimitedItemList */
};
static /* Use -fall-defs-global to expose */
asn_TYPE_descriptor_t asn_DEF_values_3 = {
"values",
"values",
&asn_OP_SET_OF,
asn_DEF_values_tags_3,
sizeof(asn_DEF_values_tags_3)
/sizeof(asn_DEF_values_tags_3[0]), /* 1 */
asn_DEF_values_tags_3, /* Same as above */
sizeof(asn_DEF_values_tags_3)
/sizeof(asn_DEF_values_tags_3[0]), /* 1 */
{ 0, 0, SET_OF_constraint },
asn_MBR_values_3,
1, /* Single element */
&asn_SPC_values_specs_3 /* Additional specs */
};
asn_TYPE_member_t asn_MBR_Attribute_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct Attribute, type),
(ASN_TAG_CLASS_UNIVERSAL | (6 << 2)),
0,
&asn_DEF_AttributeType,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"type"
},
{ ATF_NOFLAGS, 0, offsetof(struct Attribute, values),
(ASN_TAG_CLASS_UNIVERSAL | (17 << 2)),
0,
&asn_DEF_values_3,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"values"
},
};
static const ber_tlv_tag_t asn_DEF_Attribute_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_Attribute_tag2el_1[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* type */
{ (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)), 1, 0, 0 } /* values */
};
asn_SEQUENCE_specifics_t asn_SPC_Attribute_specs_1 = {
sizeof(struct Attribute),
offsetof(struct Attribute, _asn_ctx),
asn_MAP_Attribute_tag2el_1,
2, /* Count of tags in the map */
0, 0, 0, /* Optional elements (not needed) */
-1, /* First extension addition */
};
asn_TYPE_descriptor_t asn_DEF_Attribute = {
"Attribute",
"Attribute",
&asn_OP_SEQUENCE,
asn_DEF_Attribute_tags_1,
sizeof(asn_DEF_Attribute_tags_1)
/sizeof(asn_DEF_Attribute_tags_1[0]), /* 1 */
asn_DEF_Attribute_tags_1, /* Same as above */
sizeof(asn_DEF_Attribute_tags_1)
/sizeof(asn_DEF_Attribute_tags_1[0]), /* 1 */
{ 0, 0, SEQUENCE_constraint },
asn_MBR_Attribute_1,
2, /* Elements count */
&asn_SPC_Attribute_specs_1 /* Additional specs */
};

View file

@ -0,0 +1,49 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "PKIX1Explicit88"
* found in "../../../asn1/PKIXExplicit88.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#ifndef _Attribute_H_
#define _Attribute_H_
#include "asn_application.h"
/* Including external dependencies */
#include "AttributeType.h"
#include "AttributeValue.h"
#include "asn_SET_OF.h"
#include "constr_SET_OF.h"
#include "constr_SEQUENCE.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Attribute */
typedef struct Attribute {
AttributeType_t type;
struct Attribute__values {
A_SET_OF(AttributeValue_t) list;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} values;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} Attribute_t;
/* Implementation */
extern asn_TYPE_descriptor_t asn_DEF_Attribute;
extern asn_SEQUENCE_specifics_t asn_SPC_Attribute_specs_1;
extern asn_TYPE_member_t asn_MBR_Attribute_1[2];
#ifdef __cplusplus
}
#endif
#endif /* _Attribute_H_ */
#include "asn_internal.h"

View file

@ -0,0 +1,31 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "PKIX1Explicit88"
* found in "../../../asn1/PKIXExplicit88.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#include "AttributeType.h"
/*
* This type is implemented using OBJECT_IDENTIFIER,
* so here we adjust the DEF accordingly.
*/
static const ber_tlv_tag_t asn_DEF_AttributeType_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (6 << 2))
};
asn_TYPE_descriptor_t asn_DEF_AttributeType = {
"AttributeType",
"AttributeType",
&asn_OP_OBJECT_IDENTIFIER,
asn_DEF_AttributeType_tags_1,
sizeof(asn_DEF_AttributeType_tags_1)
/sizeof(asn_DEF_AttributeType_tags_1[0]), /* 1 */
asn_DEF_AttributeType_tags_1, /* Same as above */
sizeof(asn_DEF_AttributeType_tags_1)
/sizeof(asn_DEF_AttributeType_tags_1[0]), /* 1 */
{ 0, 0, OBJECT_IDENTIFIER_constraint },
0, 0, /* No members */
0 /* No specifics */
};

View file

@ -0,0 +1,43 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "PKIX1Explicit88"
* found in "../../../asn1/PKIXExplicit88.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#ifndef _AttributeType_H_
#define _AttributeType_H_
#include "asn_application.h"
/* Including external dependencies */
#include "OBJECT_IDENTIFIER.h"
#ifdef __cplusplus
extern "C" {
#endif
/* AttributeType */
typedef OBJECT_IDENTIFIER_t AttributeType_t;
/* Implementation */
extern asn_TYPE_descriptor_t asn_DEF_AttributeType;
asn_struct_free_f AttributeType_free;
asn_struct_print_f AttributeType_print;
asn_constr_check_f AttributeType_constraint;
ber_type_decoder_f AttributeType_decode_ber;
der_type_encoder_f AttributeType_encode_der;
xer_type_decoder_f AttributeType_decode_xer;
xer_type_encoder_f AttributeType_encode_xer;
oer_type_decoder_f AttributeType_decode_oer;
oer_type_encoder_f AttributeType_encode_oer;
per_type_decoder_f AttributeType_decode_uper;
per_type_encoder_f AttributeType_encode_uper;
#ifdef __cplusplus
}
#endif
#endif /* _AttributeType_H_ */
#include "asn_internal.h"

View file

@ -0,0 +1,59 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "PKIX1Explicit88"
* found in "../../../asn1/PKIXExplicit88.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#include "AttributeTypeAndValue.h"
asn_TYPE_member_t asn_MBR_AttributeTypeAndValue_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct AttributeTypeAndValue, type),
(ASN_TAG_CLASS_UNIVERSAL | (6 << 2)),
0,
&asn_DEF_AttributeType,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"type"
},
{ ATF_ANY_TYPE | ATF_NOFLAGS, 0, offsetof(struct AttributeTypeAndValue, value),
-1 /* Ambiguous tag (ANY?) */,
0,
&asn_DEF_AttributeValue,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"value"
},
};
static const ber_tlv_tag_t asn_DEF_AttributeTypeAndValue_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_AttributeTypeAndValue_tag2el_1[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 } /* type */
};
asn_SEQUENCE_specifics_t asn_SPC_AttributeTypeAndValue_specs_1 = {
sizeof(struct AttributeTypeAndValue),
offsetof(struct AttributeTypeAndValue, _asn_ctx),
asn_MAP_AttributeTypeAndValue_tag2el_1,
1, /* Count of tags in the map */
0, 0, 0, /* Optional elements (not needed) */
-1, /* First extension addition */
};
asn_TYPE_descriptor_t asn_DEF_AttributeTypeAndValue = {
"AttributeTypeAndValue",
"AttributeTypeAndValue",
&asn_OP_SEQUENCE,
asn_DEF_AttributeTypeAndValue_tags_1,
sizeof(asn_DEF_AttributeTypeAndValue_tags_1)
/sizeof(asn_DEF_AttributeTypeAndValue_tags_1[0]), /* 1 */
asn_DEF_AttributeTypeAndValue_tags_1, /* Same as above */
sizeof(asn_DEF_AttributeTypeAndValue_tags_1)
/sizeof(asn_DEF_AttributeTypeAndValue_tags_1[0]), /* 1 */
{ 0, 0, SEQUENCE_constraint },
asn_MBR_AttributeTypeAndValue_1,
2, /* Elements count */
&asn_SPC_AttributeTypeAndValue_specs_1 /* Additional specs */
};

View file

@ -0,0 +1,42 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "PKIX1Explicit88"
* found in "../../../asn1/PKIXExplicit88.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#ifndef _AttributeTypeAndValue_H_
#define _AttributeTypeAndValue_H_
#include "asn_application.h"
/* Including external dependencies */
#include "AttributeType.h"
#include "AttributeValue.h"
#include "constr_SEQUENCE.h"
#ifdef __cplusplus
extern "C" {
#endif
/* AttributeTypeAndValue */
typedef struct AttributeTypeAndValue {
AttributeType_t type;
AttributeValue_t value;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} AttributeTypeAndValue_t;
/* Implementation */
extern asn_TYPE_descriptor_t asn_DEF_AttributeTypeAndValue;
extern asn_SEQUENCE_specifics_t asn_SPC_AttributeTypeAndValue_specs_1;
extern asn_TYPE_member_t asn_MBR_AttributeTypeAndValue_1[2];
#ifdef __cplusplus
}
#endif
#endif /* _AttributeTypeAndValue_H_ */
#include "asn_internal.h"

View file

@ -0,0 +1,26 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "PKIX1Explicit88"
* found in "../../../asn1/PKIXExplicit88.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#include "AttributeValue.h"
/*
* This type is implemented using ANY,
* so here we adjust the DEF accordingly.
*/
asn_TYPE_descriptor_t asn_DEF_AttributeValue = {
"AttributeValue",
"AttributeValue",
&asn_OP_ANY,
0, /* No effective tags (pointer) */
0, /* No effective tags (count) */
0, /* No tags (pointer) */
0, /* No tags (count) */
{ 0, 0, ANY_constraint },
0, 0, /* No members */
&asn_SPC_ANY_specs /* Additional specs */
};

View file

@ -0,0 +1,43 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "PKIX1Explicit88"
* found in "../../../asn1/PKIXExplicit88.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#ifndef _AttributeValue_H_
#define _AttributeValue_H_
#include "asn_application.h"
/* Including external dependencies */
#include "ANY.h"
#ifdef __cplusplus
extern "C" {
#endif
/* AttributeValue */
typedef ANY_t AttributeValue_t;
/* Implementation */
extern asn_TYPE_descriptor_t asn_DEF_AttributeValue;
asn_struct_free_f AttributeValue_free;
asn_struct_print_f AttributeValue_print;
asn_constr_check_f AttributeValue_constraint;
ber_type_decoder_f AttributeValue_decode_ber;
der_type_encoder_f AttributeValue_encode_der;
xer_type_decoder_f AttributeValue_decode_xer;
xer_type_encoder_f AttributeValue_encode_xer;
oer_type_decoder_f AttributeValue_decode_oer;
oer_type_encoder_f AttributeValue_encode_oer;
per_type_decoder_f AttributeValue_decode_uper;
per_type_encoder_f AttributeValue_encode_uper;
#ifdef __cplusplus
}
#endif
#endif /* _AttributeValue_H_ */
#include "asn_internal.h"

View file

@ -0,0 +1,70 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "RSPDefinitions"
* found in "../../../asn1/rsp.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#include "AuthenticateClientOk.h"
asn_TYPE_member_t asn_MBR_AuthenticateClientOk_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct AuthenticateClientOk, transactionId),
(ASN_TAG_CLASS_CONTEXT | (0 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_TransactionId,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"transactionId"
},
{ ATF_NOFLAGS, 0, offsetof(struct AuthenticateClientOk, profileMetaData),
(ASN_TAG_CLASS_CONTEXT | (37 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_StoreMetadataRequest,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"profileMetaData"
},
{ ATF_NOFLAGS, 0, offsetof(struct AuthenticateClientOk, prepareDownloadRequest),
(ASN_TAG_CLASS_CONTEXT | (33 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_PrepareDownloadRequest,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"prepareDownloadRequest"
},
};
static const ber_tlv_tag_t asn_DEF_AuthenticateClientOk_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_AuthenticateClientOk_tag2el_1[] = {
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* transactionId */
{ (ASN_TAG_CLASS_CONTEXT | (33 << 2)), 2, 0, 0 }, /* prepareDownloadRequest */
{ (ASN_TAG_CLASS_CONTEXT | (37 << 2)), 1, 0, 0 } /* profileMetaData */
};
asn_SEQUENCE_specifics_t asn_SPC_AuthenticateClientOk_specs_1 = {
sizeof(struct AuthenticateClientOk),
offsetof(struct AuthenticateClientOk, _asn_ctx),
asn_MAP_AuthenticateClientOk_tag2el_1,
3, /* Count of tags in the map */
0, 0, 0, /* Optional elements (not needed) */
3, /* First extension addition */
};
asn_TYPE_descriptor_t asn_DEF_AuthenticateClientOk = {
"AuthenticateClientOk",
"AuthenticateClientOk",
&asn_OP_SEQUENCE,
asn_DEF_AuthenticateClientOk_tags_1,
sizeof(asn_DEF_AuthenticateClientOk_tags_1)
/sizeof(asn_DEF_AuthenticateClientOk_tags_1[0]), /* 1 */
asn_DEF_AuthenticateClientOk_tags_1, /* Same as above */
sizeof(asn_DEF_AuthenticateClientOk_tags_1)
/sizeof(asn_DEF_AuthenticateClientOk_tags_1[0]), /* 1 */
{ 0, 0, SEQUENCE_constraint },
asn_MBR_AuthenticateClientOk_1,
3, /* Elements count */
&asn_SPC_AuthenticateClientOk_specs_1 /* Additional specs */
};

View file

@ -0,0 +1,48 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "RSPDefinitions"
* found in "../../../asn1/rsp.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#ifndef _AuthenticateClientOk_H_
#define _AuthenticateClientOk_H_
#include "asn_application.h"
/* Including external dependencies */
#include "TransactionId.h"
#include "StoreMetadataRequest.h"
#include "PrepareDownloadRequest.h"
#include "constr_SEQUENCE.h"
#ifdef __cplusplus
extern "C" {
#endif
/* AuthenticateClientOk */
typedef struct AuthenticateClientOk {
TransactionId_t transactionId;
StoreMetadataRequest_t profileMetaData;
PrepareDownloadRequest_t prepareDownloadRequest;
/*
* This type is extensible,
* possible extensions are below.
*/
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} AuthenticateClientOk_t;
/* Implementation */
extern asn_TYPE_descriptor_t asn_DEF_AuthenticateClientOk;
extern asn_SEQUENCE_specifics_t asn_SPC_AuthenticateClientOk_specs_1;
extern asn_TYPE_member_t asn_MBR_AuthenticateClientOk_1[3];
#ifdef __cplusplus
}
#endif
#endif /* _AuthenticateClientOk_H_ */
#include "asn_internal.h"

View file

@ -0,0 +1,97 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "RSPDefinitions"
* found in "../../../asn1/rsp.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#include "AuthenticateClientOkEs11.h"
static asn_TYPE_member_t asn_MBR_eventEntries_3[] = {
{ ATF_POINTER, 0, 0,
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
0,
&asn_DEF_EventEntries,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
""
},
};
static const ber_tlv_tag_t asn_DEF_eventEntries_tags_3[] = {
(ASN_TAG_CLASS_CONTEXT | (1 << 2)),
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static asn_SET_OF_specifics_t asn_SPC_eventEntries_specs_3 = {
sizeof(struct AuthenticateClientOkEs11__eventEntries),
offsetof(struct AuthenticateClientOkEs11__eventEntries, _asn_ctx),
0, /* XER encoding is XMLDelimitedItemList */
};
static /* Use -fall-defs-global to expose */
asn_TYPE_descriptor_t asn_DEF_eventEntries_3 = {
"eventEntries",
"eventEntries",
&asn_OP_SEQUENCE_OF,
asn_DEF_eventEntries_tags_3,
sizeof(asn_DEF_eventEntries_tags_3)
/sizeof(asn_DEF_eventEntries_tags_3[0]) - 1, /* 1 */
asn_DEF_eventEntries_tags_3, /* Same as above */
sizeof(asn_DEF_eventEntries_tags_3)
/sizeof(asn_DEF_eventEntries_tags_3[0]), /* 2 */
{ 0, 0, SEQUENCE_OF_constraint },
asn_MBR_eventEntries_3,
1, /* Single element */
&asn_SPC_eventEntries_specs_3 /* Additional specs */
};
asn_TYPE_member_t asn_MBR_AuthenticateClientOkEs11_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct AuthenticateClientOkEs11, transactionId),
(ASN_TAG_CLASS_CONTEXT | (0 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_TransactionId,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"transactionId"
},
{ ATF_NOFLAGS, 0, offsetof(struct AuthenticateClientOkEs11, eventEntries),
(ASN_TAG_CLASS_CONTEXT | (1 << 2)),
0,
&asn_DEF_eventEntries_3,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"eventEntries"
},
};
static const ber_tlv_tag_t asn_DEF_AuthenticateClientOkEs11_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_AuthenticateClientOkEs11_tag2el_1[] = {
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* transactionId */
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* eventEntries */
};
asn_SEQUENCE_specifics_t asn_SPC_AuthenticateClientOkEs11_specs_1 = {
sizeof(struct AuthenticateClientOkEs11),
offsetof(struct AuthenticateClientOkEs11, _asn_ctx),
asn_MAP_AuthenticateClientOkEs11_tag2el_1,
2, /* Count of tags in the map */
0, 0, 0, /* Optional elements (not needed) */
2, /* First extension addition */
};
asn_TYPE_descriptor_t asn_DEF_AuthenticateClientOkEs11 = {
"AuthenticateClientOkEs11",
"AuthenticateClientOkEs11",
&asn_OP_SEQUENCE,
asn_DEF_AuthenticateClientOkEs11_tags_1,
sizeof(asn_DEF_AuthenticateClientOkEs11_tags_1)
/sizeof(asn_DEF_AuthenticateClientOkEs11_tags_1[0]), /* 1 */
asn_DEF_AuthenticateClientOkEs11_tags_1, /* Same as above */
sizeof(asn_DEF_AuthenticateClientOkEs11_tags_1)
/sizeof(asn_DEF_AuthenticateClientOkEs11_tags_1[0]), /* 1 */
{ 0, 0, SEQUENCE_constraint },
asn_MBR_AuthenticateClientOkEs11_1,
2, /* Elements count */
&asn_SPC_AuthenticateClientOkEs11_specs_1 /* Additional specs */
};

View file

@ -0,0 +1,58 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "RSPDefinitions"
* found in "../../../asn1/rsp.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#ifndef _AuthenticateClientOkEs11_H_
#define _AuthenticateClientOkEs11_H_
#include "asn_application.h"
/* Including external dependencies */
#include "TransactionId.h"
#include "asn_SEQUENCE_OF.h"
#include "constr_SEQUENCE_OF.h"
#include "constr_SEQUENCE.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Forward declarations */
struct EventEntries;
/* AuthenticateClientOkEs11 */
typedef struct AuthenticateClientOkEs11 {
TransactionId_t transactionId;
struct AuthenticateClientOkEs11__eventEntries {
A_SEQUENCE_OF(struct EventEntries) list;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} eventEntries;
/*
* This type is extensible,
* possible extensions are below.
*/
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} AuthenticateClientOkEs11_t;
/* Implementation */
extern asn_TYPE_descriptor_t asn_DEF_AuthenticateClientOkEs11;
extern asn_SEQUENCE_specifics_t asn_SPC_AuthenticateClientOkEs11_specs_1;
extern asn_TYPE_member_t asn_MBR_AuthenticateClientOkEs11_1[2];
#ifdef __cplusplus
}
#endif
/* Referred external types */
#include "EventEntries.h"
#endif /* _AuthenticateClientOkEs11_H_ */
#include "asn_internal.h"

View file

@ -0,0 +1,61 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "RSPDefinitions"
* found in "../../../asn1/rsp.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#include "AuthenticateClientRequest.h"
asn_TYPE_member_t asn_MBR_AuthenticateClientRequest_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct AuthenticateClientRequest, transactionId),
(ASN_TAG_CLASS_CONTEXT | (0 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_TransactionId,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"transactionId"
},
{ ATF_NOFLAGS, 0, offsetof(struct AuthenticateClientRequest, authenticateServerResponse),
(ASN_TAG_CLASS_CONTEXT | (56 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_AuthenticateServerResponse,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"authenticateServerResponse"
},
};
static const ber_tlv_tag_t asn_DEF_AuthenticateClientRequest_tags_1[] = {
(ASN_TAG_CLASS_CONTEXT | (59 << 2)),
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_AuthenticateClientRequest_tag2el_1[] = {
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* transactionId */
{ (ASN_TAG_CLASS_CONTEXT | (56 << 2)), 1, 0, 0 } /* authenticateServerResponse */
};
asn_SEQUENCE_specifics_t asn_SPC_AuthenticateClientRequest_specs_1 = {
sizeof(struct AuthenticateClientRequest),
offsetof(struct AuthenticateClientRequest, _asn_ctx),
asn_MAP_AuthenticateClientRequest_tag2el_1,
2, /* Count of tags in the map */
0, 0, 0, /* Optional elements (not needed) */
2, /* First extension addition */
};
asn_TYPE_descriptor_t asn_DEF_AuthenticateClientRequest = {
"AuthenticateClientRequest",
"AuthenticateClientRequest",
&asn_OP_SEQUENCE,
asn_DEF_AuthenticateClientRequest_tags_1,
sizeof(asn_DEF_AuthenticateClientRequest_tags_1)
/sizeof(asn_DEF_AuthenticateClientRequest_tags_1[0]) - 1, /* 1 */
asn_DEF_AuthenticateClientRequest_tags_1, /* Same as above */
sizeof(asn_DEF_AuthenticateClientRequest_tags_1)
/sizeof(asn_DEF_AuthenticateClientRequest_tags_1[0]), /* 2 */
{ 0, 0, SEQUENCE_constraint },
asn_MBR_AuthenticateClientRequest_1,
2, /* Elements count */
&asn_SPC_AuthenticateClientRequest_specs_1 /* Additional specs */
};

View file

@ -0,0 +1,46 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "RSPDefinitions"
* found in "../../../asn1/rsp.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#ifndef _AuthenticateClientRequest_H_
#define _AuthenticateClientRequest_H_
#include "asn_application.h"
/* Including external dependencies */
#include "TransactionId.h"
#include "AuthenticateServerResponse.h"
#include "constr_SEQUENCE.h"
#ifdef __cplusplus
extern "C" {
#endif
/* AuthenticateClientRequest */
typedef struct AuthenticateClientRequest {
TransactionId_t transactionId;
AuthenticateServerResponse_t authenticateServerResponse;
/*
* This type is extensible,
* possible extensions are below.
*/
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} AuthenticateClientRequest_t;
/* Implementation */
extern asn_TYPE_descriptor_t asn_DEF_AuthenticateClientRequest;
extern asn_SEQUENCE_specifics_t asn_SPC_AuthenticateClientRequest_specs_1;
extern asn_TYPE_member_t asn_MBR_AuthenticateClientRequest_1[2];
#ifdef __cplusplus
}
#endif
#endif /* _AuthenticateClientRequest_H_ */
#include "asn_internal.h"

View file

@ -0,0 +1,70 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "RSPDefinitions"
* found in "../../../asn1/rsp.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#include "AuthenticateClientResponseEs11.h"
static asn_oer_constraints_t asn_OER_type_AuthenticateClientResponseEs11_constr_1 CC_NOTUSED = {
{ 0, 0 },
-1};
asn_per_constraints_t asn_PER_type_AuthenticateClientResponseEs11_constr_1 CC_NOTUSED = {
{ APC_CONSTRAINED | APC_EXTENSIBLE, 1, 1, 0, 1 } /* (0..1,...) */,
{ APC_UNCONSTRAINED, -1, -1, 0, 0 },
0, 0 /* No PER value map */
};
asn_TYPE_member_t asn_MBR_AuthenticateClientResponseEs11_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct AuthenticateClientResponseEs11, choice.authenticateClientOk),
(ASN_TAG_CLASS_CONTEXT | (0 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_AuthenticateClientOkEs11,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"authenticateClientOk"
},
{ ATF_NOFLAGS, 0, offsetof(struct AuthenticateClientResponseEs11, choice.authenticateClientError),
(ASN_TAG_CLASS_CONTEXT | (1 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_INTEGER,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"authenticateClientError"
},
};
static const ber_tlv_tag_t asn_DEF_AuthenticateClientResponseEs11_tags_1[] = {
(ASN_TAG_CLASS_CONTEXT | (64 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_AuthenticateClientResponseEs11_tag2el_1[] = {
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* authenticateClientOk */
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* authenticateClientError */
};
asn_CHOICE_specifics_t asn_SPC_AuthenticateClientResponseEs11_specs_1 = {
sizeof(struct AuthenticateClientResponseEs11),
offsetof(struct AuthenticateClientResponseEs11, _asn_ctx),
offsetof(struct AuthenticateClientResponseEs11, present),
sizeof(((struct AuthenticateClientResponseEs11 *)0)->present),
asn_MAP_AuthenticateClientResponseEs11_tag2el_1,
2, /* Count of tags in the map */
0, 0,
2 /* Extensions start */
};
asn_TYPE_descriptor_t asn_DEF_AuthenticateClientResponseEs11 = {
"AuthenticateClientResponseEs11",
"AuthenticateClientResponseEs11",
&asn_OP_CHOICE,
asn_DEF_AuthenticateClientResponseEs11_tags_1,
sizeof(asn_DEF_AuthenticateClientResponseEs11_tags_1)
/sizeof(asn_DEF_AuthenticateClientResponseEs11_tags_1[0]), /* 1 */
asn_DEF_AuthenticateClientResponseEs11_tags_1, /* Same as above */
sizeof(asn_DEF_AuthenticateClientResponseEs11_tags_1)
/sizeof(asn_DEF_AuthenticateClientResponseEs11_tags_1[0]), /* 1 */
{ &asn_OER_type_AuthenticateClientResponseEs11_constr_1, &asn_PER_type_AuthenticateClientResponseEs11_constr_1, CHOICE_constraint },
asn_MBR_AuthenticateClientResponseEs11_1,
2, /* Elements count */
&asn_SPC_AuthenticateClientResponseEs11_specs_1 /* Additional specs */
};

View file

@ -0,0 +1,69 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "RSPDefinitions"
* found in "../../../asn1/rsp.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#ifndef _AuthenticateClientResponseEs11_H_
#define _AuthenticateClientResponseEs11_H_
#include "asn_application.h"
/* Including external dependencies */
#include "AuthenticateClientOkEs11.h"
#include "INTEGER.h"
#include "constr_CHOICE.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Dependencies */
typedef enum AuthenticateClientResponseEs11_PR {
AuthenticateClientResponseEs11_PR_NOTHING, /* No components present */
AuthenticateClientResponseEs11_PR_authenticateClientOk,
AuthenticateClientResponseEs11_PR_authenticateClientError
/* Extensions may appear below */
} AuthenticateClientResponseEs11_PR;
typedef enum AuthenticateClientResponseEs11__authenticateClientError {
AuthenticateClientResponseEs11__authenticateClientError_eumCertificateInvalid = 1,
AuthenticateClientResponseEs11__authenticateClientError_eumCertificateExpired = 2,
AuthenticateClientResponseEs11__authenticateClientError_euiccCertificateInvalid = 3,
AuthenticateClientResponseEs11__authenticateClientError_euiccCertificateExpired = 4,
AuthenticateClientResponseEs11__authenticateClientError_euiccSignatureInvalid = 5,
AuthenticateClientResponseEs11__authenticateClientError_eventIdUnknown = 6,
AuthenticateClientResponseEs11__authenticateClientError_invalidTransactionId = 7,
AuthenticateClientResponseEs11__authenticateClientError_undefinedError = 127
} e_AuthenticateClientResponseEs11__authenticateClientError;
/* AuthenticateClientResponseEs11 */
typedef struct AuthenticateClientResponseEs11 {
AuthenticateClientResponseEs11_PR present;
union AuthenticateClientResponseEs11_u {
AuthenticateClientOkEs11_t authenticateClientOk;
INTEGER_t authenticateClientError;
/*
* This type is extensible,
* possible extensions are below.
*/
} choice;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} AuthenticateClientResponseEs11_t;
/* Implementation */
extern asn_TYPE_descriptor_t asn_DEF_AuthenticateClientResponseEs11;
extern asn_CHOICE_specifics_t asn_SPC_AuthenticateClientResponseEs11_specs_1;
extern asn_TYPE_member_t asn_MBR_AuthenticateClientResponseEs11_1[2];
extern asn_per_constraints_t asn_PER_type_AuthenticateClientResponseEs11_constr_1;
#ifdef __cplusplus
}
#endif
#endif /* _AuthenticateClientResponseEs11_H_ */
#include "asn_internal.h"

View file

@ -0,0 +1,70 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "RSPDefinitions"
* found in "../../../asn1/rsp.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#include "AuthenticateClientResponseEs9.h"
static asn_oer_constraints_t asn_OER_type_AuthenticateClientResponseEs9_constr_1 CC_NOTUSED = {
{ 0, 0 },
-1};
asn_per_constraints_t asn_PER_type_AuthenticateClientResponseEs9_constr_1 CC_NOTUSED = {
{ APC_CONSTRAINED | APC_EXTENSIBLE, 1, 1, 0, 1 } /* (0..1,...) */,
{ APC_UNCONSTRAINED, -1, -1, 0, 0 },
0, 0 /* No PER value map */
};
asn_TYPE_member_t asn_MBR_AuthenticateClientResponseEs9_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct AuthenticateClientResponseEs9, choice.authenticateClientOk),
(ASN_TAG_CLASS_CONTEXT | (0 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_AuthenticateClientOk,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"authenticateClientOk"
},
{ ATF_NOFLAGS, 0, offsetof(struct AuthenticateClientResponseEs9, choice.authenticateClientError),
(ASN_TAG_CLASS_CONTEXT | (1 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_INTEGER,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"authenticateClientError"
},
};
static const ber_tlv_tag_t asn_DEF_AuthenticateClientResponseEs9_tags_1[] = {
(ASN_TAG_CLASS_CONTEXT | (59 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_AuthenticateClientResponseEs9_tag2el_1[] = {
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* authenticateClientOk */
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* authenticateClientError */
};
asn_CHOICE_specifics_t asn_SPC_AuthenticateClientResponseEs9_specs_1 = {
sizeof(struct AuthenticateClientResponseEs9),
offsetof(struct AuthenticateClientResponseEs9, _asn_ctx),
offsetof(struct AuthenticateClientResponseEs9, present),
sizeof(((struct AuthenticateClientResponseEs9 *)0)->present),
asn_MAP_AuthenticateClientResponseEs9_tag2el_1,
2, /* Count of tags in the map */
0, 0,
2 /* Extensions start */
};
asn_TYPE_descriptor_t asn_DEF_AuthenticateClientResponseEs9 = {
"AuthenticateClientResponseEs9",
"AuthenticateClientResponseEs9",
&asn_OP_CHOICE,
asn_DEF_AuthenticateClientResponseEs9_tags_1,
sizeof(asn_DEF_AuthenticateClientResponseEs9_tags_1)
/sizeof(asn_DEF_AuthenticateClientResponseEs9_tags_1[0]), /* 1 */
asn_DEF_AuthenticateClientResponseEs9_tags_1, /* Same as above */
sizeof(asn_DEF_AuthenticateClientResponseEs9_tags_1)
/sizeof(asn_DEF_AuthenticateClientResponseEs9_tags_1[0]), /* 1 */
{ &asn_OER_type_AuthenticateClientResponseEs9_constr_1, &asn_PER_type_AuthenticateClientResponseEs9_constr_1, CHOICE_constraint },
asn_MBR_AuthenticateClientResponseEs9_1,
2, /* Elements count */
&asn_SPC_AuthenticateClientResponseEs9_specs_1 /* Additional specs */
};

View file

@ -0,0 +1,72 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "RSPDefinitions"
* found in "../../../asn1/rsp.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#ifndef _AuthenticateClientResponseEs9_H_
#define _AuthenticateClientResponseEs9_H_
#include "asn_application.h"
/* Including external dependencies */
#include "AuthenticateClientOk.h"
#include "INTEGER.h"
#include "constr_CHOICE.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Dependencies */
typedef enum AuthenticateClientResponseEs9_PR {
AuthenticateClientResponseEs9_PR_NOTHING, /* No components present */
AuthenticateClientResponseEs9_PR_authenticateClientOk,
AuthenticateClientResponseEs9_PR_authenticateClientError
/* Extensions may appear below */
} AuthenticateClientResponseEs9_PR;
typedef enum AuthenticateClientResponseEs9__authenticateClientError {
AuthenticateClientResponseEs9__authenticateClientError_eumCertificateInvalid = 1,
AuthenticateClientResponseEs9__authenticateClientError_eumCertificateExpired = 2,
AuthenticateClientResponseEs9__authenticateClientError_euiccCertificateInvalid = 3,
AuthenticateClientResponseEs9__authenticateClientError_euiccCertificateExpired = 4,
AuthenticateClientResponseEs9__authenticateClientError_euiccSignatureInvalid = 5,
AuthenticateClientResponseEs9__authenticateClientError_matchingIdRefused = 6,
AuthenticateClientResponseEs9__authenticateClientError_eidMismatch = 7,
AuthenticateClientResponseEs9__authenticateClientError_noEligibleProfile = 8,
AuthenticateClientResponseEs9__authenticateClientError_ciPKUnknown = 9,
AuthenticateClientResponseEs9__authenticateClientError_invalidTransactionId = 10,
AuthenticateClientResponseEs9__authenticateClientError_undefinedError = 127
} e_AuthenticateClientResponseEs9__authenticateClientError;
/* AuthenticateClientResponseEs9 */
typedef struct AuthenticateClientResponseEs9 {
AuthenticateClientResponseEs9_PR present;
union AuthenticateClientResponseEs9_u {
AuthenticateClientOk_t authenticateClientOk;
INTEGER_t authenticateClientError;
/*
* This type is extensible,
* possible extensions are below.
*/
} choice;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} AuthenticateClientResponseEs9_t;
/* Implementation */
extern asn_TYPE_descriptor_t asn_DEF_AuthenticateClientResponseEs9;
extern asn_CHOICE_specifics_t asn_SPC_AuthenticateClientResponseEs9_specs_1;
extern asn_TYPE_member_t asn_MBR_AuthenticateClientResponseEs9_1[2];
extern asn_per_constraints_t asn_PER_type_AuthenticateClientResponseEs9_constr_1;
#ifdef __cplusplus
}
#endif
#endif /* _AuthenticateClientResponseEs9_H_ */
#include "asn_internal.h"

View file

@ -0,0 +1,31 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "RSPDefinitions"
* found in "../../../asn1/rsp.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#include "AuthenticateErrorCode.h"
/*
* This type is implemented using INTEGER,
* so here we adjust the DEF accordingly.
*/
static const ber_tlv_tag_t asn_DEF_AuthenticateErrorCode_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (2 << 2))
};
asn_TYPE_descriptor_t asn_DEF_AuthenticateErrorCode = {
"AuthenticateErrorCode",
"AuthenticateErrorCode",
&asn_OP_INTEGER,
asn_DEF_AuthenticateErrorCode_tags_1,
sizeof(asn_DEF_AuthenticateErrorCode_tags_1)
/sizeof(asn_DEF_AuthenticateErrorCode_tags_1[0]), /* 1 */
asn_DEF_AuthenticateErrorCode_tags_1, /* Same as above */
sizeof(asn_DEF_AuthenticateErrorCode_tags_1)
/sizeof(asn_DEF_AuthenticateErrorCode_tags_1[0]), /* 1 */
{ 0, 0, INTEGER_constraint },
0, 0, /* Defined elsewhere */
0 /* No specifics */
};

View file

@ -0,0 +1,55 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "RSPDefinitions"
* found in "../../../asn1/rsp.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#ifndef _AuthenticateErrorCode_H_
#define _AuthenticateErrorCode_H_
#include "asn_application.h"
/* Including external dependencies */
#include "INTEGER.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Dependencies */
typedef enum AuthenticateErrorCode {
AuthenticateErrorCode_invalidCertificate = 1,
AuthenticateErrorCode_invalidSignature = 2,
AuthenticateErrorCode_unsupportedCurve = 3,
AuthenticateErrorCode_noSessionContext = 4,
AuthenticateErrorCode_invalidOid = 5,
AuthenticateErrorCode_euiccChallengeMismatch = 6,
AuthenticateErrorCode_ciPKUnknown = 7,
AuthenticateErrorCode_undefinedError = 127
} e_AuthenticateErrorCode;
/* AuthenticateErrorCode */
typedef INTEGER_t AuthenticateErrorCode_t;
/* Implementation */
extern asn_TYPE_descriptor_t asn_DEF_AuthenticateErrorCode;
asn_struct_free_f AuthenticateErrorCode_free;
asn_struct_print_f AuthenticateErrorCode_print;
asn_constr_check_f AuthenticateErrorCode_constraint;
ber_type_decoder_f AuthenticateErrorCode_decode_ber;
der_type_encoder_f AuthenticateErrorCode_encode_der;
xer_type_decoder_f AuthenticateErrorCode_decode_xer;
xer_type_encoder_f AuthenticateErrorCode_encode_xer;
oer_type_decoder_f AuthenticateErrorCode_decode_oer;
oer_type_encoder_f AuthenticateErrorCode_encode_oer;
per_type_decoder_f AuthenticateErrorCode_decode_uper;
per_type_encoder_f AuthenticateErrorCode_encode_uper;
#ifdef __cplusplus
}
#endif
#endif /* _AuthenticateErrorCode_H_ */
#include "asn_internal.h"

View file

@ -0,0 +1,60 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "RSPDefinitions"
* found in "../../../asn1/rsp.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#include "AuthenticateResponseError.h"
asn_TYPE_member_t asn_MBR_AuthenticateResponseError_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct AuthenticateResponseError, transactionId),
(ASN_TAG_CLASS_CONTEXT | (0 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_TransactionId,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"transactionId"
},
{ ATF_NOFLAGS, 0, offsetof(struct AuthenticateResponseError, authenticateErrorCode),
(ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
0,
&asn_DEF_AuthenticateErrorCode,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"authenticateErrorCode"
},
};
static const ber_tlv_tag_t asn_DEF_AuthenticateResponseError_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_AuthenticateResponseError_tag2el_1[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* authenticateErrorCode */
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 } /* transactionId */
};
asn_SEQUENCE_specifics_t asn_SPC_AuthenticateResponseError_specs_1 = {
sizeof(struct AuthenticateResponseError),
offsetof(struct AuthenticateResponseError, _asn_ctx),
asn_MAP_AuthenticateResponseError_tag2el_1,
2, /* Count of tags in the map */
0, 0, 0, /* Optional elements (not needed) */
2, /* First extension addition */
};
asn_TYPE_descriptor_t asn_DEF_AuthenticateResponseError = {
"AuthenticateResponseError",
"AuthenticateResponseError",
&asn_OP_SEQUENCE,
asn_DEF_AuthenticateResponseError_tags_1,
sizeof(asn_DEF_AuthenticateResponseError_tags_1)
/sizeof(asn_DEF_AuthenticateResponseError_tags_1[0]), /* 1 */
asn_DEF_AuthenticateResponseError_tags_1, /* Same as above */
sizeof(asn_DEF_AuthenticateResponseError_tags_1)
/sizeof(asn_DEF_AuthenticateResponseError_tags_1[0]), /* 1 */
{ 0, 0, SEQUENCE_constraint },
asn_MBR_AuthenticateResponseError_1,
2, /* Elements count */
&asn_SPC_AuthenticateResponseError_specs_1 /* Additional specs */
};

View file

@ -0,0 +1,46 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "RSPDefinitions"
* found in "../../../asn1/rsp.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#ifndef _AuthenticateResponseError_H_
#define _AuthenticateResponseError_H_
#include "asn_application.h"
/* Including external dependencies */
#include "TransactionId.h"
#include "AuthenticateErrorCode.h"
#include "constr_SEQUENCE.h"
#ifdef __cplusplus
extern "C" {
#endif
/* AuthenticateResponseError */
typedef struct AuthenticateResponseError {
TransactionId_t transactionId;
AuthenticateErrorCode_t authenticateErrorCode;
/*
* This type is extensible,
* possible extensions are below.
*/
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} AuthenticateResponseError_t;
/* Implementation */
extern asn_TYPE_descriptor_t asn_DEF_AuthenticateResponseError;
extern asn_SEQUENCE_specifics_t asn_SPC_AuthenticateResponseError_specs_1;
extern asn_TYPE_member_t asn_MBR_AuthenticateResponseError_1[2];
#ifdef __cplusplus
}
#endif
#endif /* _AuthenticateResponseError_H_ */
#include "asn_internal.h"

View file

@ -0,0 +1,80 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "RSPDefinitions"
* found in "../../../asn1/rsp.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#include "AuthenticateResponseOk.h"
asn_TYPE_member_t asn_MBR_AuthenticateResponseOk_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct AuthenticateResponseOk, euiccSigned1),
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
0,
&asn_DEF_EuiccSigned1,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"euiccSigned1"
},
{ ATF_NOFLAGS, 0, offsetof(struct AuthenticateResponseOk, euiccSignature1),
(ASN_TAG_CLASS_APPLICATION | (55 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_OCTET_STRING,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"euiccSignature1"
},
{ ATF_NOFLAGS, 0, offsetof(struct AuthenticateResponseOk, euiccCertificate),
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
0,
&asn_DEF_Certificate,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"euiccCertificate"
},
{ ATF_NOFLAGS, 0, offsetof(struct AuthenticateResponseOk, eumCertificate),
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
0,
&asn_DEF_Certificate,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"eumCertificate"
},
};
static const ber_tlv_tag_t asn_DEF_AuthenticateResponseOk_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_AuthenticateResponseOk_tag2el_1[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, 0, 2 }, /* euiccSigned1 */
{ (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 2, -1, 1 }, /* euiccCertificate */
{ (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 3, -2, 0 }, /* eumCertificate */
{ (ASN_TAG_CLASS_APPLICATION | (55 << 2)), 1, 0, 0 } /* euiccSignature1 */
};
asn_SEQUENCE_specifics_t asn_SPC_AuthenticateResponseOk_specs_1 = {
sizeof(struct AuthenticateResponseOk),
offsetof(struct AuthenticateResponseOk, _asn_ctx),
asn_MAP_AuthenticateResponseOk_tag2el_1,
4, /* Count of tags in the map */
0, 0, 0, /* Optional elements (not needed) */
4, /* First extension addition */
};
asn_TYPE_descriptor_t asn_DEF_AuthenticateResponseOk = {
"AuthenticateResponseOk",
"AuthenticateResponseOk",
&asn_OP_SEQUENCE,
asn_DEF_AuthenticateResponseOk_tags_1,
sizeof(asn_DEF_AuthenticateResponseOk_tags_1)
/sizeof(asn_DEF_AuthenticateResponseOk_tags_1[0]), /* 1 */
asn_DEF_AuthenticateResponseOk_tags_1, /* Same as above */
sizeof(asn_DEF_AuthenticateResponseOk_tags_1)
/sizeof(asn_DEF_AuthenticateResponseOk_tags_1[0]), /* 1 */
{ 0, 0, SEQUENCE_constraint },
asn_MBR_AuthenticateResponseOk_1,
4, /* Elements count */
&asn_SPC_AuthenticateResponseOk_specs_1 /* Additional specs */
};

View file

@ -0,0 +1,49 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "RSPDefinitions"
* found in "../../../asn1/rsp.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#ifndef _AuthenticateResponseOk_H_
#define _AuthenticateResponseOk_H_
#include "asn_application.h"
/* Including external dependencies */
#include "EuiccSigned1.h"
#include "OCTET_STRING.h"
#include "Certificate.h"
#include "constr_SEQUENCE.h"
#ifdef __cplusplus
extern "C" {
#endif
/* AuthenticateResponseOk */
typedef struct AuthenticateResponseOk {
EuiccSigned1_t euiccSigned1;
OCTET_STRING_t euiccSignature1;
Certificate_t euiccCertificate;
Certificate_t eumCertificate;
/*
* This type is extensible,
* possible extensions are below.
*/
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} AuthenticateResponseOk_t;
/* Implementation */
extern asn_TYPE_descriptor_t asn_DEF_AuthenticateResponseOk;
extern asn_SEQUENCE_specifics_t asn_SPC_AuthenticateResponseOk_specs_1;
extern asn_TYPE_member_t asn_MBR_AuthenticateResponseOk_1[4];
#ifdef __cplusplus
}
#endif
#endif /* _AuthenticateResponseOk_H_ */
#include "asn_internal.h"

View file

@ -0,0 +1,91 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "RSPDefinitions"
* found in "../../../asn1/rsp.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#include "AuthenticateServerRequest.h"
static asn_TYPE_member_t asn_MBR_AuthenticateServerRequest_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct AuthenticateServerRequest, serverSigned1),
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
0,
&asn_DEF_ServerSigned1,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"serverSigned1"
},
{ ATF_NOFLAGS, 0, offsetof(struct AuthenticateServerRequest, serverSignature1),
(ASN_TAG_CLASS_APPLICATION | (55 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_OCTET_STRING,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"serverSignature1"
},
{ ATF_NOFLAGS, 0, offsetof(struct AuthenticateServerRequest, euiccCiPKIdToBeUsed),
(ASN_TAG_CLASS_UNIVERSAL | (4 << 2)),
0,
&asn_DEF_SubjectKeyIdentifier,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"euiccCiPKIdToBeUsed"
},
{ ATF_NOFLAGS, 0, offsetof(struct AuthenticateServerRequest, serverCertificate),
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
0,
&asn_DEF_Certificate,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"serverCertificate"
},
{ ATF_NOFLAGS, 0, offsetof(struct AuthenticateServerRequest, ctxParams1),
-1 /* Ambiguous tag (CHOICE?) */,
0,
&asn_DEF_CtxParams1,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"ctxParams1"
},
};
static const ber_tlv_tag_t asn_DEF_AuthenticateServerRequest_tags_1[] = {
(ASN_TAG_CLASS_CONTEXT | (56 << 2)),
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_AuthenticateServerRequest_tag2el_1[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (4 << 2)), 2, 0, 0 }, /* euiccCiPKIdToBeUsed */
{ (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, 0, 1 }, /* serverSigned1 */
{ (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 3, -1, 0 }, /* serverCertificate */
{ (ASN_TAG_CLASS_APPLICATION | (55 << 2)), 1, 0, 0 }, /* serverSignature1 */
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 4, 0, 0 } /* ctxParamsForCommonAuthentication */
};
static asn_SEQUENCE_specifics_t asn_SPC_AuthenticateServerRequest_specs_1 = {
sizeof(struct AuthenticateServerRequest),
offsetof(struct AuthenticateServerRequest, _asn_ctx),
asn_MAP_AuthenticateServerRequest_tag2el_1,
5, /* Count of tags in the map */
0, 0, 0, /* Optional elements (not needed) */
5, /* First extension addition */
};
asn_TYPE_descriptor_t asn_DEF_AuthenticateServerRequest = {
"AuthenticateServerRequest",
"AuthenticateServerRequest",
&asn_OP_SEQUENCE,
asn_DEF_AuthenticateServerRequest_tags_1,
sizeof(asn_DEF_AuthenticateServerRequest_tags_1)
/sizeof(asn_DEF_AuthenticateServerRequest_tags_1[0]) - 1, /* 1 */
asn_DEF_AuthenticateServerRequest_tags_1, /* Same as above */
sizeof(asn_DEF_AuthenticateServerRequest_tags_1)
/sizeof(asn_DEF_AuthenticateServerRequest_tags_1[0]), /* 2 */
{ 0, 0, SEQUENCE_constraint },
asn_MBR_AuthenticateServerRequest_1,
5, /* Elements count */
&asn_SPC_AuthenticateServerRequest_specs_1 /* Additional specs */
};

View file

@ -0,0 +1,50 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "RSPDefinitions"
* found in "../../../asn1/rsp.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#ifndef _AuthenticateServerRequest_H_
#define _AuthenticateServerRequest_H_
#include "asn_application.h"
/* Including external dependencies */
#include "ServerSigned1.h"
#include "OCTET_STRING.h"
#include "SubjectKeyIdentifier.h"
#include "Certificate.h"
#include "CtxParams1.h"
#include "constr_SEQUENCE.h"
#ifdef __cplusplus
extern "C" {
#endif
/* AuthenticateServerRequest */
typedef struct AuthenticateServerRequest {
ServerSigned1_t serverSigned1;
OCTET_STRING_t serverSignature1;
SubjectKeyIdentifier_t euiccCiPKIdToBeUsed;
Certificate_t serverCertificate;
CtxParams1_t ctxParams1;
/*
* This type is extensible,
* possible extensions are below.
*/
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} AuthenticateServerRequest_t;
/* Implementation */
extern asn_TYPE_descriptor_t asn_DEF_AuthenticateServerRequest;
#ifdef __cplusplus
}
#endif
#endif /* _AuthenticateServerRequest_H_ */
#include "asn_internal.h"

View file

@ -0,0 +1,70 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "RSPDefinitions"
* found in "../../../asn1/rsp.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#include "AuthenticateServerResponse.h"
static asn_oer_constraints_t asn_OER_type_AuthenticateServerResponse_constr_1 CC_NOTUSED = {
{ 0, 0 },
-1};
asn_per_constraints_t asn_PER_type_AuthenticateServerResponse_constr_1 CC_NOTUSED = {
{ APC_CONSTRAINED | APC_EXTENSIBLE, 1, 1, 0, 1 } /* (0..1,...) */,
{ APC_UNCONSTRAINED, -1, -1, 0, 0 },
0, 0 /* No PER value map */
};
asn_TYPE_member_t asn_MBR_AuthenticateServerResponse_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct AuthenticateServerResponse, choice.authenticateResponseOk),
(ASN_TAG_CLASS_CONTEXT | (0 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_AuthenticateResponseOk,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"authenticateResponseOk"
},
{ ATF_NOFLAGS, 0, offsetof(struct AuthenticateServerResponse, choice.authenticateResponseError),
(ASN_TAG_CLASS_CONTEXT | (1 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_AuthenticateResponseError,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"authenticateResponseError"
},
};
static const ber_tlv_tag_t asn_DEF_AuthenticateServerResponse_tags_1[] = {
(ASN_TAG_CLASS_CONTEXT | (56 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_AuthenticateServerResponse_tag2el_1[] = {
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* authenticateResponseOk */
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* authenticateResponseError */
};
asn_CHOICE_specifics_t asn_SPC_AuthenticateServerResponse_specs_1 = {
sizeof(struct AuthenticateServerResponse),
offsetof(struct AuthenticateServerResponse, _asn_ctx),
offsetof(struct AuthenticateServerResponse, present),
sizeof(((struct AuthenticateServerResponse *)0)->present),
asn_MAP_AuthenticateServerResponse_tag2el_1,
2, /* Count of tags in the map */
0, 0,
2 /* Extensions start */
};
asn_TYPE_descriptor_t asn_DEF_AuthenticateServerResponse = {
"AuthenticateServerResponse",
"AuthenticateServerResponse",
&asn_OP_CHOICE,
asn_DEF_AuthenticateServerResponse_tags_1,
sizeof(asn_DEF_AuthenticateServerResponse_tags_1)
/sizeof(asn_DEF_AuthenticateServerResponse_tags_1[0]), /* 1 */
asn_DEF_AuthenticateServerResponse_tags_1, /* Same as above */
sizeof(asn_DEF_AuthenticateServerResponse_tags_1)
/sizeof(asn_DEF_AuthenticateServerResponse_tags_1[0]), /* 1 */
{ &asn_OER_type_AuthenticateServerResponse_constr_1, &asn_PER_type_AuthenticateServerResponse_constr_1, CHOICE_constraint },
asn_MBR_AuthenticateServerResponse_1,
2, /* Elements count */
&asn_SPC_AuthenticateServerResponse_specs_1 /* Additional specs */
};

View file

@ -0,0 +1,59 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "RSPDefinitions"
* found in "../../../asn1/rsp.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#ifndef _AuthenticateServerResponse_H_
#define _AuthenticateServerResponse_H_
#include "asn_application.h"
/* Including external dependencies */
#include "AuthenticateResponseOk.h"
#include "AuthenticateResponseError.h"
#include "constr_CHOICE.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Dependencies */
typedef enum AuthenticateServerResponse_PR {
AuthenticateServerResponse_PR_NOTHING, /* No components present */
AuthenticateServerResponse_PR_authenticateResponseOk,
AuthenticateServerResponse_PR_authenticateResponseError
/* Extensions may appear below */
} AuthenticateServerResponse_PR;
/* AuthenticateServerResponse */
typedef struct AuthenticateServerResponse {
AuthenticateServerResponse_PR present;
union AuthenticateServerResponse_u {
AuthenticateResponseOk_t authenticateResponseOk;
AuthenticateResponseError_t authenticateResponseError;
/*
* This type is extensible,
* possible extensions are below.
*/
} choice;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} AuthenticateServerResponse_t;
/* Implementation */
extern asn_TYPE_descriptor_t asn_DEF_AuthenticateServerResponse;
extern asn_CHOICE_specifics_t asn_SPC_AuthenticateServerResponse_specs_1;
extern asn_TYPE_member_t asn_MBR_AuthenticateServerResponse_1[2];
extern asn_per_constraints_t asn_PER_type_AuthenticateServerResponse_constr_1;
#ifdef __cplusplus
}
#endif
#endif /* _AuthenticateServerResponse_H_ */
#include "asn_internal.h"

View file

@ -0,0 +1,52 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "PKIX1Implicit88"
* found in "../../../asn1/PKIXImplicit88.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#include "AuthorityInfoAccessSyntax.h"
static asn_oer_constraints_t asn_OER_type_AuthorityInfoAccessSyntax_constr_1 CC_NOTUSED = {
{ 0, 0 },
-1 /* (SIZE(1..MAX)) */};
static asn_per_constraints_t asn_PER_type_AuthorityInfoAccessSyntax_constr_1 CC_NOTUSED = {
{ APC_UNCONSTRAINED, -1, -1, 0, 0 },
{ APC_SEMI_CONSTRAINED, -1, -1, 1, 0 } /* (SIZE(1..MAX)) */,
0, 0 /* No PER value map */
};
static asn_TYPE_member_t asn_MBR_AuthorityInfoAccessSyntax_1[] = {
{ ATF_POINTER, 0, 0,
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
0,
&asn_DEF_AccessDescription,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
""
},
};
static const ber_tlv_tag_t asn_DEF_AuthorityInfoAccessSyntax_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static asn_SET_OF_specifics_t asn_SPC_AuthorityInfoAccessSyntax_specs_1 = {
sizeof(struct AuthorityInfoAccessSyntax),
offsetof(struct AuthorityInfoAccessSyntax, _asn_ctx),
0, /* XER encoding is XMLDelimitedItemList */
};
asn_TYPE_descriptor_t asn_DEF_AuthorityInfoAccessSyntax = {
"AuthorityInfoAccessSyntax",
"AuthorityInfoAccessSyntax",
&asn_OP_SEQUENCE_OF,
asn_DEF_AuthorityInfoAccessSyntax_tags_1,
sizeof(asn_DEF_AuthorityInfoAccessSyntax_tags_1)
/sizeof(asn_DEF_AuthorityInfoAccessSyntax_tags_1[0]), /* 1 */
asn_DEF_AuthorityInfoAccessSyntax_tags_1, /* Same as above */
sizeof(asn_DEF_AuthorityInfoAccessSyntax_tags_1)
/sizeof(asn_DEF_AuthorityInfoAccessSyntax_tags_1[0]), /* 1 */
{ &asn_OER_type_AuthorityInfoAccessSyntax_constr_1, &asn_PER_type_AuthorityInfoAccessSyntax_constr_1, SEQUENCE_OF_constraint },
asn_MBR_AuthorityInfoAccessSyntax_1,
1, /* Single element */
&asn_SPC_AuthorityInfoAccessSyntax_specs_1 /* Additional specs */
};

View file

@ -0,0 +1,44 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "PKIX1Implicit88"
* found in "../../../asn1/PKIXImplicit88.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#ifndef _AuthorityInfoAccessSyntax_H_
#define _AuthorityInfoAccessSyntax_H_
#include "asn_application.h"
/* Including external dependencies */
#include "asn_SEQUENCE_OF.h"
#include "constr_SEQUENCE_OF.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Forward declarations */
struct AccessDescription;
/* AuthorityInfoAccessSyntax */
typedef struct AuthorityInfoAccessSyntax {
A_SEQUENCE_OF(struct AccessDescription) list;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} AuthorityInfoAccessSyntax_t;
/* Implementation */
extern asn_TYPE_descriptor_t asn_DEF_AuthorityInfoAccessSyntax;
#ifdef __cplusplus
}
#endif
/* Referred external types */
#include "AccessDescription.h"
#endif /* _AuthorityInfoAccessSyntax_H_ */
#include "asn_internal.h"

View file

@ -0,0 +1,72 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "PKIX1Implicit88"
* found in "../../../asn1/PKIXImplicit88.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#include "AuthorityKeyIdentifier.h"
static asn_TYPE_member_t asn_MBR_AuthorityKeyIdentifier_1[] = {
{ ATF_POINTER, 3, offsetof(struct AuthorityKeyIdentifier, keyIdentifier),
(ASN_TAG_CLASS_CONTEXT | (0 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_KeyIdentifier,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"keyIdentifier"
},
{ ATF_POINTER, 2, offsetof(struct AuthorityKeyIdentifier, authorityCertIssuer),
(ASN_TAG_CLASS_CONTEXT | (1 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_GeneralNames,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"authorityCertIssuer"
},
{ ATF_POINTER, 1, offsetof(struct AuthorityKeyIdentifier, authorityCertSerialNumber),
(ASN_TAG_CLASS_CONTEXT | (2 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_CertificateSerialNumber,
0,
{ 0, 0, 0 },
0, 0, /* No default value */
"authorityCertSerialNumber"
},
};
static const int asn_MAP_AuthorityKeyIdentifier_oms_1[] = { 0, 1, 2 };
static const ber_tlv_tag_t asn_DEF_AuthorityKeyIdentifier_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_AuthorityKeyIdentifier_tag2el_1[] = {
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* keyIdentifier */
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* authorityCertIssuer */
{ (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* authorityCertSerialNumber */
};
static asn_SEQUENCE_specifics_t asn_SPC_AuthorityKeyIdentifier_specs_1 = {
sizeof(struct AuthorityKeyIdentifier),
offsetof(struct AuthorityKeyIdentifier, _asn_ctx),
asn_MAP_AuthorityKeyIdentifier_tag2el_1,
3, /* Count of tags in the map */
asn_MAP_AuthorityKeyIdentifier_oms_1, /* Optional members */
3, 0, /* Root/Additions */
-1, /* First extension addition */
};
asn_TYPE_descriptor_t asn_DEF_AuthorityKeyIdentifier = {
"AuthorityKeyIdentifier",
"AuthorityKeyIdentifier",
&asn_OP_SEQUENCE,
asn_DEF_AuthorityKeyIdentifier_tags_1,
sizeof(asn_DEF_AuthorityKeyIdentifier_tags_1)
/sizeof(asn_DEF_AuthorityKeyIdentifier_tags_1[0]), /* 1 */
asn_DEF_AuthorityKeyIdentifier_tags_1, /* Same as above */
sizeof(asn_DEF_AuthorityKeyIdentifier_tags_1)
/sizeof(asn_DEF_AuthorityKeyIdentifier_tags_1[0]), /* 1 */
{ 0, 0, SEQUENCE_constraint },
asn_MBR_AuthorityKeyIdentifier_1,
3, /* Elements count */
&asn_SPC_AuthorityKeyIdentifier_specs_1 /* Additional specs */
};

View file

@ -0,0 +1,47 @@
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "PKIX1Implicit88"
* found in "../../../asn1/PKIXImplicit88.asn"
* `asn1c -fwide-types -fcompound-names -fincludes-quoted -no-gen-example`
*/
#ifndef _AuthorityKeyIdentifier_H_
#define _AuthorityKeyIdentifier_H_
#include "asn_application.h"
/* Including external dependencies */
#include "KeyIdentifier.h"
#include "CertificateSerialNumber.h"
#include "constr_SEQUENCE.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Forward declarations */
struct GeneralNames;
/* AuthorityKeyIdentifier */
typedef struct AuthorityKeyIdentifier {
KeyIdentifier_t *keyIdentifier /* OPTIONAL */;
struct GeneralNames *authorityCertIssuer /* OPTIONAL */;
CertificateSerialNumber_t *authorityCertSerialNumber /* OPTIONAL */;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} AuthorityKeyIdentifier_t;
/* Implementation */
extern asn_TYPE_descriptor_t asn_DEF_AuthorityKeyIdentifier;
#ifdef __cplusplus
}
#endif
/* Referred external types */
#include "GeneralNames.h"
#endif /* _AuthorityKeyIdentifier_H_ */
#include "asn_internal.h"

View file

@ -0,0 +1,652 @@
/*-
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
*/
#include "asn_internal.h"
#include "BIT_STRING.h"
#include "asn_internal.h"
/*
* BIT STRING basic type description.
*/
static const ber_tlv_tag_t asn_DEF_BIT_STRING_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (3 << 2))
};
asn_OCTET_STRING_specifics_t asn_SPC_BIT_STRING_specs = {
sizeof(BIT_STRING_t),
offsetof(BIT_STRING_t, _asn_ctx),
ASN_OSUBV_BIT
};
asn_TYPE_operation_t asn_OP_BIT_STRING = {
OCTET_STRING_free, /* Implemented in terms of OCTET STRING */
BIT_STRING_print,
BIT_STRING_compare,
OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */
OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */
OCTET_STRING_decode_xer_binary,
BIT_STRING_encode_xer,
#ifdef ASN_DISABLE_OER_SUPPORT
0,
0,
#else
BIT_STRING_decode_oer,
BIT_STRING_encode_oer,
#endif /* ASN_DISABLE_OER_SUPPORT */
#ifdef ASN_DISABLE_PER_SUPPORT
0,
0,
#else
BIT_STRING_decode_uper, /* Unaligned PER decoder */
BIT_STRING_encode_uper, /* Unaligned PER encoder */
#endif /* ASN_DISABLE_PER_SUPPORT */
BIT_STRING_random_fill,
0 /* Use generic outmost tag fetcher */
};
asn_TYPE_descriptor_t asn_DEF_BIT_STRING = {
"BIT STRING",
"BIT_STRING",
&asn_OP_BIT_STRING,
asn_DEF_BIT_STRING_tags,
sizeof(asn_DEF_BIT_STRING_tags)
/ sizeof(asn_DEF_BIT_STRING_tags[0]),
asn_DEF_BIT_STRING_tags, /* Same as above */
sizeof(asn_DEF_BIT_STRING_tags)
/ sizeof(asn_DEF_BIT_STRING_tags[0]),
{ 0, 0, BIT_STRING_constraint },
0, 0, /* No members */
&asn_SPC_BIT_STRING_specs
};
/*
* BIT STRING generic constraint.
*/
int
BIT_STRING_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
const BIT_STRING_t *st = (const BIT_STRING_t *)sptr;
if(st && st->buf) {
if((st->size == 0 && st->bits_unused)
|| st->bits_unused < 0 || st->bits_unused > 7) {
ASN__CTFAIL(app_key, td, sptr,
"%s: invalid padding byte (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
} else {
ASN__CTFAIL(app_key, td, sptr,
"%s: value not given (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
return 0;
}
static const char *_bit_pattern[16] = {
"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111",
"1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"
};
asn_enc_rval_t
BIT_STRING_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr,
int ilevel, enum xer_encoder_flags_e flags,
asn_app_consume_bytes_f *cb, void *app_key) {
asn_enc_rval_t er;
char scratch[128];
char *p = scratch;
char *scend = scratch + (sizeof(scratch) - 10);
const BIT_STRING_t *st = (const BIT_STRING_t *)sptr;
int xcan = (flags & XER_F_CANONICAL);
uint8_t *buf;
uint8_t *end;
if(!st || !st->buf)
ASN__ENCODE_FAILED;
er.encoded = 0;
buf = st->buf;
end = buf + st->size - 1; /* Last byte is special */
/*
* Binary dump
*/
for(; buf < end; buf++) {
int v = *buf;
int nline = xcan?0:(((buf - st->buf) % 8) == 0);
if(p >= scend || nline) {
ASN__CALLBACK(scratch, p - scratch);
p = scratch;
if(nline) ASN__TEXT_INDENT(1, ilevel);
}
memcpy(p + 0, _bit_pattern[v >> 4], 4);
memcpy(p + 4, _bit_pattern[v & 0x0f], 4);
p += 8;
}
if(!xcan && ((buf - st->buf) % 8) == 0)
ASN__TEXT_INDENT(1, ilevel);
ASN__CALLBACK(scratch, p - scratch);
p = scratch;
if(buf == end) {
int v = *buf;
int ubits = st->bits_unused;
int i;
for(i = 7; i >= ubits; i--)
*p++ = (v & (1 << i)) ? 0x31 : 0x30;
ASN__CALLBACK(scratch, p - scratch);
}
if(!xcan) ASN__TEXT_INDENT(1, ilevel - 1);
ASN__ENCODED_OK(er);
cb_failed:
ASN__ENCODE_FAILED;
}
/*
* BIT STRING specific contents printer.
*/
int
BIT_STRING_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
asn_app_consume_bytes_f *cb, void *app_key) {
const char * const h2c = "0123456789ABCDEF";
char scratch[64];
const BIT_STRING_t *st = (const BIT_STRING_t *)sptr;
uint8_t *buf;
uint8_t *end;
char *p = scratch;
(void)td; /* Unused argument */
if(!st || !st->buf)
return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
ilevel++;
buf = st->buf;
end = buf + st->size;
/*
* Hexadecimal dump.
*/
for(; buf < end; buf++) {
if((buf - st->buf) % 16 == 0 && (st->size > 16)
&& buf != st->buf) {
_i_INDENT(1);
/* Dump the string */
if(cb(scratch, p - scratch, app_key) < 0) return -1;
p = scratch;
}
*p++ = h2c[*buf >> 4];
*p++ = h2c[*buf & 0x0F];
*p++ = 0x20;
}
if(p > scratch) {
p--; /* Eat the tailing space */
if((st->size > 16)) {
_i_INDENT(1);
}
/* Dump the incomplete 16-bytes row */
if(cb(scratch, p - scratch, app_key) < 0)
return -1;
}
if(st->bits_unused) {
int ret = snprintf(scratch, sizeof(scratch), " (%d bit%s unused)",
st->bits_unused, st->bits_unused == 1 ? "" : "s");
assert(ret > 0 && ret < (ssize_t)sizeof(scratch));
if(ret > 0 && ret < (ssize_t)sizeof(scratch)
&& cb(scratch, ret, app_key) < 0)
return -1;
}
return 0;
}
/*
* Non-destructively remove the trailing 0-bits from the given bit string.
*/
static const BIT_STRING_t *
BIT_STRING__compactify(const BIT_STRING_t *st, BIT_STRING_t *tmp) {
const uint8_t *b;
union {
const uint8_t *c_buf;
uint8_t *nc_buf;
} unconst;
if(st->size == 0) {
assert(st->bits_unused == 0);
return st;
} else {
for(b = &st->buf[st->size - 1]; b > st->buf && *b == 0; b--) {
;
}
/* b points to the last byte which may contain data */
if(*b) {
int unused = 7;
uint8_t v = *b;
v &= -(int8_t)v;
if(v & 0x0F) unused -= 4;
if(v & 0x33) unused -= 2;
if(v & 0x55) unused -= 1;
tmp->size = b-st->buf + 1;
tmp->bits_unused = unused;
} else {
tmp->size = b-st->buf;
tmp->bits_unused = 0;
}
assert(b >= st->buf);
}
unconst.c_buf = st->buf;
tmp->buf = unconst.nc_buf;
return tmp;
}
/*
* Lexicographically compare the common prefix of both strings,
* and if it is the same return -1 for the smallest string.
*/
int
BIT_STRING_compare(const asn_TYPE_descriptor_t *td, const void *aptr,
const void *bptr) {
/*
* Remove information about trailing bits, since
* X.680 (08/2015) #22.7 "ensure that different semantics are not"
* "associated with [values that differ only in] the trailing 0 bits."
*/
BIT_STRING_t compact_a, compact_b;
const BIT_STRING_t *a = BIT_STRING__compactify(aptr, &compact_a);
const BIT_STRING_t *b = BIT_STRING__compactify(bptr, &compact_b);
const asn_OCTET_STRING_specifics_t *specs = td->specifics;
assert(specs && specs->subvariant == ASN_OSUBV_BIT);
if(a && b) {
size_t common_prefix_size = a->size <= b->size ? a->size : b->size;
int ret = memcmp(a->buf, b->buf, common_prefix_size);
if(ret == 0) {
/* Figure out which string with equal prefixes is longer. */
if(a->size < b->size) {
return -1;
} else if(a->size > b->size) {
return 1;
} else {
/* Figure out how many unused bits */
if(a->bits_unused > b->bits_unused) {
return -1;
} else if(a->bits_unused < b->bits_unused) {
return 1;
} else {
return 0;
}
}
} else {
return ret;
}
} else if(!a && !b) {
return 0;
} else if(!a) {
return -1;
} else {
return 1;
}
}
#ifndef ASN_DISABLE_PER_SUPPORT
#undef RETURN
#define RETURN(_code) \
do { \
asn_dec_rval_t tmprval; \
tmprval.code = _code; \
tmprval.consumed = consumed_myself; \
return tmprval; \
} while(0)
static asn_per_constraint_t asn_DEF_BIT_STRING_constraint_size = {
APC_SEMI_CONSTRAINED, -1, -1, 0, 0};
asn_dec_rval_t
BIT_STRING_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints, void **sptr,
asn_per_data_t *pd) {
const asn_OCTET_STRING_specifics_t *specs = td->specifics
? (const asn_OCTET_STRING_specifics_t *)td->specifics
: &asn_SPC_BIT_STRING_specs;
const asn_per_constraints_t *pc =
constraints ? constraints : td->encoding_constraints.per_constraints;
const asn_per_constraint_t *csiz;
asn_dec_rval_t rval = { RC_OK, 0 };
BIT_STRING_t *st = (BIT_STRING_t *)*sptr;
ssize_t consumed_myself = 0;
int repeat;
(void)opt_codec_ctx;
if(pc) {
csiz = &pc->size;
} else {
csiz = &asn_DEF_BIT_STRING_constraint_size;
}
if(specs->subvariant != ASN_OSUBV_BIT) {
ASN_DEBUG("Subvariant %d is not BIT OSUBV_BIT", specs->subvariant);
RETURN(RC_FAIL);
}
/*
* Allocate the string.
*/
if(!st) {
st = (BIT_STRING_t *)(*sptr = CALLOC(1, specs->struct_size));
if(!st) RETURN(RC_FAIL);
}
ASN_DEBUG("PER Decoding %s size %ld .. %ld bits %d",
csiz->flags & APC_EXTENSIBLE ? "extensible" : "non-extensible",
csiz->lower_bound, csiz->upper_bound, csiz->effective_bits);
if(csiz->flags & APC_EXTENSIBLE) {
int inext = per_get_few_bits(pd, 1);
if(inext < 0) RETURN(RC_WMORE);
if(inext) {
csiz = &asn_DEF_BIT_STRING_constraint_size;
}
}
if(csiz->effective_bits >= 0) {
FREEMEM(st->buf);
st->size = (csiz->upper_bound + 7) >> 3;
st->buf = (uint8_t *)MALLOC(st->size + 1);
if(!st->buf) { st->size = 0; RETURN(RC_FAIL); }
}
/* X.691, #16.5: zero-length encoding */
/* X.691, #16.6: short fixed length encoding (up to 2 octets) */
/* X.691, #16.7: long fixed length encoding (up to 64K octets) */
if(csiz->effective_bits == 0) {
int ret;
ASN_DEBUG("Encoding BIT STRING size %ld", csiz->upper_bound);
ret = per_get_many_bits(pd, st->buf, 0, csiz->upper_bound);
if(ret < 0) RETURN(RC_WMORE);
consumed_myself += csiz->upper_bound;
st->buf[st->size] = 0;
st->bits_unused = (8 - (csiz->upper_bound & 0x7)) & 0x7;
RETURN(RC_OK);
}
st->size = 0;
do {
ssize_t raw_len;
ssize_t len_bytes;
ssize_t len_bits;
void *p;
int ret;
/* Get the PER length */
raw_len = uper_get_length(pd, csiz->effective_bits, csiz->lower_bound,
&repeat);
if(raw_len < 0) RETURN(RC_WMORE);
if(raw_len == 0 && st->buf) break;
ASN_DEBUG("Got PER length eb %ld, len %ld, %s (%s)",
(long)csiz->effective_bits, (long)raw_len,
repeat ? "repeat" : "once", td->name);
len_bits = raw_len;
len_bytes = (len_bits + 7) >> 3;
if(len_bits & 0x7) st->bits_unused = 8 - (len_bits & 0x7);
/* len_bits be multiple of 16K if repeat is set */
p = REALLOC(st->buf, st->size + len_bytes + 1);
if(!p) RETURN(RC_FAIL);
st->buf = (uint8_t *)p;
ret = per_get_many_bits(pd, &st->buf[st->size], 0, len_bits);
if(ret < 0) RETURN(RC_WMORE);
st->size += len_bytes;
} while(repeat);
st->buf[st->size] = 0; /* nul-terminate */
return rval;
}
asn_enc_rval_t
BIT_STRING_encode_uper(const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints,
const void *sptr, asn_per_outp_t *po) {
const asn_OCTET_STRING_specifics_t *specs =
td->specifics ? (const asn_OCTET_STRING_specifics_t *)td->specifics
: &asn_SPC_BIT_STRING_specs;
const asn_per_constraints_t *pc =
constraints ? constraints : td->encoding_constraints.per_constraints;
const asn_per_constraint_t *csiz;
const BIT_STRING_t *st = (const BIT_STRING_t *)sptr;
BIT_STRING_t compact_bstr; /* Do not modify this directly! */
asn_enc_rval_t er = { 0, 0, 0 };
int inext = 0; /* Lies not within extension root */
size_t size_in_bits;
const uint8_t *buf;
int ret;
int ct_extensible;
if(!st || (!st->buf && st->size))
ASN__ENCODE_FAILED;
if(specs->subvariant == ASN_OSUBV_BIT) {
if((st->size == 0 && st->bits_unused) || (st->bits_unused & ~7))
ASN__ENCODE_FAILED;
} else {
ASN__ENCODE_FAILED;
}
if(pc) {
csiz = &pc->size;
} else {
csiz = &asn_DEF_BIT_STRING_constraint_size;
}
ct_extensible = csiz->flags & APC_EXTENSIBLE;
/* Figure out the size without the trailing bits */
st = BIT_STRING__compactify(st, &compact_bstr);
size_in_bits = 8 * st->size - st->bits_unused;
ASN_DEBUG(
"Encoding %s into %" ASN_PRI_SIZE " bits"
" (%ld..%ld, effective %d)%s",
td->name, size_in_bits, csiz->lower_bound, csiz->upper_bound,
csiz->effective_bits, ct_extensible ? " EXT" : "");
/* Figure out whether size lies within PER visible constraint */
if(csiz->effective_bits >= 0) {
if((ssize_t)size_in_bits > csiz->upper_bound) {
if(ct_extensible) {
csiz = &asn_DEF_BIT_STRING_constraint_size;
inext = 1;
} else {
ASN__ENCODE_FAILED;
}
}
} else {
inext = 0;
}
if(ct_extensible) {
/* Declare whether length is [not] within extension root */
if(per_put_few_bits(po, inext, 1))
ASN__ENCODE_FAILED;
}
if(csiz->effective_bits >= 0 && !inext) {
int add_trailer = (ssize_t)size_in_bits < csiz->lower_bound;
ASN_DEBUG(
"Encoding %" ASN_PRI_SIZE " bytes (%ld), length (in %d bits) trailer %d; actual "
"value %" ASN_PRI_SSIZE "",
st->size, size_in_bits - csiz->lower_bound, csiz->effective_bits,
add_trailer,
add_trailer ? 0 : (ssize_t)size_in_bits - csiz->lower_bound);
ret = per_put_few_bits(
po, add_trailer ? 0 : (ssize_t)size_in_bits - csiz->lower_bound,
csiz->effective_bits);
if(ret) ASN__ENCODE_FAILED;
ret = per_put_many_bits(po, st->buf, size_in_bits);
if(ret) ASN__ENCODE_FAILED;
if(add_trailer) {
static const uint8_t zeros[16];
size_t trailing_zero_bits = csiz->lower_bound - size_in_bits;
while(trailing_zero_bits > 0) {
if(trailing_zero_bits > 8 * sizeof(zeros)) {
ret = per_put_many_bits(po, zeros, 8 * sizeof(zeros));
trailing_zero_bits -= 8 * sizeof(zeros);
} else {
ret = per_put_many_bits(po, zeros, trailing_zero_bits);
trailing_zero_bits = 0;
}
if(ret) ASN__ENCODE_FAILED;
}
}
ASN__ENCODED_OK(er);
}
ASN_DEBUG("Encoding %" ASN_PRI_SIZE " bytes", st->size);
buf = st->buf;
do {
int need_eom = 0;
ssize_t maySave = uper_put_length(po, size_in_bits, &need_eom);
if(maySave < 0) ASN__ENCODE_FAILED;
ASN_DEBUG("Encoding %" ASN_PRI_SSIZE " of %" ASN_PRI_SIZE "", maySave, size_in_bits);
ret = per_put_many_bits(po, buf, maySave);
if(ret) ASN__ENCODE_FAILED;
buf += maySave >> 3;
size_in_bits -= maySave;
assert(!(maySave & 0x07) || !size_in_bits);
if(need_eom && uper_put_length(po, 0, 0))
ASN__ENCODE_FAILED; /* End of Message length */
} while(size_in_bits);
ASN__ENCODED_OK(er);
}
#endif /* ASN_DISABLE_PER_SUPPORT */
asn_random_fill_result_t
BIT_STRING_random_fill(const asn_TYPE_descriptor_t *td, void **sptr,
const asn_encoding_constraints_t *constraints,
size_t max_length) {
const asn_OCTET_STRING_specifics_t *specs =
td->specifics ? (const asn_OCTET_STRING_specifics_t *)td->specifics
: &asn_SPC_BIT_STRING_specs;
asn_random_fill_result_t result_ok = {ARFILL_OK, 1};
asn_random_fill_result_t result_failed = {ARFILL_FAILED, 0};
asn_random_fill_result_t result_skipped = {ARFILL_SKIPPED, 0};
static unsigned lengths[] = {0, 1, 2, 3, 4, 8,
126, 127, 128, 16383, 16384, 16385,
65534, 65535, 65536, 65537};
uint8_t *buf;
uint8_t *bend;
uint8_t *b;
size_t rnd_bits, rnd_len;
BIT_STRING_t *st;
if(max_length == 0) return result_skipped;
switch(specs->subvariant) {
case ASN_OSUBV_ANY:
return result_failed;
case ASN_OSUBV_BIT:
break;
default:
break;
}
/* Figure out how far we should go */
rnd_bits = lengths[asn_random_between(
0, sizeof(lengths) / sizeof(lengths[0]) - 1)];
if(!constraints || !constraints->per_constraints)
constraints = &td->encoding_constraints;
if(constraints->per_constraints) {
const asn_per_constraint_t *pc = &constraints->per_constraints->size;
if(pc->flags & APC_CONSTRAINED) {
long suggested_upper_bound = pc->upper_bound < (ssize_t)max_length
? pc->upper_bound
: (ssize_t)max_length;
if(max_length < (size_t)pc->lower_bound) {
return result_skipped;
}
if(pc->flags & APC_EXTENSIBLE) {
switch(asn_random_between(0, 5)) {
case 0:
if(pc->lower_bound > 0) {
rnd_bits = pc->lower_bound - 1;
break;
}
/* Fall through */
case 1:
rnd_bits = pc->upper_bound + 1;
break;
case 2:
/* Keep rnd_bits from the table */
if(rnd_bits < max_length) {
break;
}
/* Fall through */
default:
rnd_bits = asn_random_between(pc->lower_bound,
suggested_upper_bound);
}
} else {
rnd_bits =
asn_random_between(pc->lower_bound, suggested_upper_bound);
}
} else {
rnd_bits = asn_random_between(0, max_length - 1);
}
} else if(rnd_bits >= max_length) {
rnd_bits = asn_random_between(0, max_length - 1);
}
rnd_len = (rnd_bits + 7) / 8;
buf = CALLOC(1, rnd_len + 1);
if(!buf) return result_failed;
bend = &buf[rnd_len];
for(b = buf; b < bend; b++) {
*(uint8_t *)b = asn_random_between(0, 255);
}
*b = 0; /* Zero-terminate just in case. */
if(*sptr) {
st = *sptr;
FREEMEM(st->buf);
} else {
st = (BIT_STRING_t *)(*sptr = CALLOC(1, specs->struct_size));
if(!st) {
FREEMEM(buf);
return result_failed;
}
}
st->buf = buf;
st->size = rnd_len;
st->bits_unused = (8 - (rnd_bits & 0x7)) & 0x7;
if(st->bits_unused) {
assert(st->size > 0);
st->buf[st->size-1] &= 0xff << st->bits_unused;
}
result_ok.length = st->size;
return result_ok;
}

Some files were not shown because too many files have changed in this diff Show more