import asn1tools from compile_asn import * from array import array # this is a sample record of a TS 133 128 "IRIPayload" embedded inside of a PS-PDU # it seems, that the python asn1tools doesnt support the "EXTENSIBILITY IMPLIED" feature that # is used in the 33-128.asn definition - so this record is not decoded when using version 16 of 33-128.asn unless you manually modify the schema. # asn1c seems to have the same issues. This means, the implementations are not forward compatible :-( data = array('B', [48, 130, 1, 32, 161, 130, 0, 87, 128, 7, 4, 0, 2, 2, 5, 1, 28, 129, 13, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 163, 130, 0, 32, 160, 130, 0, 21, 128, 5, 50, 50, 50, 50, 50, 129, 12, 49, 57, 56, 46, 53, 49, 46, 49, 48, 48, 46, 50, 129, 5, 0, 233, 99, 67, 134, 132, 1, 16, 133, 19, 50, 48, 50, 49, 49, 50, 49, 54, 49, 52, 50, 51, 53, 56, 46, 53, 51, 49, 90, 136, 1, 1, 162, 130, 0, 193, 160, 130, 0, 189, 48, 130, 0, 185, 128, 1, 3, 162, 130, 0, 178, 147, 129, 175, 48, 130, 0, 171, 129, 5, 4, 19, 15, 0, 3, 162, 130, 0, 160, 167, 130, 0, 156, 161, 130, 0, 17, 129, 15, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 130, 1, 0, 163, 130, 0, 18, 130, 16, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 164, 130, 0, 14, 129, 12, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 165, 130, 0, 3, 129, 1, 1, 167, 130, 0, 75, 161, 130, 0, 71, 161, 130, 0, 54, 162, 130, 0, 50, 161, 130, 0, 18, 161, 130, 0, 9, 129, 3, 50, 50, 50, 130, 2, 50, 50, 130, 3, 50, 50, 50, 162, 130, 0, 21, 161, 130, 0, 9, 129, 3, 50, 50, 50, 130, 2, 50, 50, 130, 6, 4, 34, 34, 34, 34, 34, 131, 1, 0, 132, 1, 10, 133, 8, 43, 48, 49, 58, 48, 48, 43, 48, 137, 1, 1, 138, 1, 10]) p = Path("./") fileGlob = [str(f) for f in p.rglob('*.asn')] fileGlob += [str(f) for f in p.rglob('*.asn1')] parseASN1Files(fileGlob) err, foo = compileASN1Files(fileGlob) print('***decoding pspdu***') pspdu = foo.decode('PS-PDU', data) print(pspdu) # is there a way to enable the automatic decoding of the attributes of content type ocetet string but have a "containing" constraint? print("\n\n***manually decoded 33128 iri***") # FOOIRIPayload is used because of naming clashes and i couldn't get "fixDottedReference" to do the right thing # deps/33128/... was modified for this to work iri33128 = foo.decode('FOOIRIPayload', pspdu['payload'][1][0]['iRIContents'][1]) print(iri33128)