laforge submitted this change.

View Change

Approvals: Jenkins Builder: Verified jolly: Looks good to me, but someone else must approve laforge: Looks good to me, approved
SGP32Definitions: add JSON specific variant of SGP32-CancelSessionResponse

When the CancelSessionResponse is referenced in CancelSessionRequestEsipa,
there is not context specific tag set. It is not entirely clear if this
is a bug in the ASN.1 specification or if it is by a deliberate design
choice. Nevertheless, most ASN.1 compilers (asn1c, TTCN3 asn1_compiler)
will not apply the context specific tag. Which means that the
CancelSessionResponse will be tagged with 0xA1 (1) instead 0xBF41 (65).

Example (asn1c/asn1_compiler):
$ ./contrib/unber.py --hex BF41248003ABCDEFA11DA01B30118003ABCDEF8107678112010201018201055F37051234567890
bf41 l=36
80 l=3 abcdef
a1 l=29
a0 l=27
30 l=17
80 l=3 abcdef
81 l=7 67811201020101
82 l=1 05
5f37 l=5 1234567890

However, Erlang's asn1ct compiler behaves differently. It will apply the
application specific tag from the SGP32-CancelSessionResponse as context
specific tag. Which means it will expect to see 0xBF41 (65) and not
0xA1 (1) when decoding the ASN.1 object.

The problem was known before and has been fixed by removing the tag
from the SGP32-CancelSessionResponse definition. Unfortunately this
workaround is only valid for the ASN.1 ESipa bindings because when
building the JSON structs for the JSON ESipa bindings we have to access
SGP32-CancelSessionResponse directly. And since the type definition
has normally has the application secific tag. The decoder on the other
end will expect to mee a 0xBF41 tag at the beginning of the encoded
string.

This eventually means that we have to introduce a tagged variant of
SGP32-CancelSessionResponse that we will use for the JSON encoding.

Change-Id: I566571778d2433bd87a46276e81d9d526ae97325
Related: SYS#8100
---
M asn1/SGP32Definitions.asn1
M src/esipa_json_handler.erl
2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/asn1/SGP32Definitions.asn1 b/asn1/SGP32Definitions.asn1
index 5bae2c7..4fbb495 100644
--- a/asn1/SGP32Definitions.asn1
+++ b/asn1/SGP32Definitions.asn1
@@ -701,6 +701,13 @@
cancelSessionResponseError INTEGER {invalidTransactionId(5), undefinedError(127)},
compactCancelSessionResponseOk CompactCancelSessionResponseOk
}
+-- workaround for erlang asn1ct: add a JSON specific variant of the SGP32-CancelSessionResponse to ensure application specific tag [65]
+SGP32-JSON-CancelSessionResponse ::= [65] CHOICE { -- Tag 'BF41'
+ cancelSessionResponseOk CancelSessionResponseOk,
+ cancelSessionResponseError INTEGER {invalidTransactionId(5), undefinedError(127)},
+ compactCancelSessionResponseOk CompactCancelSessionResponseOk
+}
+
CompactCancelSessionResponseOk ::= SEQUENCE {
compactEuiccCancelSessionSigned CompactEuiccCancelSessionSigned, -- Compact version of euiccCancelSessionSigned
euiccCancelSessionSignature [APPLICATION 55] OCTET STRING -- tag 5F37 signature on euiccCancelSessionSigned
diff --git a/src/esipa_json_handler.erl b/src/esipa_json_handler.erl
index a0911b5..f5fc3e3 100644
--- a/src/esipa_json_handler.erl
+++ b/src/esipa_json_handler.erl
@@ -390,7 +390,7 @@
{cancelSessionResponse,
from_base64asn1(
'SGP32Definitions',
- 'SGP32-CancelSessionResponse',
+ 'SGP32-JSON-CancelSessionResponse',
maps:get(<<"cancelSessionResponse">>, EsipaReq)
)}
]),

To view, visit change 43177. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: merged
Gerrit-Project: onomondo-eim
Gerrit-Branch: master
Gerrit-Change-Id: I566571778d2433bd87a46276e81d9d526ae97325
Gerrit-Change-Number: 43177
Gerrit-PatchSet: 16
Gerrit-Owner: dexter <pmaier@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: jolly <andreas@eversberg.eu>
Gerrit-Reviewer: laforge <laforge@osmocom.org>