|
|
# How to use the pycrate ASN.1 runtime
|
|
|
In this section, we will see how to use the ASN.1 runtime with already compiled
|
|
|
specifications from the
|
|
|
[pycrate_asn1dir/](https://github.com/ANSSI-FR/pycrate/blob/master/pycrate_asn1dir/)
|
|
|
[pycrate_asn1dir/](https://github.com/p1sec/pycrate/blob/master/pycrate_asn1dir/)
|
|
|
directory, with basic examples.
|
|
|
|
|
|
|
... | ... | @@ -19,7 +19,7 @@ The ASN.1 runtime is then in charge, together with the compiled specification, t |
|
|
encode values for those ASN.1 objects to buffers, and decode buffers to values.
|
|
|
|
|
|
The pycrate ASN.1 runtime, as defined in
|
|
|
[pycrate_asn1rt](https://github.com/ANSSI-FR/pycrate/blob/master/pycrate_asn1rt/),
|
|
|
[pycrate_asn1rt](https://github.com/p1sec/pycrate/blob/master/pycrate_asn1rt/),
|
|
|
currently implements the following encoders / decoders:
|
|
|
- the ASN.1 textual syntax, with *to_asn1()* / *from_asn1()* methods
|
|
|
- the unaligned Packed Encoding Rules (UPER), with *to_uper()* / *from_uper()* methods
|
... | ... | @@ -352,15 +352,15 @@ Pycrate provides two different modules to handle both protocols: |
|
|
- the UMTS RRC protocol is defined in the
|
|
|
[TS 25.331](http://www.3gpp.org/DynaReport/25331.htm) 3GPP specification;
|
|
|
the ASN.1 definition is available in the directory
|
|
|
[pycrate_asn1dir/3GPP_UTRAN_RRC_25331/](https://github.com/ANSSI-FR/pycrate/blob/master/pycrate_asn1dir/3GPP_UTRAN_RRC_25331/)
|
|
|
[pycrate_asn1dir/3GPP_UTRAN_RRC_25331/](https://github.com/p1sec/pycrate/blob/master/pycrate_asn1dir/3GPP_UTRAN_RRC_25331/)
|
|
|
and the corresponding Python modules are compiled in the file
|
|
|
[pycrate_asn1dir/RRC3G.py](https://github.com/ANSSI-FR/pycrate/blob/master/pycrate_asn1dir/RRC3G.py).
|
|
|
[pycrate_asn1dir/RRC3G.py](https://github.com/p1sec/pycrate/blob/master/pycrate_asn1dir/RRC3G.py).
|
|
|
- the LTE RRC protocol is defined in the
|
|
|
[TS 36.331](http://www.3gpp.org/DynaReport/36331.htm) 3GPP specification;
|
|
|
the ASN.1 definition is available in the directory
|
|
|
[pycrate_asn1dir/3GPP_EUTRAN_RRC_36331/](https://github.com/ANSSI-FR/pycrate/blob/master/pycrate_asn1dir/3GPP_EUTRAN_RRC_36331/)
|
|
|
[pycrate_asn1dir/3GPP_EUTRAN_RRC_36331/](https://github.com/p1sec/pycrate/blob/master/pycrate_asn1dir/3GPP_EUTRAN_RRC_36331/)
|
|
|
and the corresponding Python modules are compiled in the file
|
|
|
[pycrate_asn1dir/RRCLTE.py](https://github.com/ANSSI-FR/pycrate/blob/master/pycrate_asn1dir/RRCLTE.py).
|
|
|
[pycrate_asn1dir/RRCLTE.py](https://github.com/p1sec/pycrate/blob/master/pycrate_asn1dir/RRCLTE.py).
|
|
|
|
|
|
Both specifications provided are from the 3GPP release 13 (0xd), however, it is possible
|
|
|
to easily upgrade or downgrade them thanks to the *extract.py* scripts provided in the ASN.1 definition
|
... | ... | @@ -698,9 +698,9 @@ to drive mobile phones connecting to the 3G radio access network, from the core |
|
|
stand-point. The protocol is specified by the 3GPP standard
|
|
|
[TS 25.413](http://www.3gpp.org/DynaReport/25413.htm), the ASN.1 definition is available
|
|
|
in the directory
|
|
|
[pycrate_asn1dir/3GPP_UTRAN_RANAP_25413/](https://github.com/ANSSI-FR/pycrate/blob/master/pycrate_asn1dir/3GPP_UTRAN_RANAP_25413/)
|
|
|
[pycrate_asn1dir/3GPP_UTRAN_RANAP_25413/](https://github.com/p1sec/pycrate/blob/master/pycrate_asn1dir/3GPP_UTRAN_RANAP_25413/)
|
|
|
and the corresponding Python modules are in the compiled file
|
|
|
[pycrate_asn1dir/RANAP.py](https://github.com/ANSSI-FR/pycrate/blob/master/pycrate_asn1dir/RANAP.py).
|
|
|
[pycrate_asn1dir/RANAP.py](https://github.com/p1sec/pycrate/blob/master/pycrate_asn1dir/RANAP.py).
|
|
|
|
|
|
Contrary to RRC protocols, there is a single RANAP ASN.1 object to encode and decode all
|
|
|
the messages that can be exchanged with it: the *RANAP-PDU* defined in the *RANAP-PDU-Descriptions*
|
... | ... | @@ -963,12 +963,12 @@ And here is an example on how to encode an uplink RANAP Direct Transfer message: |
|
|
|
|
|
In order to go further, we can read the source code of the ongoing effort to build a 3G
|
|
|
core network, available in the directory
|
|
|
[pycrate_corenet](https://github.com/ANSSI-FR/pycrate/blob/master/pycrate_corenet/).
|
|
|
[pycrate_corenet](https://github.com/p1sec/pycrate/blob/master/pycrate_corenet/).
|
|
|
There is a generic Python module *LinkSigProc* to help with the procedures defined
|
|
|
in this kind of RPC-like protocol:
|
|
|
[pycrate_corenet/ProcProto.py](https://github.com/ANSSI-FR/pycrate/blob/master/pycrate_corenet/ProcProto.py),
|
|
|
[pycrate_corenet/ProcProto.py](https://github.com/p1sec/pycrate/blob/master/pycrate_corenet/ProcProto.py),
|
|
|
and some initial RANAP procedures defined here:
|
|
|
[pycrate_corenet/ProcCNRanap.py](https://github.com/ANSSI-FR/pycrate/blob/master/pycrate_corenet/ProcCNRanap.py).
|
|
|
[pycrate_corenet/ProcCNRanap.py](https://github.com/p1sec/pycrate/blob/master/pycrate_corenet/ProcCNRanap.py).
|
|
|
|
|
|
### S1AP
|
|
|
S1AP is the signaling protocol used between the MME in an LTE core network (also called an EPC)
|
... | ... | @@ -977,9 +977,9 @@ and also mobile phones connecting to the 4G radio access network, from the core |
|
|
The protocol is specified by the 3GPP standard
|
|
|
[TS 36.413](http://www.3gpp.org/DynaReport/36413.htm), the ASN.1 definition is available
|
|
|
in the directory
|
|
|
[pycrate_asn1dir/3GPP_EUTRAN_S1AP_36413/](https://github.com/ANSSI-FR/pycrate/blob/master/pycrate_asn1dir/3GPP_EUTRAN_S1AP_36413/)
|
|
|
[pycrate_asn1dir/3GPP_EUTRAN_S1AP_36413/](https://github.com/p1sec/pycrate/blob/master/pycrate_asn1dir/3GPP_EUTRAN_S1AP_36413/)
|
|
|
and the corresponding Python modules are in the file
|
|
|
[pycrate_asn1dir/S1AP.py](https://github.com/ANSSI-FR/pycrate/blob/master/pycrate_asn1dir/S1AP.py).
|
|
|
[pycrate_asn1dir/S1AP.py](https://github.com/p1sec/pycrate/blob/master/pycrate_asn1dir/S1AP.py).
|
|
|
|
|
|
S1AP and X2AP protocols are very similar to the existing 3G protocols (like RANAP).
|
|
|
There is a single top-level object to encode and decode all protocol's messages:
|
... | ... | @@ -1125,36 +1125,36 @@ is from 1997. |
|
|
The MAP specification can be found in the 3GPP standard
|
|
|
[TS 29.002](http://www.3gpp.org/DynaReport/29002.htm), the ASN.1 definition is available
|
|
|
in the directory
|
|
|
[pycrate_asn1dir/3GPP_MAP_29002/](https://github.com/ANSSI-FR/pycrate/blob/master/pycrate_asn1dir/3GPP_MAP_29002/)
|
|
|
[pycrate_asn1dir/3GPP_MAP_29002/](https://github.com/p1sec/pycrate/blob/master/pycrate_asn1dir/3GPP_MAP_29002/)
|
|
|
and the corresponding Python modules are in the compiled file
|
|
|
[pycrate_asn1dir/MAP.py](https://github.com/ANSSI-FR/pycrate/blob/master/pycrate_asn1dir/MAP.py).
|
|
|
[pycrate_asn1dir/MAP.py](https://github.com/p1sec/pycrate/blob/master/pycrate_asn1dir/MAP.py).
|
|
|
|
|
|
The CAP specification can be found in the 3GPP standard
|
|
|
[TS 29.078](http://www.3gpp.org/DynaReport/29078.htm), the ASN.1 definition is available
|
|
|
in the directory
|
|
|
[pycrate_asn1dir/3GPP_CAP_29078/](https://github.com/ANSSI-FR/pycrate/blob/master/pycrate_asn1dir/3GPP_CAP_29078/)
|
|
|
[pycrate_asn1dir/3GPP_CAP_29078/](https://github.com/p1sec/pycrate/blob/master/pycrate_asn1dir/3GPP_CAP_29078/)
|
|
|
and the corresponding Python modules are in the compiled file
|
|
|
[pycrate_asn1dir/CAP.py](https://github.com/ANSSI-FR/pycrate/blob/master/pycrate_asn1dir/CAP.py).
|
|
|
[pycrate_asn1dir/CAP.py](https://github.com/p1sec/pycrate/blob/master/pycrate_asn1dir/CAP.py).
|
|
|
|
|
|
The TCAP specification can be found in the ITU-T standard
|
|
|
[Q.773](http://www.itu.int/rec/T-REC-Q.773-199706-I), the ASN.1 definition is available
|
|
|
in the directory
|
|
|
[pycrate_asn1dir/ITUT_Q773_1997-06/](https://github.com/ANSSI-FR/pycrate/blob/master/pycrate_asn1dir/ITUT_Q773_1997-06/)
|
|
|
[pycrate_asn1dir/ITUT_Q773_1997-06/](https://github.com/p1sec/pycrate/blob/master/pycrate_asn1dir/ITUT_Q773_1997-06/)
|
|
|
and the corresponding Python modules are in the compiled file
|
|
|
[pycrate_asn1dir/TCAP.py](https://github.com/ANSSI-FR/pycrate/blob/master/pycrate_asn1dir/TCAP.py).
|
|
|
[pycrate_asn1dir/TCAP.py](https://github.com/p1sec/pycrate/blob/master/pycrate_asn1dir/TCAP.py).
|
|
|
|
|
|
The *TCMessage* object which corresponds to the structure of a TCAP message transporting MAP or CAP data
|
|
|
needs actually to be parameterized with higher level protocol definition. Moreover, the EXTERNAL object
|
|
|
used within the TCAP specification is from an older ASN.1 standard (the one from 1988)
|
|
|
and does not correspond to the EXTERNAL structure defined in the pycrate ASN.1 runtime.
|
|
|
For this reasons, two custom modules have been created:
|
|
|
- [pycrate_asn1dir/Pycrate-TCAP-MAP](https://github.com/ANSSI-FR/pycrate/blob/master/pycrate_asn1dir/Pycrate-TCAP-MAP/)
|
|
|
- [pycrate_asn1dir/Pycrate-TCAP-MAP](https://github.com/p1sec/pycrate/blob/master/pycrate_asn1dir/Pycrate-TCAP-MAP/)
|
|
|
with the corresponding compiled file
|
|
|
[pycrate_asn1dir/TCAP_MAP.py](https://github.com/ANSSI-FR/pycrate/blob/master/pycrate_asn1dir/TCAP_MAP.py)
|
|
|
[pycrate_asn1dir/TCAP_MAP.py](https://github.com/p1sec/pycrate/blob/master/pycrate_asn1dir/TCAP_MAP.py)
|
|
|
and the top-level object *TCAP-MAP-Message*
|
|
|
- [pycrate_asn1dir/Pycrate-TCAP-CAP](https://github.com/ANSSI-FR/pycrate/blob/master/pycrate_asn1dir/Pycrate-TCAP-CAP/)
|
|
|
- [pycrate_asn1dir/Pycrate-TCAP-CAP](https://github.com/p1sec/pycrate/blob/master/pycrate_asn1dir/Pycrate-TCAP-CAP/)
|
|
|
with the corresponding compiled file
|
|
|
[pycrate_asn1dir/TCAP_CAP.py](https://github.com/ANSSI-FR/pycrate/blob/master/pycrate_asn1dir/TCAP_CAP.py);
|
|
|
[pycrate_asn1dir/TCAP_CAP.py](https://github.com/p1sec/pycrate/blob/master/pycrate_asn1dir/TCAP_CAP.py);
|
|
|
CAP has multiple top-level objects defined in the *CAP-gsm* and *CAP-gprs* modules.
|
|
|
|
|
|
All those protocols are using the ASN.1 BER encoding.
|
... | ... | @@ -1358,9 +1358,9 @@ It is a set of 8 ASN.1 modules, which actually requires many other modules from |
|
|
ITU-T specifications to be compiled.
|
|
|
|
|
|
The X.509 2016 ASN.1 module from ITU-T is available in the directory
|
|
|
[pycrate_asn1dir/ITUT_X509_2016-10](https://github.com/ANSSI-FR/pycrate/blob/master/pycrate_asn1dir/ITUT_X509_2016-10/)
|
|
|
[pycrate_asn1dir/ITUT_X509_2016-10](https://github.com/p1sec/pycrate/blob/master/pycrate_asn1dir/ITUT_X509_2016-10/)
|
|
|
and the corresponding Python module are in the compiled file
|
|
|
[pycrate_asn1dir/X509_2016.py](https://github.com/ANSSI-FR/pycrate/blob/master/pycrate_asn1dir/X509_2016.py)
|
|
|
[pycrate_asn1dir/X509_2016.py](https://github.com/p1sec/pycrate/blob/master/pycrate_asn1dir/X509_2016.py)
|
|
|
Few errors have been corrected compared to the archive of ASN.1 files provided by the
|
|
|
ITU-T web site for the specification to compile correctly.
|
|
|
|
... | ... | |