My ASN.1 Notes: Difference between revisions
Initial creation of page |
m added sections |
||
| (10 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
== Resources == | == Resources == | ||
[http://www.oss.com/ | [http://www.oss.com/ OSS Nokalva] Note: I have used OSS Nokalva's ASN.1 Studio and really enjoyed it (UI could use a little love). | ||
[https://www.obj-sys.com/ Objective Sytems] | [https://www.obj-sys.com/ Objective Sytems] | ||
| Line 6: | Line 6: | ||
[http://powerasn.ncottin.net/ Power ASN] | [http://powerasn.ncottin.net/ Power ASN] | ||
ETSI [https://portal.etsi.org/PNNS/GenericAllocation/ASN1ObjectIdentifiers.aspx ASN.1 Object Identifiers Tree] | |||
[https://cs.fit.edu/code/projects/cse2410spring2014_team4/repository/revisions/master/entry/asn1/gsm_map/MAP-CommonDataTypes.asn Mobile Application Part (MAP)] CommonDataTypes.asn | |||
=== Python ASN.1 Resources === | |||
[https://github.com/P1sec/pycrate Pycrate] is a french word for qualifying bad wine. The present software library has nothing to do with bad wine, it is simply a Python library for manipulating various digital formats in an easy way. It is the glorious successor of libmich, which was started 8 years ago and served well. | |||
It provides basically a runtime for encoding and decoding data structures, including CSN.1 and ASN.1. Additionally, it features a 3G and LTE mobile core network. | |||
[https://github.com/etingof/pyasn1 pyasn1] is a free and open source implementation of ASN.1 types and codecs as a Python package. It has been first written to support particular protocol (SNMP) but then generalized to be suitable for a wide range of protocols based on ASN.1 specification. | |||
[https://github.com/kimgr/asn1ate asn1ate] is a Python library for translating ASN.1 into other forms. It is intended for code generation from formal ASN.1 definitions, and a code generator for pyasn1 is included. | |||
[https://python-asn1.readthedocs.io/en/latest/readme.html Python-ASN1] is a simple ASN.1 encoder and decoder for Python 2.6+ and 3.3+. | |||
[https://blog.getreu.net/projects/asn1-tiny-decoder/#_the_asn_1_decoder asn1tinydecoder.py] is a simple and fast ASN.1 decoder without external libraries designed to parse large files. | |||
== Nice examples == | |||
[https://stackoverflow.com/questions/24166556/untagged-choice-in-asn-1 Example explaining CHOICE tagging] | |||
[https://stackoverflow.com/questions/3296761/i-need-an-example-to-understand-implicit-tagging-in-asn-1/30608283#30608283 Example to understand IMPLICIT tagging] | |||
== TBCD == | |||
[https://www.obj-sys.com/docs/asn2txt/v23x/HTML/ch03s03.html Telephony Binary-Coded Decimal] strings are not part of the ASN.1 standard, but their use is prevalent in many telephony-related ASN.1 specifications. | |||
Conversion of these types into standard numeric text strings is supported by Objective Systems software. | |||
In general, BCD strings pack two numeric digits into a single byte value by using a four-bit nibble to hold each digit. By convention, the digits are reversed in TBCD strings, but there are no official standards for this encoding. | |||
== My Notes == | == My Notes == | ||
=== Source: [https://www.etsi.org/standards ETSI TS 101 671 V3.15.1 (2018-06)] === | |||
<pre> | |||
LawfulInterceptionIdentifier ::= OCTET STRING (SIZE (1..25)) | |||
-- It is recommended to use ASCII characters in "a"…"z", "A"…"Z", "-", "_", ".", and "0"…"9". | |||
-- For sub-address option only "0"..."9" shall be used. | |||
National-Parameters ::= SET SIZE (1..40) OF OCTET STRING (SIZE (1..256)) | |||
-- Content defined by national law. | |||
Network-Identifier ::= SEQUENCE | |||
{ | |||
operator-Identifier [0] OCTET STRING (SIZE (1..5)), | |||
-- It is a notification of the NWO/AP/SvP in ASCII- characters. | |||
-- For sub-address option only "0"..."9" shall be used. | |||
network-Element-Identifier [1] Network-Element-Identifier OPTIONAL, | |||
... | |||
} | |||
Network-Element-Identifier ::= CHOICE | |||
{ | |||
e164-Format [1] OCTET STRING (SIZE (1..25)), | |||
-- E164 address of the node in international format. Coded in the same format as the | |||
-- calling party number parameter of the ISUP (parameter part: EN 300 356 [5]). | |||
x25-Format [2] OCTET STRING (SIZE (1..25)), | |||
-- X25 address | |||
iP-Format [3] OCTET STRING (SIZE (1..25)), | |||
-- IP address | |||
dNS-Format [4] OCTET STRING (SIZE (1..25)), | |||
-- DNS address | |||
..., | |||
iP-Address [5] IPAddress | |||
} | |||
TimeStamp ::= CHOICE | |||
{ | |||
localTime [0] LocalTimeStamp, | |||
utcTime [1] UTCTime | |||
} | |||
LocalTimeStamp ::= SEQUENCE | |||
{ | |||
generalizedTime [0] GeneralizedTime, | |||
winterSummerIndication [1] ENUMERATED | |||
{ | |||
notProvided(0), | |||
winterTime(1), | |||
summerTime(2), | |||
... | |||
} | |||
}</pre> | |||
=== ETSI TS 133 108 v15.7.0 (2020-01) === | |||
<pre>CC-PDU ::= SEQUENCE | |||
{ | |||
uLIC-header [1] ULIC-header, | |||
payload [2] OCTET STRING | |||
} | |||
ULIC-header ::= SEQUENCE | |||
{ | |||
hi3DomainId [0] OBJECT IDENTIFIER, | |||
lIID [2] LawfulInterceptionIdentifier OPTIONAL, | |||
correlation-Number [3] EPSCorrelationNumber, | |||
timeStamp [4] TimeStamp OPTIONAL, | |||
sequence-number [5] INTEGER (0..65535), | |||
t-PDU-direction [6] TPDU-direction, | |||
..., | |||
national-HI3-ASN1parameters [7] National-HI3-ASN1parameters OPTIONAL, -- encoded per national requirements | |||
ice-type [8] ICE-type OPTIONAL | |||
} | |||
TPDU-direction ::= ENUMERATED | |||
{ | |||
from-target (1), | |||
to-target (2), | |||
unknown (3) | |||
} | |||
National-HI3-ASN1parameters ::= SEQUENCE | |||
{ | |||
countryCode [1] PrintableString (SIZE (2)), | |||
... | |||
} | |||
ICE-type ::= ENUMERATED | |||
{ | |||
sgsn (1), | |||
ggsn (2), | |||
..., | |||
s-GW (3), | |||
pDN-GW (4), | |||
colocated-SAE-GWs (5) , | |||
ePDG (6) | |||
}</pre> | |||
== Resources == | |||
[https://www.oss.com/asn1/resources/asn1-made-simple/types.html List of common ASN.1 Types] which includes UTCTime and GeneralizedTime in TimeStamp example above. | |||
[[Computing|Back to Computing]] | <center>[[Computing|Back to Computing]]</center> | ||
Latest revision as of 12:11, 4 September 2020
Resources
OSS Nokalva Note: I have used OSS Nokalva's ASN.1 Studio and really enjoyed it (UI could use a little love).
ETSI ASN.1 Object Identifiers Tree
Mobile Application Part (MAP) CommonDataTypes.asn
Python ASN.1 Resources
Pycrate is a french word for qualifying bad wine. The present software library has nothing to do with bad wine, it is simply a Python library for manipulating various digital formats in an easy way. It is the glorious successor of libmich, which was started 8 years ago and served well.
It provides basically a runtime for encoding and decoding data structures, including CSN.1 and ASN.1. Additionally, it features a 3G and LTE mobile core network.
pyasn1 is a free and open source implementation of ASN.1 types and codecs as a Python package. It has been first written to support particular protocol (SNMP) but then generalized to be suitable for a wide range of protocols based on ASN.1 specification.
asn1ate is a Python library for translating ASN.1 into other forms. It is intended for code generation from formal ASN.1 definitions, and a code generator for pyasn1 is included.
Python-ASN1 is a simple ASN.1 encoder and decoder for Python 2.6+ and 3.3+.
asn1tinydecoder.py is a simple and fast ASN.1 decoder without external libraries designed to parse large files.
Nice examples
Example explaining CHOICE tagging
Example to understand IMPLICIT tagging
TBCD
Telephony Binary-Coded Decimal strings are not part of the ASN.1 standard, but their use is prevalent in many telephony-related ASN.1 specifications.
Conversion of these types into standard numeric text strings is supported by Objective Systems software.
In general, BCD strings pack two numeric digits into a single byte value by using a four-bit nibble to hold each digit. By convention, the digits are reversed in TBCD strings, but there are no official standards for this encoding.
My Notes
Source: ETSI TS 101 671 V3.15.1 (2018-06)
LawfulInterceptionIdentifier ::= OCTET STRING (SIZE (1..25))
-- It is recommended to use ASCII characters in "a"…"z", "A"…"Z", "-", "_", ".", and "0"…"9".
-- For sub-address option only "0"..."9" shall be used.
National-Parameters ::= SET SIZE (1..40) OF OCTET STRING (SIZE (1..256))
-- Content defined by national law.
Network-Identifier ::= SEQUENCE
{
operator-Identifier [0] OCTET STRING (SIZE (1..5)),
-- It is a notification of the NWO/AP/SvP in ASCII- characters.
-- For sub-address option only "0"..."9" shall be used.
network-Element-Identifier [1] Network-Element-Identifier OPTIONAL,
...
}
Network-Element-Identifier ::= CHOICE
{
e164-Format [1] OCTET STRING (SIZE (1..25)),
-- E164 address of the node in international format. Coded in the same format as the
-- calling party number parameter of the ISUP (parameter part: EN 300 356 [5]).
x25-Format [2] OCTET STRING (SIZE (1..25)),
-- X25 address
iP-Format [3] OCTET STRING (SIZE (1..25)),
-- IP address
dNS-Format [4] OCTET STRING (SIZE (1..25)),
-- DNS address
...,
iP-Address [5] IPAddress
}
TimeStamp ::= CHOICE
{
localTime [0] LocalTimeStamp,
utcTime [1] UTCTime
}
LocalTimeStamp ::= SEQUENCE
{
generalizedTime [0] GeneralizedTime,
winterSummerIndication [1] ENUMERATED
{
notProvided(0),
winterTime(1),
summerTime(2),
...
}
}
ETSI TS 133 108 v15.7.0 (2020-01)
CC-PDU ::= SEQUENCE
{
uLIC-header [1] ULIC-header,
payload [2] OCTET STRING
}
ULIC-header ::= SEQUENCE
{
hi3DomainId [0] OBJECT IDENTIFIER,
lIID [2] LawfulInterceptionIdentifier OPTIONAL,
correlation-Number [3] EPSCorrelationNumber,
timeStamp [4] TimeStamp OPTIONAL,
sequence-number [5] INTEGER (0..65535),
t-PDU-direction [6] TPDU-direction,
...,
national-HI3-ASN1parameters [7] National-HI3-ASN1parameters OPTIONAL, -- encoded per national requirements
ice-type [8] ICE-type OPTIONAL
}
TPDU-direction ::= ENUMERATED
{
from-target (1),
to-target (2),
unknown (3)
}
National-HI3-ASN1parameters ::= SEQUENCE
{
countryCode [1] PrintableString (SIZE (2)),
...
}
ICE-type ::= ENUMERATED
{
sgsn (1),
ggsn (2),
...,
s-GW (3),
pDN-GW (4),
colocated-SAE-GWs (5) ,
ePDG (6)
}
Resources
List of common ASN.1 Types which includes UTCTime and GeneralizedTime in TimeStamp example above.