dexter has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/43144?usp=email )
Change subject: library/euicc: add ESipa JSON encoder/decoder module ......................................................................
library/euicc: add ESipa JSON encoder/decoder module
In order to test an eIM (or IPAd), which uses the JSON ESipa bindings instead of the ASN.1 ESipa bindings a set of encoder/decoder functions is needed to generate/parse the JSON messages exchanged on the ESipa interface
Change-Id: I8b6a87f39ca23658d980d19cf257b8994ea1cecb Related: SYS#8100 --- M eim/eIM_Tests.cfg M eim/eIM_Tests.ttcn M eim/gen_links.sh M library/euicc/RSPDefinitions_Types.ttcn M library/euicc/SGP32Definitions_Types.ttcn A library/euicc/esipa_Types_JSON.ttcn 6 files changed, 700 insertions(+), 43 deletions(-)
Approvals: Jenkins Builder: Verified laforge: Looks good to me, but someone else must approve dexter: Looks good to me, approved
diff --git a/eim/eIM_Tests.cfg b/eim/eIM_Tests.cfg index f100c41..00e7187 100644 --- a/eim/eIM_Tests.cfg +++ b/eim/eIM_Tests.cfg @@ -14,6 +14,7 @@
[MODULE_PARAMETERS] eIM_Tests.mp_restop_path := "./restop.py" +eIM_Tests.mp_esipa_json := false;
[MAIN_CONTROLLER]
diff --git a/eim/eIM_Tests.ttcn b/eim/eIM_Tests.ttcn index 0a1db80..035a028 100644 --- a/eim/eIM_Tests.ttcn +++ b/eim/eIM_Tests.ttcn @@ -37,6 +37,7 @@ import from HTTP_Adapter all;
import from es9p_Types_JSON all; +import from esipa_Types_JSON all; import from REST_Types_JSON all;
/* the PIPEasp port allows us to interact with restop.py via stdin/stdout */ @@ -81,6 +82,7 @@ charstring mp_esipa_ip := "127.0.0.1"; integer mp_esipa_port := 8000; boolean mp_esipa_disable_ssl := false; + boolean mp_esipa_json := false;
/* REST API tool */ charstring mp_restop_path; @@ -344,52 +346,67 @@ /* ************* ESipa/HTTP-client ************* */ /* ********************************************* */
-private function f_enc_http_req(in RemoteProfileProvisioningResponse es9p_res, out HTTPMessage http_res) { - var charstring json_body; - var HTTPResponse resp_body; - - enc_RemoteProfileProvisioningResponse_to_JSON(es9p_res, json_body); - resp_body := { - client_id := omit, - version_major := 1, - version_minor := 1, - statuscode := 200, - statustext := "OK", - /* See also SGP.32, section 6.1.1 */ - header := { - { - header_name := "X-Admin-Protocol", - header_value := "gsma/rsp/v1.0.0" - }, - { - header_name := "Content-Type", - header_value := "application/x-gsma-rsp-asn1" - }, - { - header_name := "Content-Length", - header_value := int2str(lengthof(json_body)) - } - }, - body := json_body - }; - - http_res := { response := resp_body }; -} with { extension "prototype(fast)" } - -template (value) HeaderLines ts_esipa_HTTP_Header := { - { header_name := "User-Agent", header_value := "TTCN3 eIM testsuite" }, +template (value) HeaderLines ts_esipa_HTTP_Header_asn1 := { + { header_name := "User-Agent", header_value := "TTCN3 eIM testsuite (ASN.1)" }, { header_name := "X-Admin-Protocol", header_value := "gsma/rsp/v2.1.0" }, { header_name := "Content-Type", header_value := "application/x-gsma-rsp-asn1" } };
+template (value) HeaderLines ts_esipa_HTTP_Header_json := { + { header_name := "User-Agent", header_value := "TTCN3 eIM testsuite (JSON)" }, + { header_name := "X-Admin-Protocol", header_value := "gsma/rsp/v2.1.0" }, + { header_name := "Content-Type", header_value := "application/json;charset=UTF-8" } +}; + /* Send ESipa HTTP request */ private function f_esipa_send(EsipaMessageFromIpaToEim esipa_req) runs on eIM_ConnHdlr { + if (mp_esipa_json == true) { + f_esipa_send_json(esipa_req); + } else { + f_esipa_send_asn(esipa_req); + } +} +private function f_esipa_send_asn(EsipaMessageFromIpaToEim esipa_req) runs on eIM_ConnHdlr { var octetstring esipa_req_enc; esipa_req_enc := enc_EsipaMessageFromIpaToEim(esipa_req); + f_http_tx_request(url := "/gsma/rsp2/asn1", method := "POST", - binary_body:= esipa_req_enc, - custom_hdr := valueof(ts_esipa_HTTP_Header), + binary_body := esipa_req_enc, + custom_hdr := valueof(ts_esipa_HTTP_Header_asn1), + client_id := g_http_client_id); +} +private function f_esipa_send_json(EsipaMessageFromIpaToEim esipa_req) runs on eIM_ConnHdlr { + var charstring esipa_req_enc; + var charstring url; + enc_EsipaMessageFromIpaToEim_to_JSON(esipa_req, esipa_req_enc); + + /* Determine the HTTP URL, see also GSMA SGP.32, section 6.4.1 and + * SGP32Definitions.asn:EsipaMessageFromIpaToEim */ + if (ispresent(esipa_req.initiateAuthenticationRequestEsipa)) { + url := "/gsma/rsp2/esipa/initiateAuthentication"; + } else if (ispresent(esipa_req.authenticateClientRequestEsipa)) { + url := "/gsma/rsp2/esipa/authenticateClient"; + } else if (ispresent(esipa_req.getBoundProfilePackageRequestEsipa)) { + url := "/gsma/rsp2/esipa/getBoundProfilePackage"; + } else if (ispresent(esipa_req.cancelSessionRequestEsipa)) { + url := "/gsma/rsp2/esipa/cancelSession"; + } else if (ispresent(esipa_req.handleNotificationEsipa)) { + url := "/gsma/rsp2/esipa/handleNotification"; + } else if (ispresent(esipa_req.transferEimPackageResponse)) { + url := "/gsma/rsp2/esipa/transferEimPackage"; + } else if (ispresent(esipa_req.getEimPackageRequest)) { + url := "/gsma/rsp2/esipa/getEimPackage"; + } else if (ispresent(esipa_req.provideEimPackageResult)) { + url := "/gsma/rsp2/esipa/provideEimPackageResult"; + } else { + setverdict(fail, "unknown ASN.1 choice member, check specification and upgrade lookup table."); + } + + f_http_tx_request(url := url, + method := "POST", + body := esipa_req_enc, + custom_hdr := valueof(ts_esipa_HTTP_Header_json), client_id := g_http_client_id); }
@@ -397,6 +414,7 @@ private function f_esipa_receive(template EsipaMessageFromEimToIpa expected_esipa_res := omit) runs on eIM_ConnHdlr return template EsipaMessageFromEimToIpa { var template EsipaMessageFromEimToIpa esipa_res; + var DecodedEimToIpaMessage_Wrap esipa_res_wrap; /* JSON */ var HTTPMessage response_http; response_http := f_http_rx_response(exp := ?, client_id := g_http_client_id, @@ -413,16 +431,35 @@ }
if (ispresent(response_http.response_binary)) { - esipa_res := dec_EsipaMessageFromEimToIpa(response_http.response_binary.body); - if (not istemplatekind(expected_esipa_res, "omit")) { - if (not match(valueof(esipa_res), expected_esipa_res)) { - setverdict(fail, "unexpected response from eIM on ESipa"); + if (mp_esipa_json == false) { + esipa_res := dec_EsipaMessageFromEimToIpa(response_http.response_binary.body); + if (not istemplatekind(expected_esipa_res, "omit")) { + if (not match(valueof(esipa_res), expected_esipa_res)) { + setverdict(fail, "unexpected response from eIM on ESipa"); + } } + return esipa_res; + } else { + setverdict(fail, "unexpected response from eIM on ESipa (response is JSON instead of ASN.1?)"); + return omit; } - return esipa_res; + } else if (ispresent(response_http.response)) { + if (mp_esipa_json == true) { + dec_EsipaMessageFromEimToIpa_from_JSON(response_http.response.body, esipa_res_wrap); + esipa_res := esipa_res_wrap.asn1_pdu; + if (not istemplatekind(expected_esipa_res, "omit")) { + if (not match(valueof(esipa_res), expected_esipa_res)) { + setverdict(fail, "unexpected response from eIM on ESipa"); + } + } + return esipa_res; + } else { + setverdict(fail, "unexpected response from eIM on ESipa (response is ASN.1 instead of JSON?)"); + return omit; + } } else { setverdict(fail, - "unexpected ESipa response, the HTTP body did either contain no or a non binary response"); + "unexpected ESipa response, the HTTP body did not contain any response"); return omit; } } diff --git a/eim/gen_links.sh b/eim/gen_links.sh index a8f91dd..91a67ea 100755 --- a/eim/gen_links.sh +++ b/eim/gen_links.sh @@ -34,7 +34,7 @@ FILES="PEDefinitions.asn PKIX1Explicit88.asn PKIX1Implicit88.asn RSPDefinitions.asn SGP32Definitions.asn " FILES+="PKIX1Explicit88_Templates.ttcn PKIX1Explicit88_Types.ttcn PKIX1Implicit88_Templates.ttcn " FILES+="PKIX1Implicit88_Types.ttcn RSPDefinitions_Templates.ttcn RSPDefinitions_Types.ttcn " -FILES+="SGP32Definitions_Templates.ttcn SGP32Definitions_Types.ttcn " +FILES+="SGP32Definitions_Templates.ttcn SGP32Definitions_Types.ttcn esipa_Types_JSON.ttcn " FILES+="es9p_Types_JSON.ttcn esx_header_Types_JSON.ttcn" gen_links $DIR $FILES
diff --git a/library/euicc/RSPDefinitions_Types.ttcn b/library/euicc/RSPDefinitions_Types.ttcn index b355e95..e4aca98 100644 --- a/library/euicc/RSPDefinitions_Types.ttcn +++ b/library/euicc/RSPDefinitions_Types.ttcn @@ -128,4 +128,9 @@ external function enc_NotificationMetadata(in NotificationMetadata msg) return octetstring with { extension "prototype(convert) encode(BER:BER_ENCODE_DER)" };
+external function dec_CtxParams1(in octetstring stream) return CtxParams1 +with { extension "prototype(convert) decode(BER:BER_ACCEPT_ALL)" }; +external function enc_CtxParams1(in CtxParams1 msg) return octetstring +with { extension "prototype(convert) encode(BER:BER_ENCODE_DER)" }; + } diff --git a/library/euicc/SGP32Definitions_Types.ttcn b/library/euicc/SGP32Definitions_Types.ttcn index fb6b51b..021c60f 100644 --- a/library/euicc/SGP32Definitions_Types.ttcn +++ b/library/euicc/SGP32Definitions_Types.ttcn @@ -98,6 +98,36 @@ external function enc_GetConnectivityParametersResponse(in GetConnectivityParametersResponse msg) return octetstring with { extension "prototype(convert) encode(BER:BER_ENCODE_DER)" };
+external function dec_SGP32_CancelSessionResponse(in octetstring stream) return SGP32_CancelSessionResponse +with { extension "prototype(convert) decode(BER:BER_ACCEPT_ALL)" }; +external function enc_SGP32_CancelSessionResponse(in SGP32_CancelSessionResponse msg) return octetstring +with { extension "prototype(convert) encode(BER:BER_ENCODE_DER)" }; + +external function dec_SGP32_PrepareDownloadResponse(in octetstring stream) return SGP32_PrepareDownloadResponse +with { extension "prototype(convert) decode(BER:BER_ACCEPT_ALL)" }; +external function enc_SGP32_PrepareDownloadResponse(in SGP32_PrepareDownloadResponse msg) return octetstring +with { extension "prototype(convert) encode(BER:BER_ENCODE_DER)" }; + +external function dec_SGP32_AuthenticateServerResponse(in octetstring stream) return SGP32_AuthenticateServerResponse +with { extension "prototype(convert) decode(BER:BER_ACCEPT_ALL)" }; +external function enc_SGP32_AuthenticateServerResponse(in SGP32_AuthenticateServerResponse msg) return octetstring +with { extension "prototype(convert) encode(BER:BER_ENCODE_DER)" }; + +external function dec_SGP32_PendingNotification(in octetstring stream) return SGP32_PendingNotification +with { extension "prototype(convert) decode(BER:BER_ACCEPT_ALL)" }; +external function enc_SGP32_PendingNotification(in SGP32_PendingNotification msg) return octetstring +with { extension "prototype(convert) encode(BER:BER_ENCODE_DER)" }; + +external function dec_ProvideEimPackageResult(in octetstring stream) return ProvideEimPackageResult +with { extension "prototype(convert) decode(BER:BER_ACCEPT_ALL)" }; +external function enc_ProvideEimPackageResult(in ProvideEimPackageResult msg) return octetstring +with { extension "prototype(convert) encode(BER:BER_ENCODE_DER)" }; + +external function dec_SGP32_StoreMetadataRequest(in octetstring stream) return SGP32_StoreMetadataRequest +with { extension "prototype(convert) decode(BER:BER_ACCEPT_ALL)" }; +external function enc_SGP32_StoreMetadataRequest(in SGP32_StoreMetadataRequest msg) return octetstring +with { extension "prototype(convert) encode(BER:BER_ENCODE_DER)" }; + external function dec_EuiccPackageRequest(in octetstring stream) return EuiccPackageRequest with { extension "prototype(convert) decode(BER:BER_ACCEPT_ALL)" }; external function enc_EuiccPackageRequest(in EuiccPackageRequest msg) return octetstring @@ -108,4 +138,24 @@ external function enc_SGP32_RetrieveNotificationsListResponse(in SGP32_RetrieveNotificationsListResponse msg) return octetstring with { extension "prototype(convert) encode(BER:BER_ENCODE_DER)" };
+external function dec_IpaEuiccDataRequest(in octetstring stream) return IpaEuiccDataRequest +with { extension "prototype(convert) decode(BER:BER_ACCEPT_ALL)" }; +external function enc_IpaEuiccDataRequest(in IpaEuiccDataRequest msg) return octetstring +with { extension "prototype(convert) encode(BER:BER_ENCODE_DER)" }; + +external function dec_ProfileDownloadTriggerRequest(in octetstring stream) return ProfileDownloadTriggerRequest +with { extension "prototype(convert) decode(BER:BER_ACCEPT_ALL)" }; +external function enc_ProfileDownloadTriggerRequest(in ProfileDownloadTriggerRequest msg) return octetstring +with { extension "prototype(convert) encode(BER:BER_ENCODE_DER)" }; + +external function dec_EimPackageResult(in octetstring stream) return EimPackageResult +with { extension "prototype(convert) decode(BER:BER_ACCEPT_ALL)" }; +external function enc_EimPackageResult(in EimPackageResult msg) return octetstring +with { extension "prototype(convert) encode(BER:BER_ENCODE_DER)" }; + +external function dec_EimAcknowledgements(in octetstring stream) return EimAcknowledgements +with { extension "prototype(convert) decode(BER:BER_ACCEPT_ALL)" }; +external function enc_EimAcknowledgements(in EimAcknowledgements msg) return octetstring +with { extension "prototype(convert) encode(BER:BER_ENCODE_DER)" }; + } diff --git a/library/euicc/esipa_Types_JSON.ttcn b/library/euicc/esipa_Types_JSON.ttcn new file mode 100644 index 0000000..132aaa8 --- /dev/null +++ b/library/euicc/esipa_Types_JSON.ttcn @@ -0,0 +1,564 @@ +/* JSON message definitions for ES9+ + * + * Author: Philipp Maier pmaier@sysmocom.de / sysmocom - s.f.m.c. GmbH + * + * Released under the terms of GNU General Public License, Version 2 or + * (at your option) any later version. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +module esipa_Types_JSON { + +import from esx_header_Types_JSON all; + +import from SGP32Definitions all; +import from SGP32Definitions_Types all; +import from SGP32Definitions_Templates all; + +import from RSPDefinitions all; +import from RSPDefinitions_Types all; +import from RSPDefinitions_Templates all; + +import from PKIX1Explicit88 all; +import from PKIX1Explicit88_Templates all; +import from PKIX1Explicit88_Types all; + +import from PKIX1Implicit88 all; +import from PKIX1Implicit88_Templates all; +import from PKIX1Implicit88_Types all; + +/* GSMA SGP.32, section 6.4.1.1 */ +type record JSON_ESipa_InitiateAuthenticationRequest { + JSON_ESx_RequestHeader header, + charstring euiccChallenge, + charstring euiccInfo1 optional, + charstring smdpAddress optional, + charstring eimTransactionId optional +}; +type record JSON_ESipa_InitiateAuthenticationResponse { + JSON_ESx_ResponseHeader header, + charstring transactionId, + charstring serverSigned1, + charstring serverSignature1, + charstring euiccCiPKIdentifierToBeUsed, + charstring serverCertificate, + universal charstring matchingId optional, + charstring ctxParams1 optional +}; + +/* GSMA SGP.32, section 6.4.1.2 */ +type record JSON_ESipa_AuthenticateClientRequest { + JSON_ESx_RequestHeader header, + charstring transactionId, + charstring authenticateServerResponse +}; +type record JSON_ESipa_AuthenticateClientResponse { + JSON_ESx_ResponseHeader header, + charstring transactionId optional, + charstring profileMetadata optional, + charstring smdpSigned2, + charstring smdpSignature2, + charstring smdpCertificate, + charstring hashCc optional +}; + +/* GSMA SGP.32, section 6.4.1.3 */ +type record JSON_ESipa_GetBoundProfilePackageRequest { + JSON_ESx_RequestHeader header, + charstring transactionId, + charstring prepareDownloadResponse +}; +type record JSON_ESipa_GetBoundProfilePackageResponse { + JSON_ESx_ResponseHeader header, + charstring transactionId optional, + charstring boundProfilePackage +}; + +/* GSMA SGP.32, section 6.4.1.5 */ +type record JSON_ESipa_GetEimPackageRequest { + JSON_ESx_RequestHeader header, + charstring eidValue, + boolean notifyStateChange optional, + integer stateChangeCause optional, + charstring rPlmn optional +}; +type record JSON_ESipa_GetEimPackageResponse_euiccPkgReq { + JSON_ESx_ResponseHeader header, + charstring euiccPackageRequest +}; +type record JSON_ESipa_GetEimPackageResponse_euiccDataReq { + JSON_ESx_ResponseHeader header, + charstring ipaEuiccDataRequest +}; +type record JSON_ESipa_GetEimPackageResponse_dnlTrigReq { + JSON_ESx_ResponseHeader header, + charstring profileDownloadTriggerRequest +}; +type record JSON_ESipa_GetEimPackageResponse_eimPkgErr { + JSON_ESx_ResponseHeader header, + integer eimPackageError +}; +type union JSON_ESipa_GetEimPackageResponse { + JSON_ESipa_GetEimPackageResponse_euiccPkgReq getEimPackageResponse_euiccPkgReq, + JSON_ESipa_GetEimPackageResponse_euiccDataReq getEimPackageResponse_euiccDataReq, + JSON_ESipa_GetEimPackageResponse_dnlTrigReq getEimPackageResponse_dnlTrigReq, + JSON_ESipa_GetEimPackageResponse_eimPkgErr getEimPackageResponse_eimPkgErr +} with { + variant "JSON : as value" +} + +/* GSMA SGP.32, section 6.4.1.6 */ +type record JSON_ESipa_ProvideEimPackageResultRequest { + JSON_ESx_RequestHeader header, + charstring eidValue optional, + charstring eimPackageResult +}; +type record JSON_ESipa_ProvideEimPackageResultResponse { + JSON_ESx_ResponseHeader header, + charstring eimAcknowledgements optional +}; + +/* GSMA SGP.32, section 6.4.1.7 */ +type record JSON_ESipa_HandleNotification_pendingNotif { + JSON_ESx_RequestHeader header, + charstring pendingNotification +}; +type record JSON_ESipa_HandleNotification_prvdeEimPkgRslt { + JSON_ESx_RequestHeader header, + charstring provideEimPackageResult +}; +type union JSON_ESipa_HandleNotification { + JSON_ESipa_HandleNotification_pendingNotif handleNotification_pendingNotif, + JSON_ESipa_HandleNotification_prvdeEimPkgRslt handleNotification_prvdeEimPkgRslt +} with { + variant "JSON : as value" +} + +/* GSMA SGP.32, section 6.4.1.8 */ +type record JSON_ESipa_CancelSessionRequest { + JSON_ESx_RequestHeader header, + charstring transactionId, + charstring cancelSessionResponse +}; + +/* An empty response that is used when the response only consists of a JSON header */ +type record JSON_ESipa_EmptyResponse { + JSON_ESx_ResponseHeader header +}; + +/* Definition for JSON ESipa requests */ +type union JSON_ESipa_EsipaMessageFromIpaToEim { + JSON_ESipa_InitiateAuthenticationRequest initiateAuthenticationRequest, + JSON_ESipa_AuthenticateClientRequest authenticateClientRequest, + JSON_ESipa_GetBoundProfilePackageRequest getBoundProfilePackageRequest, + JSON_ESipa_GetEimPackageRequest getEimPackageRequest, + JSON_ESipa_ProvideEimPackageResultRequest provideEimPackageResultRequest, + JSON_ESipa_HandleNotification handleNotification, + JSON_ESipa_CancelSessionRequest cancelSessionRequest +} with { + variant "JSON : as value" +} + +external function enc_JSON_ESipa_EsipaMessageFromIpaToEim(in JSON_ESipa_EsipaMessageFromIpaToEim msg) return octetstring +with { + extension "prototype (convert) encode(JSON)"; + extension "printing(pretty)"; + extension "errorbehavior(ALL:ERROR)" +} +external function dec_JSON_ESipa_EsipaMessageFromIpaToEim(in octetstring stream) return JSON_ESipa_EsipaMessageFromIpaToEim +with { + extension "prototype (convert) decode(JSON)" + extension "errorbehavior(ALL:ERROR)" +} + +/* Definition for JSON ESipa responses */ +type union JSON_ESipa_EsipaMessageFromEimToIpa +{ + JSON_ESipa_InitiateAuthenticationResponse initiateAuthenticationResponse, + JSON_ESipa_AuthenticateClientResponse authenticateClientResponse, + JSON_ESipa_GetBoundProfilePackageResponse getBoundProfilePackageResponse, + JSON_ESipa_GetEimPackageResponse getEimPackageResponse, + JSON_ESipa_ProvideEimPackageResultResponse provideEimPackageResultResponse, + JSON_ESipa_EmptyResponse emptyResponse +} with { + variant "JSON : as value" +} + +external function enc_JSON_ESipa_EsipaMessageFromEimToIpa(in JSON_ESipa_EsipaMessageFromEimToIpa msg) return octetstring +with { + extension "prototype (convert) encode(JSON)"; + extension "printing(pretty)"; + extension "errorbehavior(ALL:ERROR)" +} +external function dec_JSON_ESipa_EsipaMessageFromEimToIpa(in octetstring stream) return JSON_ESipa_EsipaMessageFromEimToIpa +with { + extension "prototype (convert) decode(JSON)" + extension "errorbehavior(ALL:ERROR)" +} + +/* Converter function to decode a JSON formatted ESipa request to its ASN.1 ESipa record representation */ +function dec_EsipaMessageFromIpaToEim_from_JSON(in charstring json_pdu_enc, out EsipaMessageFromIpaToEim asn1_pdu_dec) { + var JSON_ESipa_EsipaMessageFromIpaToEim json_pdu; + json_pdu := dec_JSON_ESipa_EsipaMessageFromIpaToEim(char2oct(json_pdu_enc)); + + if (ispresent(json_pdu.initiateAuthenticationRequest)) { + var template charstring smdpAddress := omit; + var template EUICCInfo1 euiccInfo1 := omit; + var template octetstring eimTransactionId := omit; + if (ispresent(json_pdu.initiateAuthenticationRequest.smdpAddress)) { + smdpAddress := json_pdu.initiateAuthenticationRequest.smdpAddress; + } + if (ispresent(json_pdu.initiateAuthenticationRequest.euiccInfo1)) { + euiccInfo1 := dec_EUICCInfo1(decode_base64(json_pdu.initiateAuthenticationRequest.euiccInfo1)); + } + if (ispresent(json_pdu.initiateAuthenticationRequest.eimTransactionId)) { + eimTransactionId := str2oct(json_pdu.initiateAuthenticationRequest.eimTransactionId); + } + asn1_pdu_dec := valueof(ts_initiateAuthenticationRequestEsipa( + decode_base64(json_pdu.initiateAuthenticationRequest.euiccChallenge), + smdpAddress, euiccInfo1, eimTransactionId)); + } else if (ispresent(json_pdu.authenticateClientRequest)) { + asn1_pdu_dec := valueof(ts_authenticateClientRequestEsipa( + str2oct(json_pdu.authenticateClientRequest.transactionId), + dec_SGP32_AuthenticateServerResponse(decode_base64(json_pdu.authenticateClientRequest.authenticateServerResponse)))); + } else if (ispresent(json_pdu.getBoundProfilePackageRequest)) { + asn1_pdu_dec := valueof(ts_getBoundProfilePackageRequestEsipa( + str2oct(json_pdu.getBoundProfilePackageRequest.transactionId), + dec_SGP32_PrepareDownloadResponse(decode_base64(json_pdu.getBoundProfilePackageRequest.prepareDownloadResponse)))); + } else if (ispresent(json_pdu.getEimPackageRequest)) { + var template AsnNull notifyStateChange := omit; + var template integer stateChangeCause := omit; + var template octetstring rPlmn := omit; + if (ispresent(json_pdu.getEimPackageRequest.notifyStateChange) and json_pdu.getEimPackageRequest.notifyStateChange == true) { + notifyStateChange := NULL; + } + if (ispresent(json_pdu.getEimPackageRequest.stateChangeCause)) { + stateChangeCause := json_pdu.getEimPackageRequest.stateChangeCause + } + if (ispresent(json_pdu.getEimPackageRequest.rPlmn)) { + rPlmn := str2oct(json_pdu.getEimPackageRequest.rPlmn); + } + asn1_pdu_dec := valueof(ts_getEimPackageRequest( + str2oct(json_pdu.getEimPackageRequest.eidValue), + notifyStateChange, stateChangeCause, rPlmn)); + } else if (ispresent(json_pdu.provideEimPackageResultRequest)) { + var template octetstring eidValue := omit; + if (ispresent(json_pdu.provideEimPackageResultRequest.eidValue)) { + eidValue := str2oct(json_pdu.provideEimPackageResultRequest.eidValue); + } + asn1_pdu_dec := valueof(ts_provideEimPackageResult(eidValue, + dec_EimPackageResult(decode_base64(json_pdu.provideEimPackageResultRequest.eimPackageResult)))); + } else if (ispresent(json_pdu.handleNotification)) { + if (ispresent(json_pdu.handleNotification.handleNotification_pendingNotif)) { + asn1_pdu_dec := valueof(ts_handleNotificationEsipa_pendingNotif( + dec_SGP32_PendingNotification(decode_base64(json_pdu.handleNotification.handleNotification_pendingNotif.pendingNotification)))); + } else if (ispresent(json_pdu.handleNotification.handleNotification_prvdeEimPkgRslt)) { + asn1_pdu_dec := valueof(ts_handleNotificationEsipa_prvdeEimPkgRslt( + dec_ProvideEimPackageResult(decode_base64(json_pdu.handleNotification.handleNotification_prvdeEimPkgRslt.provideEimPackageResult)))); + } + } else if (ispresent(json_pdu.cancelSessionRequest)) { + asn1_pdu_dec := valueof(ts_cancelSessionRequestEsipa( + str2oct(json_pdu.cancelSessionRequest.transactionId), + dec_SGP32_CancelSessionResponse(decode_base64(json_pdu.cancelSessionRequest.cancelSessionResponse)))); + } else { + setverdict(fail, "decoder path not implemented for JSON ESipa message"); + } +} with { extension "prototype(fast)" } + +/* Converter function to encode an ASN.1 ESipa request record to its JSON formatted ESipa representation */ +function enc_EsipaMessageFromIpaToEim_to_JSON(in EsipaMessageFromIpaToEim asn1_pdu_dec, out charstring json_pdu_enc) { + var JSON_ESipa_EsipaMessageFromIpaToEim json_pdu; + + var charstring functionRequesterIdentifier := "TTCN3"; + var charstring functionCallIdentifier := "testsuite"; + + if (ispresent(asn1_pdu_dec.initiateAuthenticationRequestEsipa)) { + json_pdu.initiateAuthenticationRequest.header.functionRequesterIdentifier := functionRequesterIdentifier; + json_pdu.initiateAuthenticationRequest.header.functionCallIdentifier := functionCallIdentifier; + json_pdu.initiateAuthenticationRequest.euiccChallenge := encode_base64(asn1_pdu_dec.initiateAuthenticationRequestEsipa.euiccChallenge); + if (ispresent(asn1_pdu_dec.initiateAuthenticationRequestEsipa.smdpAddress)) { + json_pdu.initiateAuthenticationRequest.smdpAddress := unichar2char(asn1_pdu_dec.initiateAuthenticationRequestEsipa.smdpAddress); + } + if (ispresent(asn1_pdu_dec.initiateAuthenticationRequestEsipa.euiccInfo1)) { + json_pdu.initiateAuthenticationRequest.euiccInfo1 := encode_base64(enc_EUICCInfo1(asn1_pdu_dec.initiateAuthenticationRequestEsipa.euiccInfo1)); + } + if (ispresent(asn1_pdu_dec.initiateAuthenticationRequestEsipa.eimTransactionId)) { + json_pdu.initiateAuthenticationRequest.eimTransactionId := oct2str(asn1_pdu_dec.initiateAuthenticationRequestEsipa.eimTransactionId); + } + json_pdu_enc := oct2char(enc_JSON_ESipa_EsipaMessageFromIpaToEim(json_pdu)); + } else if (ispresent(asn1_pdu_dec.authenticateClientRequestEsipa)) { + json_pdu.authenticateClientRequest.header.functionRequesterIdentifier := functionRequesterIdentifier; + json_pdu.authenticateClientRequest.header.functionCallIdentifier := functionCallIdentifier; + json_pdu.authenticateClientRequest.transactionId := oct2str(asn1_pdu_dec.authenticateClientRequestEsipa.transactionId); + json_pdu.authenticateClientRequest.authenticateServerResponse := + encode_base64(enc_SGP32_AuthenticateServerResponse(asn1_pdu_dec.authenticateClientRequestEsipa.authenticateServerResponse)) + json_pdu_enc := oct2char(enc_JSON_ESipa_EsipaMessageFromIpaToEim(json_pdu)); + } else if (ispresent(asn1_pdu_dec.getBoundProfilePackageRequestEsipa)) { + json_pdu.getBoundProfilePackageRequest.header.functionRequesterIdentifier := functionRequesterIdentifier; + json_pdu.getBoundProfilePackageRequest.header.functionCallIdentifier := functionCallIdentifier; + json_pdu.getBoundProfilePackageRequest.transactionId := oct2str(asn1_pdu_dec.getBoundProfilePackageRequestEsipa.transactionId); + json_pdu.getBoundProfilePackageRequest.prepareDownloadResponse := + encode_base64(enc_SGP32_PrepareDownloadResponse(asn1_pdu_dec.getBoundProfilePackageRequestEsipa.prepareDownloadResponse)); + json_pdu_enc := oct2char(enc_JSON_ESipa_EsipaMessageFromIpaToEim(json_pdu)); + } else if (ispresent(asn1_pdu_dec.getEimPackageRequest)) { + json_pdu.getEimPackageRequest.header.functionRequesterIdentifier := functionRequesterIdentifier; + json_pdu.getEimPackageRequest.header.functionCallIdentifier := functionCallIdentifier; + json_pdu.getEimPackageRequest.eidValue := oct2str(asn1_pdu_dec.getEimPackageRequest.eidValue); + if (ispresent(asn1_pdu_dec.getEimPackageRequest.notifyStateChange) and asn1_pdu_dec.getEimPackageRequest.notifyStateChange == NULL) { + json_pdu.getEimPackageRequest.notifyStateChange := true; + } else { + json_pdu.getEimPackageRequest.notifyStateChange := false; + } + if (ispresent(asn1_pdu_dec.getEimPackageRequest.stateChangeCause)) { + json_pdu.getEimPackageRequest.stateChangeCause := asn1_pdu_dec.getEimPackageRequest.stateChangeCause; + } + if (ispresent(asn1_pdu_dec.getEimPackageRequest.rPLMN)) { + json_pdu.getEimPackageRequest.rPlmn := oct2str(asn1_pdu_dec.getEimPackageRequest.rPLMN); + } + json_pdu_enc := oct2char(enc_JSON_ESipa_EsipaMessageFromIpaToEim(json_pdu)); + } else if (ispresent(asn1_pdu_dec.provideEimPackageResult)) { + json_pdu.provideEimPackageResultRequest.header.functionRequesterIdentifier := functionRequesterIdentifier; + json_pdu.provideEimPackageResultRequest.header.functionCallIdentifier := functionCallIdentifier; + if (ispresent(asn1_pdu_dec.provideEimPackageResult.eidValue)) { + json_pdu.provideEimPackageResultRequest.eidValue := oct2str(asn1_pdu_dec.provideEimPackageResult.eidValue); + } + json_pdu.provideEimPackageResultRequest.eimPackageResult := + encode_base64(enc_EimPackageResult(asn1_pdu_dec.provideEimPackageResult.eimPackageResult)); + json_pdu_enc := oct2char(enc_JSON_ESipa_EsipaMessageFromIpaToEim(json_pdu)); + } else if (ispresent(asn1_pdu_dec.handleNotificationEsipa)) { + json_pdu.handleNotification.handleNotification_pendingNotif.header.functionRequesterIdentifier := functionRequesterIdentifier; + json_pdu.handleNotification.handleNotification_pendingNotif.header.functionCallIdentifier := functionCallIdentifier; + if (ispresent(asn1_pdu_dec.handleNotificationEsipa.pendingNotification)) { + json_pdu.handleNotification.handleNotification_pendingNotif.pendingNotification := + encode_base64(enc_SGP32_PendingNotification(asn1_pdu_dec.handleNotificationEsipa.pendingNotification)) + } else if (ispresent(asn1_pdu_dec.handleNotificationEsipa.provideEimPackageResult)) { + json_pdu.handleNotification.handleNotification_prvdeEimPkgRslt.provideEimPackageResult := + encode_base64(enc_ProvideEimPackageResult(asn1_pdu_dec.handleNotificationEsipa.provideEimPackageResult)) + } + json_pdu_enc := oct2char(enc_JSON_ESipa_EsipaMessageFromIpaToEim(json_pdu)); + } else if (ispresent(asn1_pdu_dec.cancelSessionRequestEsipa)) { + json_pdu.cancelSessionRequest.header.functionRequesterIdentifier := functionRequesterIdentifier; + json_pdu.cancelSessionRequest.header.functionCallIdentifier := functionCallIdentifier; + json_pdu.cancelSessionRequest.transactionId := oct2str(asn1_pdu_dec.cancelSessionRequestEsipa.transactionId); + json_pdu.cancelSessionRequest.cancelSessionResponse := + encode_base64(enc_SGP32_CancelSessionResponse(asn1_pdu_dec.cancelSessionRequestEsipa.cancelSessionResponse)) + json_pdu_enc := oct2char(enc_JSON_ESipa_EsipaMessageFromIpaToEim(json_pdu)); + } else { + setverdict(fail, "encoder path not implemented for JSON ESipa message"); + } +} with { extension "prototype(fast)" } + +type record DecodedEimToIpaMessage_Wrap { + EsipaMessageFromEimToIpa asn1_pdu optional, + JSON_ESx_FunctionExecutionStatusCodeData err optional +} + +/* Converter function to decode a JSON formatted ESipa response to its ASN.1 ESipa record representation */ +function dec_EsipaMessageFromEimToIpa_from_JSON(in charstring json_pdu_enc, out DecodedEimToIpaMessage_Wrap wrapped_resp) { + var JSON_ESipa_EsipaMessageFromEimToIpa json_pdu; + json_pdu := dec_JSON_ESipa_EsipaMessageFromEimToIpa(char2oct(json_pdu_enc)); + + if (ispresent(json_pdu.initiateAuthenticationResponse)) { + var template octetstring transactionId := omit; + var template universal charstring matchingId := omit; + var template CtxParams1 ctxParams1 := omit; + if (not match(json_pdu.initiateAuthenticationResponse.header, ts_responseHeader)) { + setverdict(fail, "unsuccessful request"); + } + if (ispresent(json_pdu.initiateAuthenticationResponse.transactionId)) { + transactionId := str2oct(json_pdu.initiateAuthenticationResponse.transactionId); + } + if (ispresent(json_pdu.initiateAuthenticationResponse.matchingId)) { + matchingId := json_pdu.initiateAuthenticationResponse.matchingId; + } + if (ispresent(json_pdu.initiateAuthenticationResponse.ctxParams1)) { + ctxParams1 := dec_CtxParams1(decode_base64(json_pdu.initiateAuthenticationResponse.ctxParams1)); + } + wrapped_resp.asn1_pdu := valueof(ts_initiateAuthenticationResponseEsipa( + transactionId, + dec_ServerSigned1(decode_base64(json_pdu.initiateAuthenticationResponse.serverSigned1)), + decode_base64(json_pdu.initiateAuthenticationResponse.serverSignature1), + dec_SubjectKeyIdentifier(decode_base64(json_pdu.initiateAuthenticationResponse.euiccCiPKIdentifierToBeUsed)), + dec_Certificate(decode_base64(json_pdu.initiateAuthenticationResponse.serverCertificate)), + matchingId, + ctxParams1)); + } else if (ispresent(json_pdu.authenticateClientResponse)) { + var template octetstring transactionId := omit; + var template SGP32_StoreMetadataRequest profileMetaData := omit; + var template octetstring hashCc := omit; + if (not match(json_pdu.authenticateClientResponse.header, ts_responseHeader)) { + setverdict(fail, "unsuccessful request"); + } + if (ispresent(json_pdu.authenticateClientResponse.transactionId)) { + transactionId := str2oct(json_pdu.authenticateClientResponse.transactionId); + } + if (ispresent(json_pdu.authenticateClientResponse.profileMetadata)) { + profileMetaData := dec_SGP32_StoreMetadataRequest(decode_base64(json_pdu.authenticateClientResponse.profileMetadata)) + } + if (ispresent(json_pdu.authenticateClientResponse.hashCc)) { + hashCc := decode_base64(json_pdu.authenticateClientResponse.hashCc); + } + wrapped_resp.asn1_pdu := valueof(ts_authenticateClientResponseEsipa_dpe(transactionId, profileMetaData, + dec_SmdpSigned2(decode_base64(json_pdu.authenticateClientResponse.smdpSigned2)), + decode_base64(json_pdu.authenticateClientResponse.smdpSignature2), + dec_Certificate(decode_base64(json_pdu.authenticateClientResponse.smdpCertificate)), + hashCc)); + } else if (ispresent(json_pdu.getBoundProfilePackageResponse)) { + var template octetstring transactionId := omit; + if (not match(json_pdu.getBoundProfilePackageResponse.header, ts_responseHeader)) { + setverdict(fail, "unsuccessful request"); + } + if (ispresent(json_pdu.getBoundProfilePackageResponse.transactionId)) { + transactionId := str2oct(json_pdu.getBoundProfilePackageResponse.transactionId); + } + wrapped_resp.asn1_pdu := valueof(ts_getBoundProfilePackageResponseEsipa(transactionId, + dec_BoundProfilePackage(decode_base64(json_pdu.getBoundProfilePackageResponse.boundProfilePackage)))); + } else if (ispresent(json_pdu.getEimPackageResponse)) { + if (ispresent(json_pdu.getEimPackageResponse.getEimPackageResponse_euiccPkgReq)) { + if (not match(json_pdu.getEimPackageResponse.getEimPackageResponse_euiccPkgReq.header, ts_responseHeader)) { + setverdict(fail, "unsuccessful request"); + } + wrapped_resp.asn1_pdu := valueof(ts_getEimPackageResponse_euiccPkgReq( + dec_EuiccPackageRequest(decode_base64(json_pdu.getEimPackageResponse.getEimPackageResponse_euiccPkgReq.euiccPackageRequest)))); + } else if (ispresent(json_pdu.getEimPackageResponse.getEimPackageResponse_euiccDataReq)) { + if (not match(json_pdu.getEimPackageResponse.getEimPackageResponse_euiccDataReq.header, ts_responseHeader)) { + setverdict(fail, "unsuccessful request"); + } + wrapped_resp.asn1_pdu := valueof(ts_getEimPackageResponse_euiccDataReq( + dec_IpaEuiccDataRequest(decode_base64(json_pdu.getEimPackageResponse.getEimPackageResponse_euiccDataReq.ipaEuiccDataRequest)))); + } else if (ispresent(json_pdu.getEimPackageResponse.getEimPackageResponse_dnlTrigReq)) { + + if (not match(json_pdu.getEimPackageResponse.getEimPackageResponse_dnlTrigReq.header, ts_responseHeader)) { + setverdict(fail, "unsuccessful request"); + } + wrapped_resp.asn1_pdu := valueof(ts_getEimPackageResponse_dnlTrigReq( + dec_ProfileDownloadTriggerRequest(decode_base64(json_pdu.getEimPackageResponse.getEimPackageResponse_dnlTrigReq.profileDownloadTriggerRequest)))); + } else if (ispresent(json_pdu.getEimPackageResponse.getEimPackageResponse_eimPkgErr)) { + if (not match(json_pdu.getEimPackageResponse.getEimPackageResponse_eimPkgErr.header, ts_responseHeader)) { + setverdict(fail, "unsuccessful request"); + } + wrapped_resp.asn1_pdu := valueof(ts_getEimPackageResponse_eimPkgErr( + json_pdu.getEimPackageResponse.getEimPackageResponse_eimPkgErr.eimPackageError)); + } + } else if (ispresent(json_pdu.provideEimPackageResultResponse)) { + /* TODO: Map JSON error to an provideEimPackageResultError of the ASN.1 output, check if similar + * is possible for the other structs? */ + if (not match(json_pdu.provideEimPackageResultResponse.header, ts_responseHeader)) { + setverdict(fail, "unsuccessful request"); + } + if (ispresent(json_pdu.provideEimPackageResultResponse.eimAcknowledgements)) { + wrapped_resp.asn1_pdu := valueof(ts_provideEimPackageResultResponse_eimAck( + dec_EimAcknowledgements(decode_base64(json_pdu.provideEimPackageResultResponse.eimAcknowledgements)))); + } else { + wrapped_resp.asn1_pdu := valueof(ts_provideEimPackageResultResponse_empty) + } + } else if (ispresent(json_pdu.emptyResponse)) { + if (not match(json_pdu.emptyResponse.header, ts_responseHeader)) { + wrapped_resp.err := json_pdu.emptyResponse.header.functionExecutionStatus.statusCodeData; + } else { + /* Success case for empty response - initialize optional fields */ + wrapped_resp.asn1_pdu := omit; + wrapped_resp.err := omit; + } + } else { + setverdict(fail, "decoder path not implemented for JSON ESipa message"); + } +} with { extension "prototype(fast)" } + +/* Converter function to encode an ASN.1 ESipa response record to its JSON formatted ESipa representation */ +function enc_EsipaMessageFromEimToIpa_to_JSON(in EsipaMessageFromEimToIpa asn1_pdu_dec, out charstring json_pdu_enc) { + var JSON_ESipa_EsipaMessageFromEimToIpa json_pdu; + + if (ispresent(asn1_pdu_dec.initiateAuthenticationResponseEsipa)) { + json_pdu.initiateAuthenticationResponse.header.functionExecutionStatus.status := "Executed-Success"; + if (ispresent(asn1_pdu_dec.initiateAuthenticationResponseEsipa.initiateAuthenticationOkEsipa.transactionId)) { + json_pdu.initiateAuthenticationResponse.transactionId := + oct2str(asn1_pdu_dec.initiateAuthenticationResponseEsipa.initiateAuthenticationOkEsipa.transactionId); + } + json_pdu.initiateAuthenticationResponse.serverSigned1 := + encode_base64(enc_ServerSigned1(asn1_pdu_dec.initiateAuthenticationResponseEsipa.initiateAuthenticationOkEsipa.serverSigned1)); + json_pdu.initiateAuthenticationResponse.serverSignature1 := + encode_base64(asn1_pdu_dec.initiateAuthenticationResponseEsipa.initiateAuthenticationOkEsipa.serverSignature1); + json_pdu.initiateAuthenticationResponse.euiccCiPKIdentifierToBeUsed := + encode_base64(enc_SubjectKeyIdentifier(asn1_pdu_dec.initiateAuthenticationResponseEsipa.initiateAuthenticationOkEsipa.euiccCiPKIdentifierToBeUsed)); + json_pdu.initiateAuthenticationResponse.serverCertificate := + encode_base64(enc_Certificate(asn1_pdu_dec.initiateAuthenticationResponseEsipa.initiateAuthenticationOkEsipa.serverCertificate)); + if (ispresent(asn1_pdu_dec.initiateAuthenticationResponseEsipa.initiateAuthenticationOkEsipa.matchingId)) { + json_pdu.initiateAuthenticationResponse.matchingId := + asn1_pdu_dec.initiateAuthenticationResponseEsipa.initiateAuthenticationOkEsipa.matchingId; + } + if (ispresent(asn1_pdu_dec.initiateAuthenticationResponseEsipa.initiateAuthenticationOkEsipa.ctxParams1)) { + json_pdu.initiateAuthenticationResponse.ctxParams1 := + encode_base64(enc_CtxParams1(asn1_pdu_dec.initiateAuthenticationResponseEsipa.initiateAuthenticationOkEsipa.ctxParams1)); + } + json_pdu_enc := oct2char(enc_JSON_ESipa_EsipaMessageFromEimToIpa(json_pdu)); + } else if (ispresent(asn1_pdu_dec.authenticateClientResponseEsipa)) { + json_pdu.authenticateClientResponse.header.functionExecutionStatus.status := "Executed-Success"; + if (ispresent(asn1_pdu_dec.authenticateClientResponseEsipa.authenticateClientOkDPEsipa.transactionId)) { + json_pdu.authenticateClientResponse.transactionId := + oct2str(asn1_pdu_dec.authenticateClientResponseEsipa.authenticateClientOkDPEsipa.transactionId); + } + if (ispresent(asn1_pdu_dec.authenticateClientResponseEsipa.authenticateClientOkDPEsipa.profileMetaData)) { + json_pdu.authenticateClientResponse.profileMetadata := + encode_base64(enc_SGP32_StoreMetadataRequest(asn1_pdu_dec.authenticateClientResponseEsipa.authenticateClientOkDPEsipa.profileMetaData)); + } + json_pdu.authenticateClientResponse.smdpSigned2 := + encode_base64(enc_SmdpSigned2(asn1_pdu_dec.authenticateClientResponseEsipa.authenticateClientOkDPEsipa.smdpSigned2)); + json_pdu.authenticateClientResponse.smdpSignature2 := + encode_base64(asn1_pdu_dec.authenticateClientResponseEsipa.authenticateClientOkDPEsipa.smdpSignature2); + json_pdu.authenticateClientResponse.smdpCertificate := + encode_base64(enc_Certificate(asn1_pdu_dec.authenticateClientResponseEsipa.authenticateClientOkDPEsipa.smdpCertificate)); + if (ispresent(asn1_pdu_dec.authenticateClientResponseEsipa.authenticateClientOkDPEsipa.hashCc)) { + json_pdu.authenticateClientResponse.hashCc := + encode_base64(asn1_pdu_dec.authenticateClientResponseEsipa.authenticateClientOkDPEsipa.hashCc); + } + json_pdu_enc := oct2char(enc_JSON_ESipa_EsipaMessageFromEimToIpa(json_pdu)); + } else if (ispresent(asn1_pdu_dec.getBoundProfilePackageResponseEsipa)) { + json_pdu.getBoundProfilePackageResponse.header.functionExecutionStatus.status := "Executed-Success"; + if (ispresent(asn1_pdu_dec.getBoundProfilePackageResponseEsipa.getBoundProfilePackageOkEsipa.transactionId)) { + json_pdu.getBoundProfilePackageResponse.transactionId := + oct2str(asn1_pdu_dec.getBoundProfilePackageResponseEsipa.getBoundProfilePackageOkEsipa.transactionId); + } + json_pdu.getBoundProfilePackageResponse.boundProfilePackage := + encode_base64(enc_BoundProfilePackage(asn1_pdu_dec.getBoundProfilePackageResponseEsipa.getBoundProfilePackageOkEsipa.boundProfilePackage)); + json_pdu_enc := oct2char(enc_JSON_ESipa_EsipaMessageFromEimToIpa(json_pdu)); + } else if (ispresent(asn1_pdu_dec.getEimPackageResponse)) { + if (ispresent(asn1_pdu_dec.getEimPackageResponse.euiccPackageRequest)) { + json_pdu.getEimPackageResponse.getEimPackageResponse_euiccPkgReq.header.functionExecutionStatus.status := "Executed-Success"; + json_pdu.getEimPackageResponse.getEimPackageResponse_euiccPkgReq.euiccPackageRequest := + encode_base64(enc_EuiccPackageRequest(asn1_pdu_dec.getEimPackageResponse.euiccPackageRequest)); + } else if (ispresent(asn1_pdu_dec.getEimPackageResponse.ipaEuiccDataRequest)) { + json_pdu.getEimPackageResponse.getEimPackageResponse_euiccDataReq.header.functionExecutionStatus.status := "Executed-Success"; + json_pdu.getEimPackageResponse.getEimPackageResponse_euiccDataReq.ipaEuiccDataRequest := + encode_base64(enc_IpaEuiccDataRequest(asn1_pdu_dec.getEimPackageResponse.ipaEuiccDataRequest)); + } else if (ispresent(asn1_pdu_dec.getEimPackageResponse.profileDownloadTriggerRequest)) { + json_pdu.getEimPackageResponse.getEimPackageResponse_dnlTrigReq.header.functionExecutionStatus.status := "Executed-Success"; + json_pdu.getEimPackageResponse.getEimPackageResponse_dnlTrigReq.profileDownloadTriggerRequest := + encode_base64(enc_ProfileDownloadTriggerRequest(asn1_pdu_dec.getEimPackageResponse.profileDownloadTriggerRequest)); + } else if (ispresent(asn1_pdu_dec.getEimPackageResponse.eimPackageError)) { + json_pdu.getEimPackageResponse.getEimPackageResponse_eimPkgErr.header.functionExecutionStatus.status := "Executed-Success"; + json_pdu.getEimPackageResponse.getEimPackageResponse_eimPkgErr.eimPackageError := + asn1_pdu_dec.getEimPackageResponse.eimPackageError; + } + json_pdu_enc := oct2char(enc_JSON_ESipa_EsipaMessageFromEimToIpa(json_pdu)); + } else if (ispresent(asn1_pdu_dec.provideEimPackageResultResponse)) { + json_pdu.provideEimPackageResultResponse.header.functionExecutionStatus.status := "Executed-Success"; + if (ispresent(asn1_pdu_dec.provideEimPackageResultResponse.eimAcknowledgements)) { + json_pdu.provideEimPackageResultResponse.eimAcknowledgements := + encode_base64(enc_EimAcknowledgements(asn1_pdu_dec.provideEimPackageResultResponse.eimAcknowledgements)); + } + json_pdu_enc := oct2char(enc_JSON_ESipa_EsipaMessageFromEimToIpa(json_pdu)); + } else if (ispresent(asn1_pdu_dec.cancelSessionResponseEsipa)) { + /* This message has no JSON body, see also GSMA SGP.32, section 6.4.1.8 */ + json_pdu.emptyResponse.header.functionExecutionStatus.status := "Executed-Success"; + json_pdu_enc := oct2char(enc_JSON_ESipa_EsipaMessageFromEimToIpa(json_pdu)); + } else { + json_pdu.emptyResponse.header.functionExecutionStatus.status := "Executed-Success"; + json_pdu_enc := oct2char(enc_JSON_ESipa_EsipaMessageFromEimToIpa(json_pdu)); + } +} with { extension "prototype(fast)" } + +} with { + encode "JSON"; +}