gerrit-log
Threads by month
- ----- 2026 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
September 2026
- 1 participants
- 1894 discussions
[S] Change in onomondo-eim[master]: esipa_asn1_handler: Add TODOs to address missing checks
by dexter 02 Sep '26
by dexter 02 Sep '26
02 Sep '26
dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/onomondo-eim/+/43506?usp=email )
Change subject: esipa_asn1_handler: Add TODOs to address missing checks
......................................................................
esipa_asn1_handler: Add TODOs to address missing checks
The ASN.1 handler code lacks several checks that are required
by SGP.32. Profile downloads will work fine, but we won't catch
errors early.
Related: SYS#8100
Change-Id: I6174fba0760a0192d59db68a430b10ab7726bcb3
---
M src/esipa_asn1_handler.erl
1 file changed, 28 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/onomondo-eim refs/changes/06/43506/1
diff --git a/src/esipa_asn1_handler.erl b/src/esipa_asn1_handler.erl
index f1be50a..0fc72e7 100644
--- a/src/esipa_asn1_handler.erl
+++ b/src/esipa_asn1_handler.erl
@@ -21,6 +21,10 @@
% initiateAuthenticationRequest. However the field is only missing in case the IPA capability minimizeEsipaBytes is
% used. This is an optional feature that this eIM does not support, so we can expect euiccInfo1 to be always present.
+ % TODO: Popluate smdpAddress from Activation Code if missing: smdpAddress is declared as anan optional field in
+ % InitiateAuthenticationRequestEsipa. If the field is missing, we can retrieve it from the Activation Code that is
+ % stored in the download Order (see also SGP.32, section 3.2.3.2, step 8).
+
% setup ES9+ request message
Es9Req = {initiateAuthenticationRequest, EsipaReq},
@@ -31,16 +35,20 @@
EsipaResp =
case Es9Resp of
{initiateAuthenticationOk, InitAuthOk} ->
+ % TODO: Verify serverAddress in serverSigned1: In case we ad to extract the smdpAddress from the
+ % Activation Code we should make sure that smdpAddress and serverAddress are equal.
+ % TODO: Verify SM-DP+ OID. An Activation Code may contain an SM-DP+ OID. Make sure that this OID
+ % matches the OID from the serverCertificate (see also SGP.32, section 3.2.3.2, step 10).
TransactionId = maps:get(transactionId, InitAuthOk),
mnesia_db_work:bind(Pid, TransactionId),
% TODO: matchingId and ctxParams1 are not defined in the ES9+ InitiateAuthenticationResponse message.
% However in ESipa those fields are optional fields and either one of it should be populated in case an
% AC is used (which we do). This means we should populate those fields. The matchingId can be extracted
% from the AC, which we have in the Order. If the IPAd supports eimCtxParams1Generation then it should
- % be find if we would just add the matchingId field like so: maps:merge(InitAuthOk, #{matchingId =>
- % FIXME). Otherwise we would have to add a ctxParams1 field and populate it with the matchingId and the
- % deviceInfo. The deviceInfo can be retrieved via an eUICC data request.
- % (see GSMA SGP.32, section 3.1.2.3).
+ % be fine if we would just add the matchingId field like so: maps:merge(InitAuthOk, #{matchingId =>
+ % MatchingId}). Otherwise we would have to add a ctxParams1 field and populate it with the matchingId
+ % and the deviceInfo. The deviceInfo can be retrieved via an eUICC data request. (see also GSMA SGP.32,
+ % section 3.2.3.2, step 11).
InitAuthOkEsipa = #{
transactionId => maps:get(transactionId, InitAuthOk),
serverSigned1 => maps:get(serverSigned1, InitAuthOk),
@@ -102,6 +110,17 @@
fallbackAllowed => FallbackAllowed
}
),
+ % TODO: Verify profileMetaData in case the IPAd is not able to verify the profileMetaData: At the
+ % moment we assume that the IPAd is able to verify the profileMetaData, but there may be IPAd
+ % implementations which cannot verify the profileMetaData (eimProfileMetadataVerification). In those
+ % cases the eIM is responsible to verify the profileMetaData, which is not implemnted yet (see also
+ % SGP.32, section 3.2.3.2, step 15 and 19).
+ % TODO: Implement compatibility Check: At the moment it is the responsibility of the REST API user to
+ % ensure that eIM and IPAd are compatible. Currently the REST API user must request the IpaCapabilities
+ % via an eUICC Data Request and know for himself what capability combinations will work with this eIM.
+ % To simplify this we should automate this process by requesting and caching the IpaCapabilities once,
+ % so that we the info withing reach when we need it (similar to how we cache signPubKey, see also
+ % mnesia_db_euicc.hrl).
AuthenticateClientOkDPEsipa = AuthClntRespEs9#{
profileMetaData => StoreMetadataRequest
},
@@ -296,6 +315,11 @@
% an activationCode (option a) It still lacks download triggers via SM-DS (option b) and downloads from
% the default SM-DP+ (option c). See also GSMA SGP.32, section 3.2.3.2
ActivationCode = proplists:get_value(<<"activationCode">>, Download),
+ % TODO: Check the contents of ActivationCode. The eIM should check the provided Activation Code and stop
+ % the procedure in case the Activation Code is invalid. However, it should also be mentioned that The
+ % missing check only has a minor impact since an invalid Activation Code will be detected on the IPAd
+ % side, which will cause the procedure to stop as well. (see also SGP.32, section 3.2.3.2, step 1 and
+ % step 4).
{profileDownloadTriggerRequest, #{
profileDownloadData => {activationCode, ActivationCode},
eimTransactionId => EimTransactionId
--
To view, visit https://gerrit.osmocom.org/c/onomondo-eim/+/43506?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: onomondo-eim
Gerrit-Branch: master
Gerrit-Change-Id: I6174fba0760a0192d59db68a430b10ab7726bcb3
Gerrit-Change-Number: 43506
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
1
0
[XS] Change in onomondo-eim[master]: esipa_rest_utils: add spec reference to existing TODO
by dexter 02 Sep '26
by dexter 02 Sep '26
02 Sep '26
Attention is currently required from: dexter.
Hello Jenkins Builder, laforge,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/onomondo-eim/+/43450?usp=email
to look at the new patch set (#2).
The following approvals got outdated and were removed:
Verified+1 by Jenkins Builder
The change is no longer submittable: Verified is unsatisfied now.
Change subject: esipa_rest_utils: add spec reference to existing TODO
......................................................................
esipa_rest_utils: add spec reference to existing TODO
Related: SYS#8100
Change-Id: I33a1b1a03c67632b4a10a043928e0a265730b7e2
---
M src/esipa_rest_utils.erl
1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/onomondo-eim refs/changes/50/43450/2
--
To view, visit https://gerrit.osmocom.org/c/onomondo-eim/+/43450?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: onomondo-eim
Gerrit-Branch: master
Gerrit-Change-Id: I33a1b1a03c67632b4a10a043928e0a265730b7e2
Gerrit-Change-Number: 43450
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
1
0
[XS] Change in onomondo-eim[master]: esipa_asn_handler: add TODO about missing TLS / SNI support
by dexter 02 Sep '26
by dexter 02 Sep '26
02 Sep '26
Attention is currently required from: dexter, laforge.
Hello Jenkins Builder, laforge,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/onomondo-eim/+/43451?usp=email
to look at the new patch set (#2).
The following approvals got outdated and were removed:
Code-Review+2 by laforge, Verified+1 by Jenkins Builder
The change is no longer submittable: Code-Review and Verified are unsatisfied now.
Change subject: esipa_asn_handler: add TODO about missing TLS / SNI support
......................................................................
esipa_asn_handler: add TODO about missing TLS / SNI support
SGP.32 requires an eIM to support SNI, however since this eIM has
no multi tenant support at all, it may not benefit much from this
feature at the moment.
However, according to the cowboy documentation SNI is supported
and the effort to integrate it is manageable. Let's postpone this
until we add multi tenant support.
Related: SYS#8100
Change-Id: Iaebe29563259ae5fabeb9825839a03062d7fc24d
---
M src/onomondo_eim_app.erl
1 file changed, 3 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/onomondo-eim refs/changes/51/43451/2
--
To view, visit https://gerrit.osmocom.org/c/onomondo-eim/+/43451?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: onomondo-eim
Gerrit-Branch: master
Gerrit-Change-Id: Iaebe29563259ae5fabeb9825839a03062d7fc24d
Gerrit-Change-Number: 43451
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
1
0
[XS] Change in onomondo-eim[master]: esipa_asn_handler: add TODO about missing download options
by dexter 02 Sep '26
by dexter 02 Sep '26
02 Sep '26
Attention is currently required from: dexter.
Hello Jenkins Builder, laforge,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/onomondo-eim/+/43449?usp=email
to look at the new patch set (#2).
The following approvals got outdated and were removed:
Verified+1 by Jenkins Builder
The change is no longer submittable: Verified is unsatisfied now.
Change subject: esipa_asn_handler: add TODO about missing download options
......................................................................
esipa_asn_handler: add TODO about missing download options
SGP.32 also defines other download trigger options next to the
commonly used activationCode method. Let's add a related TODO
to the code.
Related: SYS#8100
Change-Id: I5e72416284027731627c264fa81c62a4a9a0d407
---
M src/esipa_asn1_handler.erl
1 file changed, 3 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/onomondo-eim refs/changes/49/43449/2
--
To view, visit https://gerrit.osmocom.org/c/onomondo-eim/+/43449?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: onomondo-eim
Gerrit-Branch: master
Gerrit-Change-Id: I5e72416284027731627c264fa81c62a4a9a0d407
Gerrit-Change-Number: 43449
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
1
0
[L] Change in onomondo-eim[master]: contrib: restructure REST API usage examples (tryme-scripts)
by dexter 02 Sep '26
by dexter 02 Sep '26
02 Sep '26
dexter has submitted this change. ( https://gerrit.osmocom.org/c/onomondo-eim/+/43142?usp=email )
Change subject: contrib: restructure REST API usage examples (tryme-scripts)
......................................................................
contrib: restructure REST API usage examples (tryme-scripts)
The so called tryme scripts are using a very clumsy method to set
the varying parameters (tryme.cfg). The files also mix with other
unrelated files in the contrib directory. There is also a lot of
distracting output displayed which complicates the usage of the
examples even further. This patch fixes those shortcomings.
- put everything related to the usage example into a dedicated
directory.
- renovate restop.py so that it produces more readable output.
- in the tryme_*.sh scripts, avoid output that is not needed.
- cleanup tryme.cfg so that it only contains one set of parameters,
add some helpful comments.
- add functionality to pass the the parameters either via
commandline options or via tryme.cfg, add a parameter to point
to an alternative .cfg file, so that users can use multiple
different configurations.
- update documentation
- cleanup other minor inconsistencies
Related: SYS#8100
Change-Id: I4e42ce85c84b47d3561011083da4a1e54958fd8e
---
A contrib/rest_api_usage_example/getopts.sh
A contrib/rest_api_usage_example/lookup.sh
A contrib/rest_api_usage_example/restop.py
A contrib/rest_api_usage_example/tryme.cfg
R contrib/rest_api_usage_example/tryme_addEim.sh
R contrib/rest_api_usage_example/tryme_configureImmediateEnable.sh
R contrib/rest_api_usage_example/tryme_delete.sh
R contrib/rest_api_usage_example/tryme_deleteEim.sh
R contrib/rest_api_usage_example/tryme_disable.sh
R contrib/rest_api_usage_example/tryme_download.sh
R contrib/rest_api_usage_example/tryme_enable.sh
R contrib/rest_api_usage_example/tryme_euiccDataRequest.sh
R contrib/rest_api_usage_example/tryme_euicc_get_state.sh
R contrib/rest_api_usage_example/tryme_euicc_set_state.sh
R contrib/rest_api_usage_example/tryme_getRAT.sh
R contrib/rest_api_usage_example/tryme_listEim.sh
R contrib/rest_api_usage_example/tryme_listProfileInfo.sh
R contrib/rest_api_usage_example/tryme_updateEim.sh
D contrib/restop.py
D contrib/tryme.cfg
D contrib/tryme_lookup.sh
M doc/examples.md
22 files changed, 252 insertions(+), 239 deletions(-)
Approvals:
laforge: Looks good to me, but someone else must approve
Jenkins Builder: Verified
dexter: Looks good to me, approved
jolly: Looks good to me, but someone else must approve
diff --git a/contrib/rest_api_usage_example/getopts.sh b/contrib/rest_api_usage_example/getopts.sh
new file mode 100755
index 0000000..b97fb72
--- /dev/null
+++ b/contrib/rest_api_usage_example/getopts.sh
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+EID=""
+AC="(none)"
+ICCID="(none)"
+CFG_FILE="tryme.cfg"
+
+while getopts "c:e:a:i:h" opt; do
+ case $opt in
+ c)
+ CFG_FILE=$OPTARG
+ ;;
+ e)
+ EID=$OPTARG
+ CFG_FILE=""
+ ;;
+ a)
+ AC=$OPTARG
+ CFG_FILE=""
+ ;;
+ i)
+ ICCID=$OPTARG
+ CFG_FILE=""
+ ;;
+ h)
+ echo "Usage: $0 -c path/to/my/tryme.cfg"
+ echo " $0 -e EID -a AC -i ICCID"
+ exit 0
+ ;;
+ \?)
+ echo "invalid option: -$OPTARG"
+ ;;
+ :)
+ echo "option -$OPTARG requires an argument."
+ ;;
+ esac
+done
+
+if [ -n "$CFG_FILE" ]; then
+ echo "sourcing parameters from config file: $CFG_FILE"
+ source $CFG_FILE
+fi
+
+if [ -z "$EID" ]; then
+ echo "error: no EID (mandatory) specified!"
+ exit 1
+fi
+
+echo "parameters:"
+echo "EID: $EID"
+echo "ICCID: $ICCID"
+echo "AC: $AC"
diff --git a/contrib/rest_api_usage_example/lookup.sh b/contrib/rest_api_usage_example/lookup.sh
new file mode 100755
index 0000000..988f5a3
--- /dev/null
+++ b/contrib/rest_api_usage_example/lookup.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+if [[ $# == 2 ]]; then
+ sleep 5
+ while true; do
+ ./restop.py -l -f $1 -r $2 > /dev/null
+ sleep 5
+ done
+else
+ echo "Usage: $0 facility resource-id"
+fi
+
+
+
diff --git a/contrib/rest_api_usage_example/restop.py b/contrib/rest_api_usage_example/restop.py
new file mode 100755
index 0000000..cf31e4d
--- /dev/null
+++ b/contrib/rest_api_usage_example/restop.py
@@ -0,0 +1,108 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2025 Onomondo ApS & sysmocom - s.f.m.c. GmbH. All rights reserved.
+# SPDX-License-Identifier: AGPL-3.0-only
+# Author: Philipp Maier <pmaier(a)sysmocom.de> / sysmocom - s.f.m.c. GmbH
+
+import sys
+import argparse
+import json
+import requests
+import pprint
+import textwrap
+
+DOWNLOAD_DEFAULT='{ "eidValue" : "89882119900000000000000000000005", "order" : {"activationCode" : "1$testsmdpplus1.example.com$OPxLD-UVRuC-jysPI-YkOwT"}}'
+PSMO_DEFAULT='{ "eidValue" : "89882119900000000000000000000005", "order" : [{"psmo" : "enable", "iccid" : "98001032547698103285", "rollback" : false }]}'
+
+req_headers = {
+ 'Content-Type': 'application/json',
+ 'X-Admin-Protocol': 'onomondo/eim/v1.0.0',
+}
+
+def h2b(s) -> bytearray:
+ """convert from a string of hex nibbles to a sequence of bytes"""
+ return bytes.fromhex(s)
+
+def rest_create(host, facility, Json):
+ r = requests.post("http://" + str(host) + "/" + str(facility) + "/create", json=Json, headers=req_headers)
+ return str(r.url)
+
+def rest_lookup(host, facility, ResourceId):
+ r = requests.get("http://" + str(host) + "/" + str(facility) + "/lookup/" + str(ResourceId), headers=req_headers)
+ return r.json()
+
+def rest_delete(host, facility, ResourceId):
+ r = requests.get("http://" + str(host) + "/" + str(facility) + "/delete/" + str(ResourceId), headers=req_headers)
+ return r.json()
+
+def rest_list(host, facility):
+ r = requests.get("http://" + str(host) + "/" + str(facility) + "/list/", headers=req_headers)
+ return r.json()
+
+def main(argv):
+ parser = argparse.ArgumentParser(prog='restop', description='utility to operate on the REST API of onomondo_eim')
+ parser.add_argument("-s", "--host", default="127.0.0.1:8080")
+ parser.add_argument("-f", "--facility", help="REST API facility", default="download")
+ parser.add_argument("-c", "--create", help="creata a new REST resource", action='store_true')
+ parser.add_argument("-l", "--lookup", help="lookup an existing REST resource", action='store_true')
+ parser.add_argument("-d", "--delete", help="delete a no longer needed REST resource", action='store_true')
+ parser.add_argument("-t", "--list", help="list all currently existing REST resources", action='store_true')
+ parser.add_argument("-r", "--resource-id", help="REST resource identifier")
+ parser.add_argument("-j", "--json", help="JSON input")
+ parser.add_argument("-e", "--erlang-debuginfo", help="decode and display erlang debug information", action='store_true')
+
+ args = parser.parse_args()
+ pp = pprint.PrettyPrinter()
+
+ if args.create:
+ print("create on: " + str(args.host), file=sys.stderr)
+ print(" facility: " + str(args.facility), file=sys.stderr)
+ if args.json:
+ args_json = json.loads(str(args.json))
+ else:
+ if args.facility == "download":
+ args_json = json.loads(DOWNLOAD_DEFAULT)
+ elif args.facility == "psmo":
+ args_json = json.loads(PSMO_DEFAULT)
+ args_json_pretty = pp.pformat(args_json)
+ print(" json: " + textwrap.indent(args_json_pretty, " " * 7)[7:], file=sys.stderr)
+ resource_url = rest_create(args.host, args.facility, args_json)
+ print(" resourceId: " + resource_url.rsplit('/')[-1], file=sys.stderr)
+ print(resource_url)
+
+ elif args.lookup:
+ print("lookup on: " + str(args.host), file=sys.stderr)
+ print(" facility: " + str(args.facility), file=sys.stderr)
+ print(" resourceId: " + str(args.resource_id), file=sys.stderr)
+ result_json = rest_lookup(args.host, args.facility, args.resource_id)
+ result_json_pretty = pp.pformat(result_json)
+ print(" json: " + textwrap.indent(result_json_pretty, " " * 7)[7:], file=sys.stderr)
+ if args.erlang_debuginfo and 'debuginfo' in result_json:
+ import erlang
+ debuginfo_hexstr=result_json['debuginfo']
+ debuginfo_bytes=h2b(debuginfo_hexstr)
+ debuginfo_term=erlang.binary_to_term(debuginfo_bytes)
+ debuginfo_pretty = pp.pformat(debuginfo_term)
+ print(" debuginfo: " + textwrap.indent(debuginfo_pretty, " " * 12)[12:], file=sys.stderr)
+ print(json.dumps(result_json))
+
+ elif args.delete:
+ print("delete on: " + str(args.host), file=sys.stderr)
+ print(" facility: " + str(args.facility), file=sys.stderr)
+ print(" resourceId: " + str(args.resource_id), file=sys.stderr)
+ result_json = rest_delete(args.host, args.facility, args.resource_id)
+ result_json_pretty = pp.pformat(result_json)
+ print(" json: " + textwrap.indent(result_json_pretty, " " * 7)[7:], file=sys.stderr)
+ print(json.dumps(result_json))
+
+ elif args.list:
+ print("list on: " + str(args.host), file=sys.stderr)
+ print(" facility: " + str(args.facility), file=sys.stderr)
+ result_json = rest_list(args.host, args.facility)
+ result_json_pretty = pp.pformat(result_json)
+ print(" json: " + textwrap.indent(result_json_pretty, " " * 7)[7:], file=sys.stderr)
+ print(json.dumps(result_json))
+
+if __name__ == "__main__":
+ main(sys.argv[1:])
+
diff --git a/contrib/rest_api_usage_example/tryme.cfg b/contrib/rest_api_usage_example/tryme.cfg
new file mode 100644
index 0000000..0506a19
--- /dev/null
+++ b/contrib/rest_api_usage_example/tryme.cfg
@@ -0,0 +1,14 @@
+# Set this value to the EID of the eUICC you want to target. The EID is the
+# primary identifier on which the eIM identifies the requests from the IoT
+# device (IPAd).
+EID='89049044900000000000000000102452'
+
+# Change this value to the activation code (AC) of your profile download
+AC='1$smdpp.test.rsp.sysmocom.de$TS48V1-A-UNIQUE'
+
+# Set this value to the ICCID of your profile. The ICCID format used here is
+# the binary form as it can be found in EF.ICCID. (In case you do not know the
+# ICCID (yet), you may leave this field empty. The ICCID is returned by the eIM
+# (tryme_download.sh) when the profile download is complete. In case the profile
+# is already installed, you may request a list (tryme_listProfileInfo.sh).
+ICCID='989444999999990920F3' #8949449999999990023
diff --git a/contrib/tryme_addEim.sh b/contrib/rest_api_usage_example/tryme_addEim.sh
similarity index 90%
rename from contrib/tryme_addEim.sh
rename to contrib/rest_api_usage_example/tryme_addEim.sh
index a504010..70a246b 100755
--- a/contrib/tryme_addEim.sh
+++ b/contrib/rest_api_usage_example/tryme_addEim.sh
@@ -1,11 +1,10 @@
#!/bin/bash
-. ./tryme.cfg
+. ./getopts.sh
JSON='{ "eidValue" : "'$EID'", "order" : { "eco" : [ { "addEim" : { "eimConfigurationData" : "3079800465494D32810E3132372E302E302E313A383030308301018401FFA55BA059301306072A8648CE3D020106082A8648CE3D03010703420004FE584A6F450459574AECA195D0299737F74C89BA2D36DF9286EC25D973037A0FBA70D14DF3E1F7D0A305E57B95B731C4DE218D2D7F9F22113ED5D18C2E3DDF1C" } } ] } }'
RC=`./restop.py -c -f eco -j "$JSON"`
-echo $RC
echo "---------------------------------------8<---------------------------------------"
RESOURCE_ID=`echo $RC | cut -d '/' -f 6`
echo "ResourceId =" $RESOURCE_ID
-./tryme_lookup.sh eco $RESOURCE_ID
+./lookup.sh eco $RESOURCE_ID
diff --git a/contrib/tryme_configureImmediateEnable.sh b/contrib/rest_api_usage_example/tryme_configureImmediateEnable.sh
similarity index 86%
rename from contrib/tryme_configureImmediateEnable.sh
rename to contrib/rest_api_usage_example/tryme_configureImmediateEnable.sh
index 9cf4fde..9538beb 100755
--- a/contrib/tryme_configureImmediateEnable.sh
+++ b/contrib/rest_api_usage_example/tryme_configureImmediateEnable.sh
@@ -1,11 +1,10 @@
#!/bin/bash
-. ./tryme.cfg
+. ./getopts.sh
JSON='{ "eidValue" : "'$EID'", "order" : { "psmo": [ { "configureImmediateEnable" : { "immediateEnableFlag" : true, "defaultSmdpAddress" : "testsmdpplus1.example.com" } } ] } }'
RC=`./restop.py -c -f psmo -j "$JSON"`
-echo $RC
echo "---------------------------------------8<---------------------------------------"
RESOURCE_ID=`echo $RC | cut -d '/' -f 6`
echo "ResourceId =" $RESOURCE_ID
-./tryme_lookup.sh psmo $RESOURCE_ID
+./lookup.sh psmo $RESOURCE_ID
diff --git a/contrib/tryme_delete.sh b/contrib/rest_api_usage_example/tryme_delete.sh
similarity index 84%
rename from contrib/tryme_delete.sh
rename to contrib/rest_api_usage_example/tryme_delete.sh
index bf1a9b2..bedb3db 100755
--- a/contrib/tryme_delete.sh
+++ b/contrib/rest_api_usage_example/tryme_delete.sh
@@ -1,12 +1,11 @@
#!/bin/bash
-. ./tryme.cfg
+. ./getopts.sh
JSON='{ "eidValue" : "'$EID'", "order" : { "psmo" : [ { "delete" : { "iccid" : "'$ICCID'" } } ] } }'
RC=`./restop.py -c -f psmo -j "$JSON"`
-echo $RC
echo "---------------------------------------8<---------------------------------------"
RESOURCE_ID=`echo $RC | cut -d '/' -f 6`
echo "ResourceId =" $RESOURCE_ID
-./tryme_lookup.sh psmo $RESOURCE_ID
+./lookup.sh psmo $RESOURCE_ID
diff --git a/contrib/tryme_deleteEim.sh b/contrib/rest_api_usage_example/tryme_deleteEim.sh
similarity index 84%
rename from contrib/tryme_deleteEim.sh
rename to contrib/rest_api_usage_example/tryme_deleteEim.sh
index 8faf657..5177e6e 100755
--- a/contrib/tryme_deleteEim.sh
+++ b/contrib/rest_api_usage_example/tryme_deleteEim.sh
@@ -1,11 +1,11 @@
#!/bin/bash
-. ./tryme.cfg
+. ./getopts.sh
+
EIM_ID="eIM2"
JSON='{ "eidValue" : "'$EID'", "order" : { "eco" : [ { "deleteEim" : { "eimId" : "'$EIM_ID'" } } ] } }'
RC=`./restop.py -c -f eco -j "$JSON"`
-echo $RC
echo "---------------------------------------8<---------------------------------------"
RESOURCE_ID=`echo $RC | cut -d '/' -f 6`
echo "ResourceId =" $RESOURCE_ID
-./tryme_lookup.sh eco $RESOURCE_ID
+./lookup.sh eco $RESOURCE_ID
diff --git a/contrib/tryme_disable.sh b/contrib/rest_api_usage_example/tryme_disable.sh
similarity index 84%
rename from contrib/tryme_disable.sh
rename to contrib/rest_api_usage_example/tryme_disable.sh
index a45af94..cc55a41 100755
--- a/contrib/tryme_disable.sh
+++ b/contrib/rest_api_usage_example/tryme_disable.sh
@@ -1,11 +1,10 @@
#!/bin/bash
-. ./tryme.cfg
+. ./getopts.sh
JSON='{ "eidValue" : "'$EID'", "order" : { "psmo" : [ { "disable" : { "iccid" : "'$ICCID'" } } ] } }'
RC=`./restop.py -c -f psmo -j "$JSON"`
-echo $RC
echo "---------------------------------------8<---------------------------------------"
RESOURCE_ID=`echo $RC | cut -d '/' -f 6`
echo "ResourceId =" $RESOURCE_ID
-./tryme_lookup.sh psmo $RESOURCE_ID
+./lookup.sh psmo $RESOURCE_ID
diff --git a/contrib/tryme_download.sh b/contrib/rest_api_usage_example/tryme_download.sh
similarity index 82%
rename from contrib/tryme_download.sh
rename to contrib/rest_api_usage_example/tryme_download.sh
index 10725a2..56f9096 100755
--- a/contrib/tryme_download.sh
+++ b/contrib/rest_api_usage_example/tryme_download.sh
@@ -1,11 +1,10 @@
#!/bin/bash
-. ./tryme.cfg
+. ./getopts.sh
JSON='{ "eidValue" : "'$EID'", "order" : { "download" : {"activationCode" : "'$AC'" } } }'
RC=`./restop.py -c -f download -j "$JSON"`
-echo $RC
echo "---------------------------------------8<---------------------------------------"
RESOURCE_ID=`echo $RC | cut -d '/' -f 6`
echo "ResourceId =" $RESOURCE_ID
-./tryme_lookup.sh download $RESOURCE_ID
+./lookup.sh download $RESOURCE_ID
diff --git a/contrib/tryme_enable.sh b/contrib/rest_api_usage_example/tryme_enable.sh
similarity index 84%
rename from contrib/tryme_enable.sh
rename to contrib/rest_api_usage_example/tryme_enable.sh
index ac08706..93f52c6 100755
--- a/contrib/tryme_enable.sh
+++ b/contrib/rest_api_usage_example/tryme_enable.sh
@@ -1,11 +1,10 @@
#!/bin/bash
-. ./tryme.cfg
+. ./getopts.sh
JSON='{ "eidValue" : "'$EID'", "order" : { "psmo": [ { "enable" : { "iccid" : "'$ICCID'", "rollback" : false } } ] } }'
RC=`./restop.py -c -f psmo -j "$JSON"`
-echo $RC
echo "---------------------------------------8<---------------------------------------"
RESOURCE_ID=`echo $RC | cut -d '/' -f 6`
echo "ResourceId =" $RESOURCE_ID
-./tryme_lookup.sh psmo $RESOURCE_ID
+./lookup.sh psmo $RESOURCE_ID
diff --git a/contrib/tryme_euiccDataRequest.sh b/contrib/rest_api_usage_example/tryme_euiccDataRequest.sh
similarity index 74%
rename from contrib/tryme_euiccDataRequest.sh
rename to contrib/rest_api_usage_example/tryme_euiccDataRequest.sh
index ba70a69..28aa282 100755
--- a/contrib/tryme_euiccDataRequest.sh
+++ b/contrib/rest_api_usage_example/tryme_euiccDataRequest.sh
@@ -1,10 +1,10 @@
#!/bin/bash
-. ./tryme.cfg
-JSON='{ "eidValue" : "'$EID'", "order" : { "edr" : { "tagList" : "81BF20BF228384A5A6A8A9A0" } } }'
+. ./getopts.sh
+
+JSON='{ "eidValue" : "'$EID'", "order" : { "edr" : { "tagList" : "81BF20BF228384A5A6A8A9A0A2" } } }'
RC=`./restop.py -c -f edr -j "$JSON"`
-echo $RC
echo "---------------------------------------8<---------------------------------------"
RESOURCE_ID=`echo $RC | cut -d '/' -f 6`
echo "ResourceId =" $RESOURCE_ID
-./tryme_lookup.sh edr $RESOURCE_ID
+./lookup.sh edr $RESOURCE_ID
diff --git a/contrib/tryme_euicc_get_state.sh b/contrib/rest_api_usage_example/tryme_euicc_get_state.sh
similarity index 87%
rename from contrib/tryme_euicc_get_state.sh
rename to contrib/rest_api_usage_example/tryme_euicc_get_state.sh
index dc96cf0..f41ecc3 100755
--- a/contrib/tryme_euicc_get_state.sh
+++ b/contrib/rest_api_usage_example/tryme_euicc_get_state.sh
@@ -1,14 +1,13 @@
#!/bin/bash
-. ./tryme.cfg
+. ./getopts.sh
# States we want to retrieve with this request.
STATES='"counterValue", "consumerEuicc", "signAlgo", "signPubKey", "stateChangeCauseList"'
JSON='{ "eidValue" : "'$EID'", "order" : { "euicc" : { "get" : [ '$STATES' ] } } }'
RC=`./restop.py -c -f euicc -j "$JSON"`
-echo $RC
echo "---------------------------------------8<---------------------------------------"
RESOURCE_ID=`echo $RC | cut -d '/' -f 6`
echo "ResourceId =" $RESOURCE_ID
-./tryme_lookup.sh euicc $RESOURCE_ID
+./lookup.sh euicc $RESOURCE_ID
diff --git a/contrib/tryme_euicc_set_state.sh b/contrib/rest_api_usage_example/tryme_euicc_set_state.sh
similarity index 92%
rename from contrib/tryme_euicc_set_state.sh
rename to contrib/rest_api_usage_example/tryme_euicc_set_state.sh
index 04d8c51..5d30ea1 100755
--- a/contrib/tryme_euicc_set_state.sh
+++ b/contrib/rest_api_usage_example/tryme_euicc_set_state.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-. ./tryme.cfg
+. ./getopts.sh
# States we want to set with this request (list does not have to be complete, states not listest here are left
# unchanged.
@@ -11,9 +11,8 @@
JSON='{ "eidValue" : "'$EID'", "order" : { "euicc" : { "set" : '$STATES' } } }'
RC=`./restop.py -c -f euicc -j "$JSON"`
-echo $RC
echo "---------------------------------------8<---------------------------------------"
RESOURCE_ID=`echo $RC | cut -d '/' -f 6`
echo "ResourceId =" $RESOURCE_ID
-./tryme_lookup.sh euicc $RESOURCE_ID
+./lookup.sh euicc $RESOURCE_ID
diff --git a/contrib/tryme_getRAT.sh b/contrib/rest_api_usage_example/tryme_getRAT.sh
similarity index 83%
rename from contrib/tryme_getRAT.sh
rename to contrib/rest_api_usage_example/tryme_getRAT.sh
index fa61d51..4c3dcdf 100755
--- a/contrib/tryme_getRAT.sh
+++ b/contrib/rest_api_usage_example/tryme_getRAT.sh
@@ -1,11 +1,10 @@
#!/bin/bash
-. ./tryme.cfg
+. ./getopts.sh
JSON='{ "eidValue" : "'$EID'", "order" : { "psmo" : [ { "getRAT" : { } } ] } }'
RC=`./restop.py -c -f psmo -j "$JSON"`
-echo $RC
echo "---------------------------------------8<---------------------------------------"
RESOURCE_ID=`echo $RC | cut -d '/' -f 6`
echo "ResourceId =" $RESOURCE_ID
-./tryme_lookup.sh psmo $RESOURCE_ID
+./lookup.sh psmo $RESOURCE_ID
diff --git a/contrib/tryme_listEim.sh b/contrib/rest_api_usage_example/tryme_listEim.sh
similarity index 83%
rename from contrib/tryme_listEim.sh
rename to contrib/rest_api_usage_example/tryme_listEim.sh
index 0d86787..25ece68 100755
--- a/contrib/tryme_listEim.sh
+++ b/contrib/rest_api_usage_example/tryme_listEim.sh
@@ -1,11 +1,10 @@
#!/bin/bash
-. ./tryme.cfg
+. ./getopts.sh
JSON='{ "eidValue" : "'$EID'", "order" : { "eco" : [ { "listEim" : { } } ] } }'
RC=`./restop.py -c -f eco -j "$JSON"`
-echo $RC
echo "---------------------------------------8<---------------------------------------"
RESOURCE_ID=`echo $RC | cut -d '/' -f 6`
echo "ResourceId =" $RESOURCE_ID
-./tryme_lookup.sh eco $RESOURCE_ID
+./lookup.sh eco $RESOURCE_ID
diff --git a/contrib/tryme_listProfileInfo.sh b/contrib/rest_api_usage_example/tryme_listProfileInfo.sh
similarity index 83%
rename from contrib/tryme_listProfileInfo.sh
rename to contrib/rest_api_usage_example/tryme_listProfileInfo.sh
index 7d64b98..a555308 100755
--- a/contrib/tryme_listProfileInfo.sh
+++ b/contrib/rest_api_usage_example/tryme_listProfileInfo.sh
@@ -1,11 +1,10 @@
#!/bin/bash
-. ./tryme.cfg
+. ./getopts.sh
JSON='{ "eidValue" : "'$EID'", "order" : { "psmo" : [ { "listProfileInfo" : { } } ] } }'
RC=`./restop.py -c -f psmo -j "$JSON"`
-echo $RC
echo "---------------------------------------8<---------------------------------------"
RESOURCE_ID=`echo $RC | cut -d '/' -f 6`
echo "ResourceId =" $RESOURCE_ID
-./tryme_lookup.sh psmo $RESOURCE_ID
+./lookup.sh psmo $RESOURCE_ID
diff --git a/contrib/tryme_updateEim.sh b/contrib/rest_api_usage_example/tryme_updateEim.sh
similarity index 86%
rename from contrib/tryme_updateEim.sh
rename to contrib/rest_api_usage_example/tryme_updateEim.sh
index 5d08398..c228f1d 100755
--- a/contrib/tryme_updateEim.sh
+++ b/contrib/rest_api_usage_example/tryme_updateEim.sh
@@ -1,11 +1,10 @@
#!/bin/bash
-. ./tryme.cfg
+. ./getopts.sh
JSON='{ "eidValue" : "'$EID'", "order" : { "eco" : [ { "updateEim" : { "eimConfigurationData" : "3017800465494D32810F3132372E302E302E34323A39303030" } } ] } }'
RC=`./restop.py -c -f eco -j "$JSON"`
-echo $RC
echo "---------------------------------------8<---------------------------------------"
RESOURCE_ID=`echo $RC | cut -d '/' -f 6`
echo "ResourceId =" $RESOURCE_ID
-./tryme_lookup.sh eco $RESOURCE_ID
+./lookup.sh eco $RESOURCE_ID
diff --git a/contrib/restop.py b/contrib/restop.py
deleted file mode 100755
index a12ccd4..0000000
--- a/contrib/restop.py
+++ /dev/null
@@ -1,95 +0,0 @@
-#!/usr/bin/env python3
-#
-# Copyright (c) 2025 Onomondo ApS & sysmocom - s.f.m.c. GmbH. All rights reserved.
-# SPDX-License-Identifier: AGPL-3.0-only
-# Author: Philipp Maier <pmaier(a)sysmocom.de> / sysmocom - s.f.m.c. GmbH
-
-import sys
-import argparse
-import json
-import requests
-import erlang
-import pprint
-
-DOWNLOAD_DEFAULT='{ "eidValue" : "89882119900000000000000000000005", "order" : {"activationCode" : "1$testsmdpplus1.example.com$OPxLD-UVRuC-jysPI-YkOwT"}}'
-PSMO_DEFAULT='{ "eidValue" : "89882119900000000000000000000005", "order" : [{"psmo" : "enable", "iccid" : "98001032547698103285", "rollback" : false }]}'
-
-req_headers = {
- 'Content-Type': 'application/json',
- 'X-Admin-Protocol': 'onomondo/eim/v1.0.0',
-}
-
-def h2b(s) -> bytearray:
- """convert from a string of hex nibbles to a sequence of bytes"""
- return bytes.fromhex(s)
-
-def rest_create(host, facility, Json):
- r = requests.post("http://" + str(host) + "/" + str(facility) + "/create", json=Json, headers=req_headers)
- return str(r.url)
-
-def rest_lookup(host, facility, ResourceId):
- r = requests.get("http://" + str(host) + "/" + str(facility) + "/lookup/" + str(ResourceId), headers=req_headers)
- return r.json()
-
-def rest_delete(host, facility, ResourceId):
- r = requests.get("http://" + str(host) + "/" + str(facility) + "/delete/" + str(ResourceId), headers=req_headers)
- return r.json()
-
-def rest_list(host, facility):
- r = requests.get("http://" + str(host) + "/" + str(facility) + "/list/", headers=req_headers)
- return r.json()
-
-def main(argv):
- parser = argparse.ArgumentParser(prog='restop', description='utility to operate on the REST API of onomondo_eim')
- parser.add_argument("-s", "--host", default="127.0.0.1:8080")
- parser.add_argument("-f", "--facility", default="download")
- parser.add_argument("-c", "--create", action='store_true', default=False)
- parser.add_argument("-l", "--lookup", action='store_true', default=False)
- parser.add_argument("-d", "--delete", action='store_true', default=False)
- parser.add_argument("-t", "--list", action='store_true', default=False)
- parser.add_argument("-r", "--resource-id")
- parser.add_argument("-j", "--json")
-
- args = parser.parse_args()
-
- if args.create:
- print("create on: " + str(args.host), file=sys.stderr)
- print(" facility: " + str(args.facility), file=sys.stderr)
- if args.json:
- args_json = str(args.json)
- else:
- if args.facility == "download":
- args_json = DOWNLOAD_DEFAULT
- elif args.facility == "psmo":
- args_json = PSMO_DEFAULT
- print(" json: " + args_json, file=sys.stderr)
- print("result:", file=sys.stderr)
- print(rest_create(args.host, args.facility, json.loads(args_json)))
- elif args.lookup:
- print("lookup on: " + str(args.host), file=sys.stderr)
- print(" facility: " + str(args.facility), file=sys.stderr)
- print(" resourceId: " + str(args.resource_id), file=sys.stderr)
- result = rest_lookup(args.host, args.facility, args.resource_id)
- print(json.dumps(result))
- if 'debuginfo' in result:
- debuginfo_hexstr=result['debuginfo']
- debuginfo_bytes=h2b(debuginfo_hexstr)
- debuginfo_term=erlang.binary_to_term(debuginfo_bytes)
- pp = pprint.PrettyPrinter(depth=4)
- debuginfo_pretty = pp.pformat(debuginfo_term)
- print("decoded debuginfo: " + str(debuginfo_pretty), file=sys.stderr)
- elif args.delete:
- print("delete on: " + str(args.host), file=sys.stderr)
- print(" facility: " + str(args.facility), file=sys.stderr)
- print(" resourceId: " + str(args.resource_id), file=sys.stderr)
- print("result:", file=sys.stderr)
- print(json.dumps(rest_delete(args.host, args.facility, args.resource_id)))
- elif args.list:
- print("list on: " + str(args.host), file=sys.stderr)
- print(" facility: " + str(args.facility), file=sys.stderr)
- print("result:", file=sys.stderr)
- print(json.dumps(rest_list(args.host, args.facility)), file=sys.stderr)
-
-if __name__ == "__main__":
- main(sys.argv[1:])
-
diff --git a/contrib/tryme.cfg b/contrib/tryme.cfg
deleted file mode 100644
index 674da53..0000000
--- a/contrib/tryme.cfg
+++ /dev/null
@@ -1,63 +0,0 @@
-#EID='89882119900000000000000000000005' #NIST+BRP Test eUICC (Consumer)
-#EID='89044045118427484800000000011628' #NIST+BRP Test eUICC (IoT)
-#EID='89044045116727494800000004479172' #SLM17 ECu10.07 GSMA sample eUICC
-#EID='89086030202200000022000027485428' #eSIM me eUICC (Consumer)
-#EID='89049032123451234512345678901235' #Comprion Test eUICC (Consumer)
-EID='89034011022310000000000006803372' #Consumer eUICC for testing/demo
-
-case $1 in
- "A")
- #GSMA TS.48 V1 A
- AC='1$smdpp.test.rsp.sysmocom.de$TS48V1-A-UNIQUE'
- ICCID='989444999999990920F3' #8949449999999990023
- ;;
-
- "B")
- #GSMA TS.48 V1 B
- AC='1$smdpp.test.rsp.sysmocom.de$TS48V1-B-UNIQUE'
- ICCID='989444999999990930F1' #8949449999999990031
- ;;
- "C")
- #A test profile from a commercial operator (use GSMA eUICC)
- AC='1$rsp.truphone.com$QR-G-5C-1LS-1W1Z9P7'
- ICCID='984474680000230631F1' #changes after each download
- ;;
- "D")
- #TS48V1-B-UNIQUE-nojavacard-nocsim on self hosted SMDP+ instance
- #Osmo-smdpplus will verify the server address, you can put the SMPD+ hostname
- #(testsmdpplus1.example.com) into /etc/hosts: "127.0.0.1 testsmdpplus1.example.com"
- AC='1$testsmdpplus1.example.com$TS48V1-B-UNIQUE-nojavacard-nocsim'
- ICCID='989444999999990930F1' #8949449999999990031
- ;;
- "E")
- #A test profile that is installed on a test eUICC at some other location
- AC='1$rsp.example.com$UNKNOWN' #dummy value, unknown
- ICCID='98543700000012181938' #89457300000021819183
- ;;
- "X")
- #A way to sumbint any EID, ICCID and AC directly without putting it here.
- EID=$2
- ICCID=$3
- AC=$4
- ;;
- *)
- echo "EID=$EID"
- echo "Please select a profile:"
- echo "A: GSMA TS.48 V1 A"
- echo "B: GSMA TS.48 V1 B"
- echo "C: Truephone (commercial, GSMA)"
- echo "D: TS48V1-B-UNIQUE-nojavacard-nocsim (for debugging)"
- echo "E: Testprofile on another test eUICC (for testing/demo)"
- echo "X: Use any EID, ICCID or AC directly (tryme_*.sh EID [ICCID] [AC])"
- echo ""
- echo "A few examples:"
- echo "./tryme_download.sh X 89086030202200000022000027485428 NOT_NEEDED '1\$rsp.truphone.com\$QR-G-5C-1LS-1W1Z9P7'"
- echo "./tryme_enable.sh X 89086030202200000022000027485428 984474680000730600F7"
- echo "./tryme_listProfileInfo.sh X 89086030202200000022000027485428"
- echo "./tryme_download.sh E"
- echo "./tryme_enable.sh E"
- echo "./tryme_listProfileInfo.sh E"
- echo ""
- exit
- ;;
-esac
diff --git a/contrib/tryme_lookup.sh b/contrib/tryme_lookup.sh
deleted file mode 100755
index df8e129..0000000
--- a/contrib/tryme_lookup.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/bash
-
-if [[ $# == 2 ]]; then
- sleep 5
- while true; do
- ./restop.py -l -f $1 -r $2
- sleep 5
- done
-else
- echo "Usage: $0 facility resource-id"
-fi
-
-
-
diff --git a/doc/examples.md b/doc/examples.md
index 9f3726a..ab7f510 100644
--- a/doc/examples.md
+++ b/doc/examples.md
@@ -2,8 +2,8 @@
------------------
The REST API is complex interface that is difficult to operate out of the box without any prior familiarization. To
-give a system integrator a good starting point, the contrib directory contains "tryme-scripts" that serve as examples
-and an easy way try out the REST API.
+give a system integrator a good starting point, the contrib/rest_api_usage_example directory contains "tryme-scripts"
+that serve as examples and an easy way try out the REST API.
### Scripts
@@ -14,6 +14,17 @@
It should be noted that the tryme_*.sh scripts are really just simple examples that were created to simplify testing
during development.
+#### tryme.cfg
+
+This is just a simple shellscript that sets some initial variables. Some sample values are already present. It is
+recommended to edit tryme.cfg and to replace the sample values with some useful values. This is in particular the
+$EID variable at the top of the file.
+
+The file also defines a sample profiles along with a matching activation code (`$AC`) and ICCID (`$ICCID`). The ICCID
+is usually not known in advance. It becomes known after the eUICC has decrypted and installed the profile package. It
+should also be noted that the ICCID parameter is always issued in its raw format (digits swapped, padded with 'F' at
+the end).
+
#### restop.py
The python-script "restop.py" is called by the tryme "tryme_*.sh" scripts. This script can be used as a stand-alone
@@ -22,19 +33,19 @@
user must keep track of the REST resources he created, monitor them, check for errors, delete REST resources, resubmit
REST resources in case an `order` has failed, etc.
-#### tryme.cfg
+#### lookup.sh
-This is just a simple shellscript that sets some initial variables. Some sample values are already present. It is
-recommended to edit tryme.cfg and to replace the sample values with some useful values. This is in particular the
-$EID variable at the top of the file.
+This shellscript serves as a helper for the "tryme_*.sh" scripts. It is uses "restop.py" to query and display the
+status of the current REST resource in regular intervals.
-The file also defines some sample profiles along with their activation codes (`$AC`) and ICCIDs (`$ICCID`). The ICCID is
-usually not known in advance. It becomes known after the eUICC has decrypted and installed the profile package. It
-should also be noted that the ICCID parameter is always issued in its raw format (digits swapped, padded with 'F' at
-the end).
+#### getopts.sh
-In tryme.cfg one will also find a profile `X`, this profile is a placeholder in case the user decides not to edit
-tryme.cfg and to pass all parameters from the commandline instead.
+This shellscript is executed by the "tryme_*.sh" on each startup. It is not meant to be called directly by the user.
+The purpose of "getopts.sh" to either read the configurable parameters (EID, AC, ICCID) from "tryme.cfg" or to accept
+those parameters directly from the commandline. For a commandline help, the user may call any "tryme_*.sh" with the
+`-h` options. In case the "tryme_*.sh" scripts are called without parameters, the parameters are loaded from "tryme.cfg"
+In case a different config file shall be used, the user use the `-c` parameter to change the location of the config
+file.
### Downloading And Enabling A Profile
@@ -42,13 +53,11 @@
following example we will pass all parameters directly from the commandline. It is assumed that the REST API of
onomondo-eim is available at 127.0.0.1:8080.
-In the first step we will issue a download `order` using the `tryme_download.sh`. The parameter `X` tells tryme.cfg to
-use the placeholder profile. The second parameter is the EID (not to be confused with ICCID) of the eUICC. The
-third parameter serves as a placeholder for the ICCID, which we do not know or need yet. The last parameter is the
-`activationCode`.
+In the first step we will issue a download `order` using the `tryme_download.sh`. The parameter `-e` specifies the
+EID, The second parameter `-a` specifies the `activationCode` (AC).
```
-./tryme_download.sh X 12345678900000000000000000001234 NOT_NEEDED '1$rsp.example.com$EXAMPLE'
+./tryme_download.sh -e 12345678900000000000000000001234 -a '1$rsp.example.com$EXAMPLE'
```
When the script is executed, it will `create` the related REST resource and then `lookup` the REST `resource`
@@ -66,11 +75,11 @@
(to keep the rest table clean one should `delete` the rest resource now as described above)
However, the profile is not enabled yet. In order to use it, we must issue an `enable` PSMO first. To do that we may
-run `tryme_enable.sh`. The parameter `X` tells tryme.cfg to use the placeholder profile again. The second parameter is
-the EID and the third parameter is the ICCID that we have just taken from the JSON output above.
+run `tryme_enable.sh`. The parameter `-e` tells specifies the EID again. The second parameter `-i` specifies the
+the ICCID that we have just taken from the JSON output above.
```
-./tryme_enable.sh X 12345678900000000000000000001234 12324567899999911191
+./tryme_enable.sh -e 12345678900000000000000000001234 -i 12324567899999911191
```
We now must wait again until the IPAd fetches the related eIM package with the eUICC package that contains the `enable`
@@ -90,7 +99,7 @@
To send a `listProfileInfo` run:
```
-./tryme_listProfileInfo.sh X 12345678900000000000000000001234
+./tryme_listProfileInfo.sh -e 12345678900000000000000000001234
```
As soon as the IPAd has fetched and executed the related eUICC package, the JSON output should look like this:
@@ -111,7 +120,7 @@
To perform an eUICC data request, execute the following script like so:
```
-./tryme_euiccDataRequest.sh X 12345678900000000000000000001234
+./tryme_euiccDataRequest.sh -e 12345678900000000000000000001234
```
There should be response like this:
@@ -138,7 +147,7 @@
We would edit the order into tryme_set_euicc_param.sh and run the script:
```
-./tryme_euicc_set_state.sh X 12345678900000000000000000001234
+./tryme_euicc_set_state.sh -e 12345678900000000000000000001234
```
The order will execute as an internal process. This means that no IPAd interaction is involved. However, on the REST
@@ -165,7 +174,7 @@
We would edit the order into tryme_set_euicc_param.sh and run the script:
```
-./tryme_euicc_get_state.sh X 12345678900000000000000000001234
+./tryme_euicc_get_state.sh -e 12345678900000000000000000001234
```
The eIM will respond with a list of key value pairs of the requested eUICC states:
--
To view, visit https://gerrit.osmocom.org/c/onomondo-eim/+/43142?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: onomondo-eim
Gerrit-Branch: master
Gerrit-Change-Id: I4e42ce85c84b47d3561011083da4a1e54958fd8e
Gerrit-Change-Number: 43142
Gerrit-PatchSet: 6
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: jolly <andreas(a)eversberg.eu>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
1
0
[L] Change in onomondo-eim[master]: contrib: restructure REST API usage examples (tryme-scripts)
by dexter 02 Sep '26
by dexter 02 Sep '26
02 Sep '26
dexter has posted comments on this change by dexter. ( https://gerrit.osmocom.org/c/onomondo-eim/+/43142?usp=email )
Change subject: contrib: restructure REST API usage examples (tryme-scripts)
......................................................................
Patch Set 6: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/onomondo-eim/+/43142?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: onomondo-eim
Gerrit-Branch: master
Gerrit-Change-Id: I4e42ce85c84b47d3561011083da4a1e54958fd8e
Gerrit-Change-Number: 43142
Gerrit-PatchSet: 6
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: jolly <andreas(a)eversberg.eu>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Comment-Date: Wed, 02 Sep 2026 11:23:47 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
1
0
[M] Change in onomondo-eim[master]: rest_api_ressource/response_schema: fix regex for hexstring fields
by dexter 02 Sep '26
by dexter 02 Sep '26
02 Sep '26
dexter has submitted this change. ( https://gerrit.osmocom.org/c/onomondo-eim/+/43208?usp=email )
(
2 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
)Change subject: rest_api_ressource/response_schema: fix regex for hexstring fields
......................................................................
rest_api_ressource/response_schema: fix regex for hexstring fields
Fields which expect a hexstring use a regex to check if the string
is hexadecimal. Some fields also require a hexstring of a certain
length. Unfortunately some of those fields still have wrong regex.
- Remove the superflous ',' in [0-9,A-F]
- Correct the length requirements
Related: SYS#8100
Change-Id: I00e1870bca6ca661897f55ecab6771e0c72935ea
---
M priv/rest_api_resource_schema.json
M priv/rest_api_response_schema.json
2 files changed, 25 insertions(+), 25 deletions(-)
Approvals:
jolly: Looks good to me, but someone else must approve
laforge: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/priv/rest_api_resource_schema.json b/priv/rest_api_resource_schema.json
index c66bbaa..4ddbb8e 100644
--- a/priv/rest_api_resource_schema.json
+++ b/priv/rest_api_resource_schema.json
@@ -7,7 +7,7 @@
"eidValue": {
"description": "EID value of the eUICC to be addressed",
"type": "string",
- "pattern": "^[0-9,A-F]{2,32}$"
+ "pattern": "^[0-9A-F]{32}$"
},
"order": {
"description": "Order to be executed",
@@ -45,7 +45,7 @@
"iccid": {
"description": "ICCID of the profile. (ICCID in nibble-swapped raw format, see also ETSI TS 102 221, section 13.2)",
"type": "string",
- "pattern": "^[0-9,A-F]{2,32}$"
+ "pattern": "^[0-9A-F]{18,20}$"
},
"rollback": {
"description": "see also GSMA SGP.32, section 3.4.1, subsection 'Profile Rollback Procedure'",
@@ -66,7 +66,7 @@
"iccid": {
"description": "ICCID of the profile. (ICCID in nibble-swapped raw format, see also ETSI TS 102 221, section 13.2)",
"type": "string",
- "pattern": "^[0-9,A-F]{2,32}$"
+ "pattern": "^[0-9A-F]{18,20}$"
}
},
"required": [
@@ -83,7 +83,7 @@
"iccid": {
"description": "ICCID of the profile. (ICCID in nibble-swapped raw format)",
"type": "string",
- "pattern": "^[0-9,A-F]{2,32}$"
+ "pattern": "^[0-9A-F]{18,20}$"
}
},
"required": [
@@ -103,14 +103,14 @@
"isdpAid": {
"description": "AID of the ISDP (identifies a profile)",
"type": "string",
- "pattern": "^[0-9,A-F]{2,32}$"
+ "pattern": "^[0-9A-F]{2,32}$"
}
},
{
"iccid": {
"description": "ICCID of the profile. (ICCID in nibble-swapped raw format, see also ETSI TS 102 221, section 13.2)",
"type": "string",
- "pattern": "^[0-9,A-F]{2,32}$"
+ "pattern": "^[0-9A-F]{18,20}$"
}
},
{
@@ -124,7 +124,7 @@
"taglist": {
"description": "concatonation of the BER-TLV tags that shall be included in the response",
"type": "string",
- "pattern": "^[0-9,A-F]{2,32}$"
+ "pattern": "^[0-9A-F].*$"
}
},
"required": [
@@ -227,7 +227,7 @@
"eimConfigurationData": {
"description": "ASN.1 encoded EimConfigurationData",
"type": "string",
- "pattern": "^[0-9,A-F]{2,32}$"
+ "pattern": "^[0-9A-F].*$"
}
},
"required": [
@@ -260,7 +260,7 @@
"eimConfigurationData": {
"description": "ASN.1 encoded EimConfigurationData",
"type": "string",
- "pattern": "^[0-9,A-F]{2,32}$"
+ "pattern": "^[0-9A-F].*$"
}
},
"required": [
@@ -290,7 +290,7 @@
"tagList": {
"description": "see GSMA SGP.32, section 2.11.1.2",
"type": "string",
- "pattern": "^[0-9,A-F]{2,32}$"
+ "pattern": "^[0-9A-F].*$"
}
},
"required": [
diff --git a/priv/rest_api_response_schema.json b/priv/rest_api_response_schema.json
index 0f532d3..04ae8ce 100644
--- a/priv/rest_api_response_schema.json
+++ b/priv/rest_api_response_schema.json
@@ -95,12 +95,12 @@
"iccid": {
"description": "ICCID of the profile. (ICCID in nibble-swapped raw format, see also ETSI TS 102 221, section 13.2)",
"type": "string",
- "pattern": "^[0-9,A-F]{2,32}$"
+ "pattern": "^[0-9A-F]{18,20}$"
},
"isdpAid": {
"description": "AID of the ISDP (identifies a profile)",
"type": "string",
- "pattern": "^[0-9,A-F]{2,32}$"
+ "pattern": "^[0-9A-F]{2,32}$"
},
"profileState": {
"description": "usage state of the prifle",
@@ -129,7 +129,7 @@
"icon": {
"description": "icon graphic",
"type": "string",
- "pattern": "^[0-9,A-F]{2,32}$"
+ "pattern": "^[0-9A-F].*$"
},
"profileClass": {
"description": "0=test, 1=provisioning, 2=operational",
@@ -171,17 +171,17 @@
"mccMnc": {
"description": "MCC and MNC coded as defined in 3GPP TS 24.008",
"type": "string",
- "pattern": "^[0-9,A-F]{2,32}$"
+ "pattern": "^[0-9A-F]{3}$"
},
"gid1": {
"description": "referring to content of EF GID1 (file identifier '6F3E') as defined in 3GPP TS 31.102",
"type": "string",
- "pattern": "^[0-9,A-F]{2,32}$"
+ "pattern": "^[0-9A-F].*$"
},
"gid2": {
"description": "referring to content of EF GID2 (file identifier '6F3F') as defined in 3GPP TS 31.102",
"type": "string",
- "pattern": "^[0-9,A-F]{2,32}$"
+ "pattern": "^[0-9A-F].*$"
}
},
"required": [
@@ -409,7 +409,7 @@
"iccid": {
"description": "ICCID of the profile. (ICCID in nibble-swapped raw format, see also ETSI TS 102 221, section 13.2)",
"type": "string",
- "pattern": "^[0-9,A-F]{2,32}$"
+ "pattern": "^[0-9A-F]{18,20}$"
}
},
"required": [
@@ -477,12 +477,12 @@
"euiccInfo1": {
"description": "ASN.1 encoded, see GSMA SGP.22",
"type": "string",
- "pattern": "^[0-9,A-F]{2,32}$"
+ "pattern": "^[0-9A-F].*$"
},
"euiccInfo2": {
"description": "ASN.1 encoded, see GSMA SGP.22 and GSMA SGP.32",
"type": "string",
- "pattern": "^[0-9,A-F]{2,32}$"
+ "pattern": "^[0-9A-F].*$"
},
"rootSmdsAddress": {
"description": "see GSMA SGP.32",
@@ -495,27 +495,27 @@
"eumCertificate": {
"description": "ASN.1 encoded, see GSMA SGP.22",
"type": "string",
- "pattern": "^[0-9,A-F]{2,32}$"
+ "pattern": "^[0-9A-F].*$"
},
"euiccCertificate": {
"description": "ASN.1 encoded, see GSMA SGP.22",
"type": "string",
- "pattern": "^[0-9,A-F]{2,32}$"
+ "pattern": "^[0-9A-F].*$"
},
"ipaCapabilities": {
"description": "ASN.1 encoded, see GSMA SGP.32",
"type": "string",
- "pattern": "^[0-9,A-F]{2,32}$"
+ "pattern": "^[0-9A-F].*$"
},
"deviceInfo": {
"description": "ASN.1 encoded, see GSMA SGP.32",
"type": "string",
- "pattern": "^[0-9,A-F]{2,32}$"
+ "pattern": "^[0-9A-F].*$"
},
"notificationsList": {
"description": "ASN.1 encoded, see GSMA SGP.32",
"type": "string",
- "pattern": "^[0-9,A-F]{2,32}$"
+ "pattern": "^[0-9A-F].*$"
}
},
"additionalProperties": false
@@ -559,7 +559,7 @@
"debuginfo": {
"description": "Erlang ETS encoded debug information string, for debugging/diagnosis only",
"type": "string",
- "pattern": "^[0-9,A-F].*$"
+ "pattern": "^[0-9A-F].*$"
}
},
"required": [
--
To view, visit https://gerrit.osmocom.org/c/onomondo-eim/+/43208?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: onomondo-eim
Gerrit-Branch: master
Gerrit-Change-Id: I00e1870bca6ca661897f55ecab6771e0c72935ea
Gerrit-Change-Number: 43208
Gerrit-PatchSet: 4
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: jolly <andreas(a)eversberg.eu>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
1
0
[L] Change in onomondo-eim[master]: rest_handler: add API versions and schema validation
by dexter 02 Sep '26
by dexter 02 Sep '26
02 Sep '26
dexter has submitted this change. ( https://gerrit.osmocom.org/c/onomondo-eim/+/43089?usp=email )
Change subject: rest_handler: add API versions and schema validation
......................................................................
rest_handler: add API versions and schema validation
The JSON based REST API currently has no version checking and also
does not use any JSON schema based validation yet. This patch adds
both. An X-ADMIN-PROTOCOL field in the HTTP header informs about
the API version (same style as the JSON interfaces defined in
GSMA SGP.32 and SGP.22 would use). For incoming messages, the
X-ADMIN-PROTOCOL field is checked to prevent outdated clients from
using the REST API.
The incoming and outgoing JSON messages are now validated against
JSON schema files. Those are the same JSON schema file which were
only provided for documentation purposes only before. Now those
files have been fixed up and moved to the priv directory, where
they are now actively used.
Change-Id: I76e91e53a009cedf2cb1a0297db86e9e5fe7047a
Related: SYS#8100
---
M contrib/restop.py
M doc/rest_api.md
R priv/rest_api_info_schema.json
R priv/rest_api_resource_schema.json
R priv/rest_api_response_schema.json
M rebar.config
M rebar.lock
M src/onomondo_eim.app.src
M src/onomondo_eim_app.erl
M src/rest_handler.erl
A src/rest_middleware.erl
11 files changed, 191 insertions(+), 63 deletions(-)
Approvals:
dexter: Looks good to me, approved
Jenkins Builder: Verified
laforge: Looks good to me, but someone else must approve
diff --git a/contrib/restop.py b/contrib/restop.py
index 47c1953..a12ccd4 100755
--- a/contrib/restop.py
+++ b/contrib/restop.py
@@ -14,24 +14,29 @@
DOWNLOAD_DEFAULT='{ "eidValue" : "89882119900000000000000000000005", "order" : {"activationCode" : "1$testsmdpplus1.example.com$OPxLD-UVRuC-jysPI-YkOwT"}}'
PSMO_DEFAULT='{ "eidValue" : "89882119900000000000000000000005", "order" : [{"psmo" : "enable", "iccid" : "98001032547698103285", "rollback" : false }]}'
+req_headers = {
+ 'Content-Type': 'application/json',
+ 'X-Admin-Protocol': 'onomondo/eim/v1.0.0',
+}
+
def h2b(s) -> bytearray:
"""convert from a string of hex nibbles to a sequence of bytes"""
return bytes.fromhex(s)
def rest_create(host, facility, Json):
- r = requests.post("http://" + str(host) + "/" + str(facility) + "/create", json=Json)
+ r = requests.post("http://" + str(host) + "/" + str(facility) + "/create", json=Json, headers=req_headers)
return str(r.url)
def rest_lookup(host, facility, ResourceId):
- r = requests.get("http://" + str(host) + "/" + str(facility) + "/lookup/" + str(ResourceId))
+ r = requests.get("http://" + str(host) + "/" + str(facility) + "/lookup/" + str(ResourceId), headers=req_headers)
return r.json()
def rest_delete(host, facility, ResourceId):
- r = requests.get("http://" + str(host) + "/" + str(facility) + "/delete/" + str(ResourceId))
+ r = requests.get("http://" + str(host) + "/" + str(facility) + "/delete/" + str(ResourceId), headers=req_headers)
return r.json()
def rest_list(host, facility):
- r = requests.get("http://" + str(host) + "/" + str(facility) + "/list/")
+ r = requests.get("http://" + str(host) + "/" + str(facility) + "/list/", headers=req_headers)
return r.json()
def main(argv):
diff --git a/doc/rest_api.md b/doc/rest_api.md
index 59af59c..a3434dc 100644
--- a/doc/rest_api.md
+++ b/doc/rest_api.md
@@ -171,12 +171,22 @@
This description above describes only the basic concept of the REST API. To give a system integrator a detailed overview
on how the requests/responses should look like three JSON schema files are shipped with onomondo-eim:
-* contrib/rest_api_resource_schema.json: This schema describes a REST resource. This is the format that the requests
+* priv/rest_api_resource_schema.json: This schema describes a REST resource. This is the format that the requests
issued to the REST API should have.
-* contrib/rest_api_response_schema.json: This schema that describes the JSON formatted response that is received from the
+* priv/rest_api_response_schema.json: This schema that describes the JSON formatted response that is received from the
REST API when the `lookup` operation is performed.
-* contrib/rest_api_info_schema.json: This schema that describes the JSON formatted info page that is received when the
+* priv/rest_api_info_schema.json: This schema that describes the JSON formatted info page that is received when the
REST API is called without any parameters.
+#### HTTP Header
+
+When sending a REST request, the following additional HTTP header fields have to be present. The `X-Admin-Protocol`
+field must match the NSS of the URN found in the `$id` field of the JSON schema files.
+
+* Content-Type: application/json
+* X-Admin-Protocol: onomondo/eim/v1.0.0
+
+Note: Any REST response will also contain an `X-Admin-Protocol` field. Applications may query the `eIM Information`
+(see above) to receive and check the current API version used on the REST API.
\ No newline at end of file
diff --git a/contrib/rest_api_info_schema.json b/priv/rest_api_info_schema.json
similarity index 70%
rename from contrib/rest_api_info_schema.json
rename to priv/rest_api_info_schema.json
index d808dd6..b73addc 100644
--- a/contrib/rest_api_info_schema.json
+++ b/priv/rest_api_info_schema.json
@@ -1,7 +1,7 @@
{
- "$id": "https://onomondo.com/schemas/info",
- "$schema": "https://json-schema.org/draft/2020-12/schema",
- "title": "REST API info",
+ "$id": "urn:info:onomondo/eim/v1.0.0",
+ "$schema": "http://json-schema.org/draft-06/schema#",
+ "title": "onomondo-eim REST API info",
"type": "object",
"properties": {
"hostname": {
@@ -12,7 +12,7 @@
"description": "erlang node name of the onomondo-eim instance",
"type": "string"
},
- "version": {
+ "vsn": {
"description": "version number of the onomondo-eim instance",
"type": "string"
},
@@ -26,7 +26,7 @@
},
"esipaPort": {
"description": "IP-Port where the ESipa interface is bound to",
- "type": "string"
+ "type": "integer"
},
"esipaSslCert": {
"description": "SSL certificate that is used for the ESipa interface (HTTPS)",
@@ -46,16 +46,25 @@
"addInitialEimRequest": {
"description": "ASN.1 encoded eIM configuration (see also GSMA SGP.32)",
"type": "string",
- "pattern": "^[0-9,A-F]{2,32}$"
+ "pattern": "^[0-9A-F].*$"
},
"eimConfigurationData": {
"description": "ASN.1 encoded eIM configuration (see also GSMA SGP.32)",
"type": "string",
- "pattern": "^[0-9,A-F]{2,32}$"
+ "pattern": "^[0-9A-F].*$"
},
"counterValue": {
"description": "Initial counter value for signature generation (see also GSMA SGP.32)",
"type": "integer"
+ },
+ "consumerEuicc": {
+ "description": "Tells if this eIM treads new eUICCs as consumer eUICCs by default",
+ "type": "boolean"
}
- }
+ },
+ "required": [
+ "hostname", "node", "vsn", "eimId", "esipaIp", "esipaPort", "esipaSslCert", "eimCert", "rootCiCerts",
+ "addInitialEimRequest", "eimConfigurationData", "counterValue", "consumerEuicc"
+ ],
+ "additionalProperties": false
}
diff --git a/contrib/rest_api_resource_schema.json b/priv/rest_api_resource_schema.json
similarity index 90%
rename from contrib/rest_api_resource_schema.json
rename to priv/rest_api_resource_schema.json
index 8a9e91d..c66bbaa 100644
--- a/contrib/rest_api_resource_schema.json
+++ b/priv/rest_api_resource_schema.json
@@ -1,7 +1,7 @@
{
- "$id": "https://onomondo.com/schemas/resource",
- "$schema": "https://json-schema.org/draft/2020-12/schema",
- "title": "REST API resource",
+ "$id": "urn:resource:onomondo/eim/v1.0.0",
+ "$schema": "http://json-schema.org/draft-06/schema#",
+ "title": "onomondo-eim REST API resource",
"type": "object",
"properties": {
"eidValue": {
@@ -25,7 +25,8 @@
},
"required": [
"activationCode"
- ]
+ ],
+ "additionalProperties": false
}
},
{
@@ -53,7 +54,8 @@
},
"required": [
"iccid"
- ]
+ ],
+ "additionalProperties": false
}
},
{
@@ -69,7 +71,8 @@
},
"required": [
"iccid"
- ]
+ ],
+ "additionalProperties": false
}
},
{
@@ -85,7 +88,8 @@
},
"required": [
"iccid"
- ]
+ ],
+ "additionalProperties": false
}
},
{
@@ -125,14 +129,16 @@
},
"required": [
"searchCriteria"
- ]
+ ],
+ "additionalProperties": false
}
},
{
"getRAT": {
"description": "order the execution of a getRAT PSMO, see also GSMA SGP.32, section 5.9.13",
"type": "object",
- "properties": {}
+ "properties": {},
+ "additionalProperties": false
}
},
{
@@ -155,7 +161,8 @@
},
"required": [
"immediateEnableFlag"
- ]
+ ],
+ "additionalProperties": false
}
},
{
@@ -171,7 +178,8 @@
},
"required": [
"iccid"
- ]
+ ],
+ "additionalProperties": false
}
},
{
@@ -193,12 +201,14 @@
},
"required": [
"defaultDpAddress"
- ]
+ ],
+ "additionalProperties": false
}
}
]
}
- }
+ },
+ "additionalProperties": false
}
},
{
@@ -222,7 +232,8 @@
},
"required": [
"eimConfigurationData"
- ]
+ ],
+ "additionalProperties": false
}
},
{
@@ -237,7 +248,8 @@
},
"required": [
"eimId"
- ]
+ ],
+ "additionalProperties": false
}
},
{
@@ -253,7 +265,8 @@
},
"required": [
"eimConfigurationData"
- ]
+ ],
+ "additionalProperties": false
}
},
{
@@ -264,7 +277,8 @@
}
}
]
- }
+ },
+ "additionalProperties": false
}
}
},
@@ -281,7 +295,8 @@
},
"required": [
"tagList"
- ]
+ ],
+ "additionalProperties": false
}
},
{
@@ -328,10 +343,12 @@
"enum": ["counterValue", "consumerEuicc", "associationToken", "signAlgo", "signPubKey"]
}
}
- }
+ },
+ "additionalProperties": false
}
}
]
}
- }
+ },
+ "additionalProperties": false
}
diff --git a/contrib/rest_api_response_schema.json b/priv/rest_api_response_schema.json
similarity index 95%
rename from contrib/rest_api_response_schema.json
rename to priv/rest_api_response_schema.json
index e0bc6ed..0f532d3 100644
--- a/contrib/rest_api_response_schema.json
+++ b/priv/rest_api_response_schema.json
@@ -1,7 +1,7 @@
{
- "$id": "https://onomondo.com/schemas/response",
- "$schema": "https://json-schema.org/draft/2020-12/schema",
- "title": "REST API response",
+ "$id": "urn:response:onomondo/eim/v1.0.0",
+ "$schema": "http://json-schema.org/draft-06/schema#",
+ "title": "onomondo-eim REST API response",
"type": "object",
"properties": {
"status": {
@@ -20,7 +20,7 @@
"type": "string"
},
"resource": {
- "$ref": "/schemas/resource"
+ "$ref": "urn:resource:onomondo/eim/v1.0.0"
},
"outcome": {
"description": "specific result if the executed order",
@@ -141,7 +141,8 @@
},
"required": [
"finalResult"
- ]
+ ],
+ "additionalProperties": false
}
},
{
@@ -185,7 +186,8 @@
},
"required": [
"mccMnc"
- ]
+ ],
+ "additionalProperties": false
},
"consentRequired": {
"description": "indicates that the End User consent is required",
@@ -198,7 +200,8 @@
"ppr2",
"allowedOperators",
"consentRequired"
- ]
+ ],
+ "additionalProperties": false
}
}
},
@@ -277,7 +280,8 @@
},
"required": [
"addEimResultCode"
- ]
+ ],
+ "additionalProperties": false
}
},
{
@@ -345,7 +349,8 @@
},
"required": [
"finalResult"
- ]
+ ],
+ "additionalProperties": false
}
},
{
@@ -409,7 +414,8 @@
},
"required": [
"finalResult"
- ]
+ ],
+ "additionalProperties": false
}
},
{
@@ -511,12 +517,14 @@
"type": "string",
"pattern": "^[0-9,A-F]{2,32}$"
}
- }
+ },
+ "additionalProperties": false
}
},
"required": [
"edrResult"
- ]
+ ],
+ "additionalProperties": false
}
},
{
@@ -546,15 +554,16 @@
}
]
}
- },
- "debuginfo": {
- "description": "Erlang ETS encoded debug information string, for debugging/diagnosis only",
- "type": "string",
- "pattern": "^[0-9,A-F]{2,32}$"
}
+ },
+ "debuginfo": {
+ "description": "Erlang ETS encoded debug information string, for debugging/diagnosis only",
+ "type": "string",
+ "pattern": "^[0-9,A-F].*$"
}
},
"required": [
"status"
- ]
+ ],
+ "additionalProperties": false
}
diff --git a/rebar.config b/rebar.config
index 8108230..00ed4d9 100644
--- a/rebar.config
+++ b/rebar.config
@@ -10,7 +10,8 @@
{jiffy, "1.1.2"},
{quickrand, "2.0.7"},
{uuid, "2.0.7", {pkg, uuid_erl}},
- {jsx, "~> 3.1"}
+ {jsx, "~> 3.1"},
+ {jesse, "1.8.2"}
]}.
{project_plugins, [rebar3_asn1_compiler, erlfmt]}.
diff --git a/rebar.lock b/rebar.lock
index 5216b5c..9b29a63 100644
--- a/rebar.lock
+++ b/rebar.lock
@@ -4,6 +4,7 @@
{<<"cowlib">>,{pkg,<<"cowlib">>,<<"2.12.1">>},1},
{<<"hackney">>,{pkg,<<"hackney">>,<<"1.20.1">>},0},
{<<"idna">>,{pkg,<<"idna">>,<<"6.1.1">>},1},
+ {<<"jesse">>,{pkg,<<"jesse">>,<<"1.8.2">>},0},
{<<"jiffy">>,{pkg,<<"jiffy">>,<<"1.1.2">>},0},
{<<"jsx">>,{pkg,<<"jsx">>,<<"3.1.0">>},0},
{<<"metrics">>,{pkg,<<"metrics">>,<<"1.0.1">>},1},
@@ -21,6 +22,7 @@
{<<"cowlib">>, <<"A9FA9A625F1D2025FE6B462CB865881329B5CAFF8F1854D1CBC9F9533F00E1E1">>},
{<<"hackney">>, <<"8D97AEC62DDDDD757D128BFD1DF6C5861093419F8F7A4223823537BAD5D064E2">>},
{<<"idna">>, <<"8A63070E9F7D0C62EB9D9FCB360A7DE382448200FBBD1B106CC96D3D8099DF8D">>},
+ {<<"jesse">>, <<"6AEFE03B0275CC973D258FEA8EB1D5C27943C73199E6AF257A1BB3C763F552D3">>},
{<<"jiffy">>, <<"A9B6C9A7EC268E7CF493D028F0A4C9144F59CCB878B1AFE42841597800840A1B">>},
{<<"jsx">>, <<"D12516BAA0BB23A59BB35DCCAF02A1BD08243FCBB9EFE24F2D9D056CCFF71268">>},
{<<"metrics">>, <<"25F094DEA2CDA98213CECC3AEFF09E940299D950904393B2A29D191C346A8486">>},
@@ -37,6 +39,7 @@
{<<"cowlib">>, <<"163B73F6367A7341B33C794C4E88E7DBFE6498AC42DCD69EF44C5BC5507C8DB0">>},
{<<"hackney">>, <<"FE9094E5F1A2A2C0A7D10918FEE36BFEC0EC2A979994CFF8CFE8058CD9AF38E3">>},
{<<"idna">>, <<"92376EB7894412ED19AC475E4A86F7B413C1B9FBB5BD16DCCD57934157944CEA">>},
+ {<<"jesse">>, <<"46C9C46F673F07D9DF4158D1ACF62B0D0188DB35E8996833075E28B4FE639BAD">>},
{<<"jiffy">>, <<"BB61BC42A720BBD33CB09A410E48BB79A61012C74CB8B3E75F26D988485CF381">>},
{<<"jsx">>, <<"0C5CC8FDC11B53CC25CF65AC6705AD39E54ECC56D1C22E4ADB8F5A53FB9427F3">>},
{<<"metrics">>, <<"69B09ADDDC4F74A40716AE54D140F93BEB0FB8978D8636EADED0C31B6F099F16">>},
diff --git a/src/onomondo_eim.app.src b/src/onomondo_eim.app.src
index 049fce0..ffeb39e 100644
--- a/src/onomondo_eim.app.src
+++ b/src/onomondo_eim.app.src
@@ -15,7 +15,8 @@
hackney,
jiffy,
quickrand,
- uuid
+ uuid,
+ jesse
]},
{env, []}
]}.
diff --git a/src/onomondo_eim_app.erl b/src/onomondo_eim_app.erl
index 20d07a5..89ffd4a 100644
--- a/src/onomondo_eim_app.erl
+++ b/src/onomondo_eim_app.erl
@@ -119,6 +119,7 @@
),
% Startup REST server
+ rest_handler:load_json_schema(),
Dispatch_REST = rest_dispatch(),
{ok, RestIp} = application:get_env(onomondo_eim, rest_ip),
{ok, RestPort} = application:get_env(onomondo_eim, rest_port),
@@ -129,7 +130,7 @@
none,
none,
Dispatch_REST,
- [cowboy_router, cowboy_handler],
+ [cowboy_router, rest_middleware, cowboy_handler],
"REST"
),
diff --git a/src/rest_handler.erl b/src/rest_handler.erl
index 6718986..1497456 100644
--- a/src/rest_handler.erl
+++ b/src/rest_handler.erl
@@ -8,6 +8,7 @@
% Functions we provide to the Cowboy REST handler
-export([
+ load_json_schema/0,
init/2,
allowed_methods/2,
content_types_provided/2,
@@ -18,6 +19,34 @@
-record(state, {op}).
+% Load a single JSON schema from file.
+load_json_schema_one(JsonSchemaName) ->
+ {ok, JsonSchemaPath} = utils:get_priv_file_path(onomondo_eim, JsonSchemaName ++ ".json"),
+ logger:notice("Loading JSON schema from file: ~p~n", [JsonSchemaPath]),
+ {ok, JsonSchema} = file:read_file(JsonSchemaPath),
+ JsonSchemaDecoded = jiffy:decode(JsonSchema),
+ jesse:add_schema(JsonSchemaName, JsonSchemaDecoded).
+
+% Initial load of the JSON schema files (called once on startup).
+load_json_schema() ->
+ ok = load_json_schema_one("rest_api_resource_schema"),
+ ok = load_json_schema_one("rest_api_response_schema"),
+ ok = load_json_schema_one("rest_api_info_schema").
+
+% Decode and validate given encoded JSON data against a given JSON schema.
+decode_and_validate_json(JsonData, JsonSchemaName) ->
+ JsonDataDecoded = jiffy:decode(JsonData),
+ case jesse:validate(JsonSchemaName, JsonDataDecoded) of
+ {ok, JsonDataDecodedValidated} ->
+ {ok, JsonDataDecodedValidated};
+ {error, ValidationErrorCause} ->
+ logger:error(
+ "JSON validation failed:~nJsonSchemaName=~p~nJsonDataDecoded=~p~nValidationErrorCause=~p~n",
+ [JsonSchemaName, JsonDataDecoded, ValidationErrorCause]
+ ),
+ error
+ end.
+
% Initiaize state and extract the operation (create, lookup, update, list)
init(Req, Options) ->
State = #state{op = Options},
@@ -61,14 +90,14 @@
% Create a new resource and return its identifier
post_rest_create(Req, State, Facility) ->
- {ok, [{Content, true}], Req1} = cowboy_req:read_urlencoded_body(Req),
+ {ok, [{JsonData, true}], Req1} = cowboy_req:read_urlencoded_body(Req),
logger:info(
"REST: creating new REST resource,~nPeer=~p, Resource=~p, Facility=~p",
- [maps:get(peer, Req), Content, Facility]
+ [maps:get(peer, Req), JsonData, Facility]
),
- ContentDecoded = jiffy:decode(Content),
- {[{<<"eidValue">>, EidValue}, _]} = ContentDecoded,
- {[_, {<<"order">>, Order}]} = ContentDecoded,
+ {ok, JsonDataDecodedValidated} = decode_and_validate_json(JsonData, "rest_api_resource_schema"),
+ {[{<<"eidValue">>, EidValue}, _]} = JsonDataDecodedValidated,
+ {[_, {<<"order">>, Order}]} = JsonDataDecodedValidated,
{ok, ResourceId} = mnesia_db_rest:create(Facility, EidValue, Order),
case cowboy_req:method(Req1) of
<<"POST">> ->
@@ -111,6 +140,7 @@
{[{status, error}]}
end,
ResponseJson = jiffy:encode(Response),
+ {ok, _} = decode_and_validate_json(ResponseJson, "rest_api_response_schema"),
logger:info(
"REST: responding to client,~nPeer=~p, ResourceId=~p, Response:~p~n",
[maps:get(peer, Req), ResourceId, ResponseJson]
@@ -135,6 +165,7 @@
{[{status, error}]}
end,
ResponseJson = jiffy:encode(Response),
+ {ok, _} = decode_and_validate_json(ResponseJson, "rest_api_response_schema"),
logger:info(
"REST: responding to client,~nPeer=~p, ResourceId=~p, Response:~p~n",
[maps:get(peer, Req), ResourceId, ResponseJson]
@@ -197,8 +228,10 @@
{counterValue, CounterValue},
{consumerEuicc, ConsumerEuicc}
]},
- InfoListJson = utils:join_binary_list(jiffy:encode(InfoList)),
- Response = io_lib:format("~s", [binary_to_list(InfoListJson)]),
+ ResponseJson = utils:join_binary_list(jiffy:encode(InfoList)),
+ {ok, _} = decode_and_validate_json(ResponseJson, "rest_api_info_schema"),
+
+ Response = io_lib:format("~s", [binary_to_list(ResponseJson)]),
logger:info(
"REST: responding to client,~nPeer=~p, Response=~p~n",
[maps:get(peer, Req), list_to_binary(Response)]
diff --git a/src/rest_middleware.erl b/src/rest_middleware.erl
new file mode 100644
index 0000000..f0d73bf
--- /dev/null
+++ b/src/rest_middleware.erl
@@ -0,0 +1,39 @@
+% Copyright (c) 2025 Onomondo ApS & sysmocom - s.f.m.c. GmbH. All rights reserved.
+%
+% SPDX-License-Identifier: AGPL-3.0-only
+%
+% Author: Harald Welte <hwelte(a)sysmocom.de> / sysmocom - s.f.m.c. GmbH
+
+-module(rest_middleware).
+-behaviour(cowboy_middleware).
+
+-export([execute/2]).
+
+% Derive the X-ADMIN-PROTOCOL string from the URN contained in the $id field of the related JSON schema.
+protocol_from_json_schema(JsonSchemaName) ->
+ JsonSchema = jesse_database:load(JsonSchemaName),
+ {[{<<"$id">>, JsonSchemaId} | _]} = JsonSchema,
+ JsonSchemaIdUrnPath = maps:get(path, uri_string:parse(JsonSchemaId)),
+ [_, Protocol] = string:split(JsonSchemaIdUrnPath, ":"),
+ Protocol.
+
+% Cowboy middleware callback, make sure that the X-ADMIN-PROTOCOL field contains the expected protocol
+% identifier for incoming POST requests. For outgoing requests, set the X-ADMIN-PROTOCOL. Both strings
+% are derived from the related JSON schema.
+execute(Req0 = #{method := <<"POST">>}, State) ->
+ ExpectedProtocol = protocol_from_json_schema("rest_api_resource_schema"),
+ case cowboy_req:header(<<"x-admin-protocol">>, Req0) of
+ ExpectedProtocol ->
+ {ok, Req0, State};
+ Protocol ->
+ logger:error(
+ "Rejecting incompatible REST request: ~s,~nProtocol=~p, Peer=~p, Pid=~p~n",
+ [maps:get(path, Req0), Protocol, maps:get(peer, Req0), maps:get(pid, Req0)]
+ ),
+ Req = cowboy_req:reply(400, #{}, <<"Unsupported x-admin-protocol">>, Req0),
+ {stop, Req}
+ end;
+execute(Req0, Env) ->
+ Protocol = protocol_from_json_schema("rest_api_response_schema"),
+ Req1 = cowboy_req:set_resp_header(<<"x-admin-protocol">>, Protocol, Req0),
+ {ok, Req1, Env}.
--
To view, visit https://gerrit.osmocom.org/c/onomondo-eim/+/43089?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: onomondo-eim
Gerrit-Branch: master
Gerrit-Change-Id: I76e91e53a009cedf2cb1a0297db86e9e5fe7047a
Gerrit-Change-Number: 43089
Gerrit-PatchSet: 8
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
1
0
[L] Change in onomondo-eim[master]: rest_handler: add API versions and schema validation
by dexter 02 Sep '26
by dexter 02 Sep '26
02 Sep '26
dexter has posted comments on this change by dexter. ( https://gerrit.osmocom.org/c/onomondo-eim/+/43089?usp=email )
Change subject: rest_handler: add API versions and schema validation
......................................................................
Patch Set 8: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/onomondo-eim/+/43089?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: onomondo-eim
Gerrit-Branch: master
Gerrit-Change-Id: I76e91e53a009cedf2cb1a0297db86e9e5fe7047a
Gerrit-Change-Number: 43089
Gerrit-PatchSet: 8
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Comment-Date: Wed, 02 Sep 2026 11:23:21 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
1
0
[M] Change in onomondo-eim[master]: esipa_asn1_handler_utils: clean up handling of EuiccPackageResult
by dexter 02 Sep '26
by dexter 02 Sep '26
02 Sep '26
dexter has submitted this change. ( https://gerrit.osmocom.org/c/onomondo-eim/+/43016?usp=email )
Change subject: esipa_asn1_handler_utils: clean up handling of EuiccPackageResult
......................................................................
esipa_asn1_handler_utils: clean up handling of EuiccPackageResult
The function that handles the parsing and processing of the
EuiccPackageResult is written in a confusing way and also seems
to be slightly wrong (we do not want to re-bind any work item to a
eimTransactionId here). Let's clean it up in a way that is easier
to follow.
Change-Id: Ic2f64c254f3e07ce8dfdf43af977decf3514627b
Related: SYS#8100
---
M src/crypto_utils.erl
M src/esipa_asn1_handler_utils.erl
2 files changed, 83 insertions(+), 84 deletions(-)
Approvals:
dexter: Looks good to me, approved
Jenkins Builder: Verified
laforge: Looks good to me, but someone else must approve
diff --git a/src/crypto_utils.erl b/src/crypto_utils.erl
index 21929b5..7d051a1 100644
--- a/src/crypto_utils.erl
+++ b/src/crypto_utils.erl
@@ -12,6 +12,7 @@
-export([
sign_euiccPackageSigned/2,
verify_euiccPackageResultSigned/2,
+ verify_euiccPackageErrorSigned/2,
store_euicc_pubkey_from_authenticateResponseOk/2,
store_euicc_pubkey_from_ipaEuiccDataResponse/2
]).
@@ -107,52 +108,57 @@
error
end.
-verify_euiccPackageResultSigned(EuiccPackageResult, EidValue) ->
+verify_euiccPackageResultSigned(EuiccPackageResultSigned, EidValue) ->
{ok, ConsumerEuicc} = mnesia_db_euicc:state_get(EidValue, consumerEuicc),
case ConsumerEuicc of
false ->
% Read the AssociationToken
{ok, AssociationToken} = mnesia_db_euicc:state_get(EidValue, associationToken),
- case EuiccPackageResult of
- {euiccPackageResultSigned, EuiccPackageResultSigned} ->
- EuiccPackageResultDataSigned = maps:get(
- euiccPackageResultDataSigned, EuiccPackageResultSigned
- ),
- EuiccSignEPR = maps:get(euiccSignEPR, EuiccPackageResultSigned),
- {ok, EuiccPackageResultDataSigned_enc} = 'SGP32Definitions':encode(
- 'EuiccPackageResultDataSigned',
- EuiccPackageResultDataSigned
- ),
- % "euiccSignEPR SHALL apply on the concatenated data objects euiccPackageResultDataSigned and
- % eimSignature." (see also GSMA SGP.32, section 2.11.2.1)
- MsgToBeVerfied = utils:join_binary_list([
- EuiccPackageResultDataSigned_enc,
- enc_association_token(AssociationToken)
- ]),
- verify_signature(MsgToBeVerfied, EuiccSignEPR, EidValue);
- {euiccPackageErrorSigned, EuiccPackageErrorSigned} ->
- EuiccPackageErrorDataSigned = maps:get(
- euiccPackageErrorDataSigned, EuiccPackageErrorSigned
- ),
- EuiccSignEPE = maps:get(euiccSignEPE, EuiccPackageErrorSigned),
- {ok, EuiccPackageErrorDataSigned_enc} = 'SGP32Definitions':encode(
- 'EuiccPackageErrorDataSigned',
- EuiccPackageErrorDataSigned
- ),
- % "euiccSignEPE SHALL apply on the concatenated data objects euiccPackageErrorDataSigned and
- % eimSignature." (see also GSMA SGP.32, section 2.11.2.1)
- MsgToBeVerfied = utils:join_binary_list([
- EuiccPackageErrorDataSigned_enc,
- enc_association_token(AssociationToken)
- ]),
- verify_signature(MsgToBeVerfied, EuiccSignEPE, EidValue);
- {euiccPackageErrorUnsigned, _} ->
- % This result has no signature
- ok;
- _ ->
- error
- end;
+ EuiccPackageResultDataSigned = maps:get(
+ euiccPackageResultDataSigned, EuiccPackageResultSigned
+ ),
+ EuiccSignEPR = maps:get(euiccSignEPR, EuiccPackageResultSigned),
+ {ok, EuiccPackageResultDataSigned_enc} = 'SGP32Definitions':encode(
+ 'EuiccPackageResultDataSigned',
+ EuiccPackageResultDataSigned
+ ),
+ % "euiccSignEPR SHALL apply on the concatenated data objects euiccPackageResultDataSigned and
+ % eimSignature." (see also GSMA SGP.32, section 2.11.2.1)
+ MsgToBeVerfied = utils:join_binary_list([
+ EuiccPackageResultDataSigned_enc,
+ enc_association_token(AssociationToken)
+ ]),
+ verify_signature(MsgToBeVerfied, EuiccSignEPR, EidValue);
+ _ ->
+ logger:info(
+ "omitting signature check for euiccPackageResultSigned from eID ~p (consumer eUICC)~n",
+ [utils:binary_to_hex(EidValue)]
+ ),
+ ok
+ end.
+
+verify_euiccPackageErrorSigned(EuiccPackageErrorSigned, EidValue) ->
+ {ok, ConsumerEuicc} = mnesia_db_euicc:state_get(EidValue, consumerEuicc),
+ case ConsumerEuicc of
+ false ->
+ % Read the AssociationToken
+ {ok, AssociationToken} = mnesia_db_euicc:state_get(EidValue, associationToken),
+ EuiccPackageErrorDataSigned = maps:get(
+ euiccPackageErrorDataSigned, EuiccPackageErrorSigned
+ ),
+ EuiccSignEPE = maps:get(euiccSignEPE, EuiccPackageErrorSigned),
+ {ok, EuiccPackageErrorDataSigned_enc} = 'SGP32Definitions':encode(
+ 'EuiccPackageErrorDataSigned',
+ EuiccPackageErrorDataSigned
+ ),
+ % "euiccSignEPE SHALL apply on the concatenated data objects euiccPackageErrorDataSigned and
+ % eimSignature." (see also GSMA SGP.32, section 2.11.2.1)
+ MsgToBeVerfied = utils:join_binary_list([
+ EuiccPackageErrorDataSigned_enc,
+ enc_association_token(AssociationToken)
+ ]),
+ verify_signature(MsgToBeVerfied, EuiccSignEPE, EidValue);
_ ->
logger:info(
"omitting signature check for euiccPackageResultSigned from eID ~p (consumer eUICC)~n",
diff --git a/src/esipa_asn1_handler_utils.erl b/src/esipa_asn1_handler_utils.erl
index 8d6e59a..373922f 100644
--- a/src/esipa_asn1_handler_utils.erl
+++ b/src/esipa_asn1_handler_utils.erl
@@ -40,18 +40,13 @@
none
end.
-process_euiccPackageResult(Pid, EuiccPackageResult, Debuginfo, EimTransactionId) ->
- WorkBind = fun(Map) ->
- case maps:find(eimTransactionId, Map) of
- {ok, Value} ->
- mnesia_db_work:bind(Pid, Value);
- _ ->
- ok
- end
- end,
+% Handle an EuiccPackageResult, this includes everything from the handling of the work items in mnesia_db, down to
+% signature checks and the generation of an appropriate outcome for the REST API.
+handle_euiccPackageResult(Pid, EuiccPackageResult, Debuginfo) ->
+ EimTransactionId = eimTransactionId_from_euiccPackageResult(EuiccPackageResult),
+ {EidValue, _, _} = mnesia_db_work:pickup(Pid, EimTransactionId),
CheckCounterValue = fun(Map) ->
- {EidValue, _, _} = mnesia_db_work:pickup(Pid, EimTransactionId),
CounterValueIpad = maps:get(counterValue, Map),
{ok, CounterValueEim} = mnesia_db_euicc:state_get(EidValue, counterValue),
case CounterValueIpad of
@@ -59,7 +54,7 @@
ok;
_ ->
logger:error(
- "invalid euiccPackageResultSigned, counterValue mismatch: CounterValueIpad=~p, CounterValueEim=~p~n",
+ "invalid eUICC signature, counterValue mismatch: CounterValueIpad=~p, CounterValueEim=~p~n",
[CounterValueIpad, CounterValueEim]
),
error
@@ -69,31 +64,43 @@
Outcome =
case EuiccPackageResult of
{euiccPackageResultSigned, EuiccPackageResultSigned} ->
- EuiccPackageResultDataSigned = maps:get(
- euiccPackageResultDataSigned, EuiccPackageResultSigned
- ),
- WorkBind(EuiccPackageResultDataSigned),
- case CheckCounterValue(EuiccPackageResultDataSigned) of
+ case
+ crypto_utils:verify_euiccPackageResultSigned(EuiccPackageResultSigned, EidValue)
+ of
ok ->
- esipa_rest_utils:euiccPackageResultDataSigned_to_outcome(
- EuiccPackageResultDataSigned
- );
+ EuiccPackageResultDataSigned = maps:get(
+ euiccPackageResultDataSigned, EuiccPackageResultSigned
+ ),
+ case CheckCounterValue(EuiccPackageResultDataSigned) of
+ ok ->
+ esipa_rest_utils:euiccPackageResultDataSigned_to_outcome(
+ EuiccPackageResultDataSigned
+ );
+ _ ->
+ [{[{euiccPackageErrorCode, counterValueMismatch}]}]
+ end;
_ ->
- [{[{euiccPackageErrorCode, counterValueMismatch}]}]
+ [{[{procedureError, euiccSignatureInvalid}]}]
end;
{euiccPackageErrorSigned, EuiccPackageErrorSigned} ->
- EuiccPackageErrorDataSigned = maps:get(
- euiccPackageErrorDataSigned, EuiccPackageErrorSigned
- ),
- WorkBind(EuiccPackageErrorDataSigned),
- EuiccPackageErrorCode = maps:get(
- euiccPackageErrorCode, EuiccPackageErrorDataSigned
- ),
- case CheckCounterValue(EuiccPackageErrorDataSigned) of
+ case
+ crypto_utils:verify_euiccPackageErrorSigned(EuiccPackageErrorSigned, EidValue)
+ of
ok ->
- [{[{euiccPackageErrorCode, EuiccPackageErrorCode}]}];
+ EuiccPackageErrorDataSigned = maps:get(
+ euiccPackageErrorDataSigned, EuiccPackageErrorSigned
+ ),
+ EuiccPackageErrorCode = maps:get(
+ euiccPackageErrorCode, EuiccPackageErrorDataSigned
+ ),
+ case CheckCounterValue(EuiccPackageErrorDataSigned) of
+ ok ->
+ [{[{euiccPackageErrorCode, EuiccPackageErrorCode}]}];
+ _ ->
+ [{[{euiccPackageErrorCode, counterValueMismatch}]}]
+ end;
_ ->
- [{[{euiccPackageErrorCode, counterValueMismatch}]}]
+ [{[{procedureError, euiccSignatureInvalid}]}]
end;
{euiccPackageErrorUnsigned, _} ->
[{[{euiccPackageErrorCode, undefinedError}]}]
@@ -101,20 +108,6 @@
mnesia_db_work:finish(Pid, Outcome, Debuginfo).
-% Handle an EuiccPackageResult, this includes everything from the handling of the work items in mnesia_db, down to
-% signature checks and the generation of an appropriate outcome for the REST API.
-handle_euiccPackageResult(Pid, EuiccPackageResult, Debuginfo) ->
- EimTransactionId = eimTransactionId_from_euiccPackageResult(EuiccPackageResult),
- {EidValue, _, _} = mnesia_db_work:pickup(Pid, EimTransactionId),
- case crypto_utils:verify_euiccPackageResultSigned(EuiccPackageResult, EidValue) of
- ok ->
- process_euiccPackageResult(Pid, EuiccPackageResult, Debuginfo, EimTransactionId);
- _ ->
- mnesia_db_work:finish(
- Pid, [{[{procedureError, euiccSignatureInvalid}]}], Debuginfo
- )
- end.
-
% Handle an IpaEuiccDataResponse, this includes everything from the handling of the work items in mnesia_db as well
% as the generation of an appropriate outcome for the REST API. In case IpaEuiccDataResponse contains an eUICC public
% key, we will automatically store it so that we can use it to check the signatures of PSMOs and eCOs.
--
To view, visit https://gerrit.osmocom.org/c/onomondo-eim/+/43016?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: onomondo-eim
Gerrit-Branch: master
Gerrit-Change-Id: Ic2f64c254f3e07ce8dfdf43af977decf3514627b
Gerrit-Change-Number: 43016
Gerrit-PatchSet: 9
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
1
0