pycrate icon indicating copy to clipboard operation
pycrate copied to clipboard

pycrate 0.7.8 asn1rt.err.ASN1BERDecodeErr: RetrieveNotificationsListResponse.notificationList._item_.otherSignedNotification: missing mandatory component, tbsOtherNotification

Open mtb04313 opened this issue 9 months ago • 4 comments

Hello, I encountered a ASN1BERDecodeErr error while parsing RetrieveNotificationsListResponse in GSMA SGP.22 v3. The error can also be reproduced in asn1_play (https://amenitypj.in/asn1Play) with other releases of SGP.22

Steps to reproduce: git clone https://github.com/pycrate-org/pycrate cd pycrate

tools\pycrate_asn1compile.py -i c:\test\SGP.22-v3.0-1\RSPDefinition.asn c:\test\SGP.22-v3.0-1\PKIX1Implicit88.asn c:\test\SGP.22-v3.0-1\PKIX1Explicit88.asn c:\test\SGP.22-v3.0-1\PEDefinitions.asn -o c:\test\SGP.22-v3.0-1\gsma_sgp22_v3

[proc] [c:\test\SGP.22-v3.0-1\RSPDefinition.asn] module RSPDefinitions (oid: [2, 23, 146, 1, 1, 3]): 210 ASN.1 assignments found
[proc] [c:\test\SGP.22-v3.0-1\PKIX1Implicit88.asn] module PKIX1Implicit88 (oid: [1, 3, 6, 1, 5, 5, 7, 0, 19]): 86 ASN.1 assignments found
[proc] [c:\test\SGP.22-v3.0-1\PKIX1Explicit88.asn] module PKIX1Explicit88 (oid: [1, 3, 6, 1, 5, 5, 7, 0, 18]): 170 ASN.1 assignments found
[proc] [c:\test\SGP.22-v3.0-1\PEDefinitions.asn] module PEDefinitions (oid: [2, 23, 143, 1, 1, 3]): 65 ASN.1 assignments found
--- compilation cycle ---
WNG: PKIX1Explicit88.AlgorithmIdentifier, untagged OPEN / ANY in SEQUENCE with parameters
--- compilation cycle ---
--- compilation cycle ---
--- verifications ---
[proc] ASN.1 modules processed: ['RSPDefinitions', 'PKIX1Implicit88', 'PKIX1Explicit88', 'PEDefinitions']
[proc] ASN.1 objects compiled: 371 types, 0 sets, 156 values
[proc] done

cd c:\test\SGP.22-v3.0-1 bug_pycrate.py

Traceback (most recent call last):
  File "C:\test\SGP.22-v3.0-1\bug_pycrate.py", line 46, in <module>
    main()
  File "C:\test\SGP.22-v3.0-1\bug_pycrate.py", line 43, in main
    decode_retrieveNotificationsList(rsp)     # failed
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\test\SGP.22-v3.0-1\bug_pycrate.py", line 32, in decode_retrieveNotificationsList
    rspObj.from_ber(encodedBytes)
  File "C:\Python312-64\Lib\site-packages\pycrate_asn1rt\asnobj.py", line 1637, in from_ber
    self._from_ber(char, TLV)
  File "C:\Python312-64\Lib\site-packages\pycrate_asn1rt\asnobj.py", line 1621, in _from_ber
    self._decode_ber_cont(char, tlv)
  File "C:\Python312-64\Lib\site-packages\pycrate_asn1rt\asnobj_construct.py", line 507, in _decode_ber_cont
    Cho._from_ber(char, [tlv])
  File "C:\Python312-64\Lib\site-packages\pycrate_asn1rt\asnobj.py", line 1621, in _from_ber
    self._decode_ber_cont(char, tlv)
  File "C:\Python312-64\Lib\site-packages\pycrate_asn1rt\asnobj_construct.py", line 3090, in _decode_ber_cont
    Comp._from_ber(char, [comp_tlv])
  File "C:\Python312-64\Lib\site-packages\pycrate_asn1rt\asnobj.py", line 1621, in _from_ber
    self._decode_ber_cont(char, tlv)
  File "C:\Python312-64\Lib\site-packages\pycrate_asn1rt\asnobj_construct.py", line 507, in _decode_ber_cont
    Cho._from_ber(char, [tlv])
  File "C:\Python312-64\Lib\site-packages\pycrate_asn1rt\asnobj.py", line 1621, in _from_ber
    self._decode_ber_cont(char, tlv)
  File "C:\Python312-64\Lib\site-packages\pycrate_asn1rt\asnobj_construct.py", line 2109, in _decode_ber_cont
    raise(ASN1BERDecodeErr('{0}: missing mandatory component, {1}'\
pycrate_asn1rt.err.ASN1BERDecodeErr: RetrieveNotificationsListResponse.notificationList._item_.otherSignedNotification: missing mandatory component, tbsOtherNotification

Workaround mv gsma_sgp22_v3.py gsma_sgp22_v3.py.original

cat patchfile.txt | patch gsma_sgp22_v3.py.original -o gsma_sgp22_v3.py patching file gsma_sgp22_v3.py.original

SGP.22-v3.0-1.zip

bug_pycrate.py OPEN._decode_ber_cont: RetrieveNotificationsListResponse.notificationList.item.otherSignedNotification.euiccCertificate.tbsCertificate.subjectPublicKeyInfo.algorithm.parameters, DEFINED BY lookup not supported OPEN._decode_ber_cont: RetrieveNotificationsListResponse.notificationList.item.otherSignedNotification.nextCertInChain.tbsCertificate.subjectPublicKeyInfo.algorithm.parameters, DEFINED BY lookup not supported ('notificationList', [('otherSignedNotification', {'tbsOtherNotification': {'seqNumber': 88, 'profileManagementOperation': (1, 2), 'notificationAddress': 'rsp-eu.simlessly.com', 'iccid': b'\x98D5X#P\x89 F\xf9'}, 'euiccNotificationSignature': b'\x96%\xee\x08\xca/\xbb#X\r:\x8ar\xb3\x92u\x8d\x07\xbc\r\xb1\x80\xfc\x05JC\xb9Jb\n\x00/@-\xddF\xc4R\x011\xd9\xad\x7f\x86\x9a\xc0\xc4\xe0\xb3RR\x97}#^<\x8bY\xeaS\xc1\xa6\xcb\xda', 'euiccCertificate': {'tbsCertificate': {'version': 2, 'serialNumber': 170558324583887545867756765014070074943, 'signature': {'algorithm': (1, 2, 840, 10045, 4, 3, 2)}, 'issuer': ('rdnSequence', [[{'type': (2, 5, 4, 10), 'value': ('_unk_0012', b'GEMALTO SA')}], [{'type': (2, 5, 4, 3), 'value': ('_unk_0012', b'GEMALTO EUM CE PAU')}]]), 'validity': {'notBefore': ('utcTime', ('24', '10', '18', '00', '00', '00', 'Z')), 'notAfter': ('generalTime', ('9999', '12', '31', '23', '59', '59', None, 'Z'))}, 'subject': ('rdnSequence', [[{'type': (2, 5, 4, 10), 'value': ('_unk_0012', b'GEMALTO SA')}], [{'type': (2, 5, 4, 5), 'value': ('_unk_0019', b'89033023429000000000042877717740')}]]), 'subjectPublicKeyInfo': {'algorithm': {'algorithm': (1, 2, 840, 10045, 2, 1), 'parameters': ('_unk_006', b'\x86H\xce=\x03\x01\x07')}, 'subjectPublicKey': (63682112740970372210974134734014972668028160697727024093272042841325483258648144505735997702512153758195846054696949148327976550597242081573041956377326903, 520)}, 'extensions': [{'extnID': (2, 5, 29, 35), 'extnValue': b'0\x16\x80\x14\xdc\xde\x1ai\x1f\xe9\xafu\xdd\xa1\xbb\x92\x991\x8b)\xb1\xd4\x16\xb2'}, {'extnID': (2, 5, 29, 14), 'extnValue': b'\x04\x14U\x87\x8d\x0c`s(|c\x08@Kw\x01k\x06\xda\x97\xd3\xe1'}, {'extnID': (2, 5, 29, 15), 'critical': True, 'extnValue': b'\x03\x02\x00\x80'}, {'extnID': (2, 5, 29, 32), 'critical': True, 'extnValue': b'0\x0b0\t\x06\x07g\x81\x12\x01\x02\x01\x01'}]}, 'signatureAlgorithm': {'algorithm': (1, 2, 840, 10045, 4, 3, 2)}, 'signature': (46638659030562055062499246876961152021973208105263302029900432402007881444271819464240309271966965639844676738751606824403890783783615331851873560067803981149667673890899193, 576)}, 'nextCertInChain': {'tbsCertificate': {'version': 2, 'serialNumber': 51117269164942528510938495864802179922, 'signature': {'algorithm': (1, 2, 840, 10045, 4, 3, 2)}, 'issuer': ('rdnSequence', [[{'type': (2, 5, 4, 10), 'value': ('_unk_0019', b'GSM Association')}], [{'type': (2, 5, 4, 3), 'value': ('_unk_0019', b'GSM Association - RSP2 Root CI1')}]]), 'validity': {'notBefore': ('utcTime', ('17', '05', '25', '00', '00', '00', 'Z')), 'notAfter': ('utcTime', ('47', '05', '24', '23', '59', '59', 'Z'))}, 'subject': ('rdnSequence', [[{'type': (2, 5, 4, 10), 'value': ('_unk_0012', b'GEMALTO SA')}], [{'type': (2, 5, 4, 3), 'value': ('_unk_0012', b'GEMALTO EUM CE PAU')}]]), 'subjectPublicKeyInfo': {'algorithm': {'algorithm': (1, 2, 840, 10045, 2, 1), 'parameters': ('_unk_006', b'\x86H\xce=\x03\x01\x07')}, 'subjectPublicKey': (62970975015704509736436756982654773535893891895072610108722779850295505112900096179276122770808816053645629425062933553633696923378196323456826074187846326, 520)}, 'extensions': [{'extnID': (2, 5, 29, 19), 'critical': True, 'extnValue': b'0\x06\x01\x01\xff\x02\x01\x00'}, {'extnID': (2, 5, 29, 32), 'critical': True, 'extnValue': b'0\x0b0\t\x06\x07g\x81\x12\x01\x02\x01\x02'}, {'extnID': (2, 5, 29, 31), 'extnValue': b'0D0B\xa0@\xa0>\x86<http://gsma-crl.symauth.com/offlineca/gsma-rsp2-root-ci1.crl'}, {'extnID': (2, 5, 29, 15), 'critical': True, 'extnValue': b'\x03\x02\x01\x06'}, {'extnID': (2, 5, 29, 30), 'critical': True, 'extnValue': b'00\xa0.0,\xa4*0(1\x130\x11\x06\x03U\x04\n\x0c\nGEMALTO SA1\x110\x0f\x06\x03U\x04\x05\x13\x0889033023'}, {'extnID': (2, 5, 29, 17), 'extnValue': b'0\x0e\x88\x0c+\x06\x01\x04\x01\x81\xf8\x02\x87j\x04\x03'}, {'extnID': (2, 5, 29, 14), 'extnValue': b'\x04\x14\xdc\xde\x1ai\x1f\xe9\xafu\xdd\xa1\xbb\x92\x991\x8b)\xb1\xd4\x16\xb2'}, {'extnID': (2, 5, 29, 35), 'extnValue': b'0\x16\x80\x14\x817\x0fQ%\xd0\xb1\xd4\x08\xd4\xc3\xb22\xe6\xd2^y[\xeb\xfb'}]}, 'signatureAlgorithm': {'algorithm': (1, 2, 840, 10045, 4, 3, 2)}, 'signature': (182167519629839116493407247127635555255523363602079834021063055882452061239938844376112671634714812980715242391955681601016437387741440392927620049293001931113320140837283, 568)}})])

mtb04313 avatar Mar 24 '25 02:03 mtb04313

Thanks for the report. Pycrate's exception says RetrieveNotificationsListResponse.notificationList._item_.otherSignedNotification: missing mandatory component, tbsOtherNotification, which means the value you submitted to the decoder is missing the mandatory field tbsOtherNotification within the SEQUENCE otherSignedNotification. Did you double check what exact value you are submitting? Could you please test the offending buffer against another ASN.1 compiler / decoder, to ensure it is valid, then indicate what makes pycrate fail to decode it? Your patch consists in removing tag declaration from objects in the automatically generated module. Not only are tags required for proper BER decoding, but there is no root cause analysis related to the error you are having. This does not help very much understanding the issue.

mitshell avatar Mar 24 '25 20:03 mitshell

Hello, Thanks for looking into this issue. Indeed, I have successfully decoded the offending buffer using asn1c-0.9.28 (https://github.com/vlm/asn1c), which led me to think the input buffer is valid. I think the pycrate decoder error happened because the pycrate_asn1compile.py tool assigned incorrect tags to the child nodes of 'otherSignedNotification', which I manually 'undo' in the patch file. I had compared 'OtherSignedNotification' with 'AuthenticateResponseOk' in the generated code, to come up with the workaround. However, I did not investigate what led pycrate_asn1compile.py to assign those tags in OtherSignedNotification while not doing so for AuthenticateResponseOk.

<RetrieveNotificationsListResponse>
    <notificationList>
            <otherSignedNotification>
                <tbsOtherNotification>
                    <seqNumber>88</seqNumber>
                    <profileManagementOperation>
                        01
                    </profileManagementOperation>
                    <notificationAddress>rsp-eu.simlessly.com</notificationAddress>
                    <iccid>98 44 35 58 23 50 89 20 46 F9</iccid>
                </tbsOtherNotification>
                <euiccNotificationSignature>
                    96 25 EE 08 CA 2F BB 23 58 0D 3A 8A 72 B3 92 75
                    8D 07 BC 0D B1 80 FC 05 4A 43 B9 4A 62 0A 00 2F
                    40 2D DD 46 C4 52 01 31 D9 AD 7F 86 9A C0 C4 E0
                    B3 52 52 97 7D 23 5E 3C 8B 59 EA 53 C1 A6 CB DA
                </euiccNotificationSignature>
                <euiccCertificate>
                    <tbsCertificate>
                        <version>2</version>
                        <serialNumber>00:80:50:56:A5:30:06:38:1D:CB:EB:89:66:5B:63:1E:3F</serialNumber>
                        <signature>
                            <algorithm>1.2.840.10045.4.3.2</algorithm>
                        </signature>
                        <issuer>
                            <rdnSequence>
                                <RelativeDistinguishedName>
                                    <AttributeTypeAndValue>
                                        <type>2.5.4.10</type>
                                        <value>0C 0A 47 45 4D 41 4C 54 4F 20 53 41</value>
                                    </AttributeTypeAndValue>
                                </RelativeDistinguishedName>
                                <RelativeDistinguishedName>
                                    <AttributeTypeAndValue>
                                        <type>2.5.4.3</type>
                                        <value>
                                            0C 12 47 45 4D 41 4C 54 4F 20 45 55 4D 20 43 45
                                            20 50 41 55
                                        </value>
                                    </AttributeTypeAndValue>
                                </RelativeDistinguishedName>
                            </rdnSequence>
                        </issuer>
                        <validity>
                            <notBefore>
                                <utcTime>241018000000Z</utcTime>
                            </notBefore>
                            <notAfter>
                                <generalTime>99991231235959Z</generalTime>
                            </notAfter>
                        </validity>
                        <subject>
                            <rdnSequence>
                                <RelativeDistinguishedName>
                                    <AttributeTypeAndValue>
                                        <type>2.5.4.10</type>
                                        <value>0C 0A 47 45 4D 41 4C 54 4F 20 53 41</value>
                                    </AttributeTypeAndValue>
                                </RelativeDistinguishedName>
                                <RelativeDistinguishedName>
                                    <AttributeTypeAndValue>
                                        <type>2.5.4.5</type>
                                        <value>
                                            13 20 38 39 30 33 33 30 32 33 34 32 39 30 30 30
                                            30 30 30 30 30 30 30 34 32 38 37 37 37 31 37 37
                                            34 30
                                        </value>
                                    </AttributeTypeAndValue>
                                </RelativeDistinguishedName>
                            </rdnSequence>
                        </subject>
                        <subjectPublicKeyInfo>
                            <algorithm>
                                <algorithm>1.2.840.10045.2.1</algorithm>
                                <parameters>06 08 2A 86 48 CE 3D 03 01 07</parameters>
                            </algorithm>
                            <subjectPublicKey>
                                0000010010111111111001111010111011011101011110101000010001111010
                                1010001100101001011010011101110000110110100011000100101001111000
                                1010010011101110000000110000011011010000000100111001101110010100
                                1100001101010010010000011011111100111100000000110000000010001101
                                1010101000001011010110100010000100111001101011110000000100001011
                                1011001011101011010100011011101001110011010111010011001100000101
                                0111101011001110111101011110111011010111101111011100110010011011

                                010000000010110011001010111011000010000011011010001001111111010100110111
                            </subjectPublicKey>
                        </subjectPublicKeyInfo>
                        <extensions>
                            <Extension>
                                <extnID>2.5.29.35</extnID>
                                <critical><false/></critical>
                                <extnValue>
                                    30 16 80 14 DC DE 1A 69 1F E9 AF 75 DD A1 BB 92
                                    99 31 8B 29 B1 D4 16 B2
                                </extnValue>
                            </Extension>
                            <Extension>
                                <extnID>2.5.29.14</extnID>
                                <critical><false/></critical>
                                <extnValue>
                                    04 14 55 87 8D 0C 60 73 28 7C 63 08 40 4B 77 01
                                    6B 06 DA 97 D3 E1
                                </extnValue>
                            </Extension>
                            <Extension>
                                <extnID>2.5.29.15</extnID>
                                <critical><true/></critical>
                                <extnValue>03 02 00 80</extnValue>
                            </Extension>
                            <Extension>
                                <extnID>2.5.29.32</extnID>
                                <critical><true/></critical>
                                <extnValue>30 0B 30 09 06 07 67 81 12 01 02 01 01</extnValue>
                            </Extension>
                        </extensions>
                    </tbsCertificate>
                    <signatureAlgorithm>
                        <algorithm>1.2.840.10045.4.3.2</algorithm>
                    </signatureAlgorithm>
                    <signature>
                        0011000001000110000000100010000100000000110111011011011000001111
                        0101000100010010111010010111001011000000011101011100000101100011
                        1000111100011001010001011010000000001110001001011101011010110111
                        0101010011110111000101000010010001110011010111101011011101101100
                        0111011110101010110111000111110110010010000000100010000100000000
                        1011010101100000101011101110101100101001100000010000110001110101
                        0111010001100011110001101001011101011111101001110000100110101100
                        1100101101101110010100101110000001000011110000010010011110110100
                        1010101001001000001111001011110101111101101101000100010011111001
                    </signature>
                </euiccCertificate>
                <nextCertInChain>
                    <tbsCertificate>
                        <version>2</version>
                        <serialNumber>26:74:D3:F3:9D:37:27:79:08:7E:1B:59:35:EC:FB:52</serialNumber>
                        <signature>
                            <algorithm>1.2.840.10045.4.3.2</algorithm>
                        </signature>
                        <issuer>
                            <rdnSequence>
                                <RelativeDistinguishedName>
                                    <AttributeTypeAndValue>
                                        <type>2.5.4.10</type>
                                        <value>
                                            13 0F 47 53 4D 20 41 73 73 6F 63 69 61 74 69 6F
                                            6E
                                        </value>
                                    </AttributeTypeAndValue>
                                </RelativeDistinguishedName>
                                <RelativeDistinguishedName>
                                    <AttributeTypeAndValue>
                                        <type>2.5.4.3</type>
                                        <value>
                                            13 1F 47 53 4D 20 41 73 73 6F 63 69 61 74 69 6F
                                            6E 20 2D 20 52 53 50 32 20 52 6F 6F 74 20 43 49
                                            31
                                        </value>
                                    </AttributeTypeAndValue>
                                </RelativeDistinguishedName>
                            </rdnSequence>
                        </issuer>
                        <validity>
                            <notBefore>
                                <utcTime>170525000000Z</utcTime>
                            </notBefore>
                            <notAfter>
                                <utcTime>470524235959Z</utcTime>
                            </notAfter>
                        </validity>
                        <subject>
                            <rdnSequence>
                                <RelativeDistinguishedName>
                                    <AttributeTypeAndValue>
                                        <type>2.5.4.10</type>
                                        <value>0C 0A 47 45 4D 41 4C 54 4F 20 53 41</value>
                                    </AttributeTypeAndValue>
                                </RelativeDistinguishedName>
                                <RelativeDistinguishedName>
                                    <AttributeTypeAndValue>
                                        <type>2.5.4.3</type>
                                        <value>
                                            0C 12 47 45 4D 41 4C 54 4F 20 45 55 4D 20 43 45
                                            20 50 41 55
                                        </value>
                                    </AttributeTypeAndValue>
                                </RelativeDistinguishedName>
                            </rdnSequence>
                        </subject>
                        <subjectPublicKeyInfo>
                            <algorithm>
                                <algorithm>1.2.840.10045.2.1</algorithm>
                                <parameters>06 08 2A 86 48 CE 3D 03 01 07</parameters>
                            </algorithm>
                            <subjectPublicKey>
                                0000010010110010010100111011011011011010100101010001000111100101
                                1110000110001010011100000001111010110110010001000011011110011110
                                1110000001000000110000001010111000011111011110011011101000100110
                                1000000100011000010000100111010101001011111110111111110001100001
                                0010110000111000011111100110011111100101110111111011001011110011
                                1011100001111101000110000011111010010100111101011100100000010101
                                0011100011100001011100101101110100111100000101010111110110011010

                                011110111000100011001101000111100010111110111011110001100101001010110110
                            </subjectPublicKey>
                        </subjectPublicKeyInfo>
                        <extensions>
                            <Extension>
                                <extnID>2.5.29.19</extnID>
                                <critical><true/></critical>
                                <extnValue>30 06 01 01 FF 02 01 00</extnValue>
                            </Extension>
                            <Extension>
                                <extnID>2.5.29.32</extnID>
                                <critical><true/></critical>
                                <extnValue>30 0B 30 09 06 07 67 81 12 01 02 01 02</extnValue>
                            </Extension>
                            <Extension>
                                <extnID>2.5.29.31</extnID>
                                <critical><false/></critical>
                                <extnValue>
                                    30 44 30 42 A0 40 A0 3E 86 3C 68 74 74 70 3A 2F
                                    2F 67 73 6D 61 2D 63 72 6C 2E 73 79 6D 61 75 74
                                    68 2E 63 6F 6D 2F 6F 66 66 6C 69 6E 65 63 61 2F
                                    67 73 6D 61 2D 72 73 70 32 2D 72 6F 6F 74 2D 63
                                    69 31 2E 63 72 6C
                                </extnValue>
                            </Extension>
                            <Extension>
                                <extnID>2.5.29.15</extnID>
                                <critical><true/></critical>
                                <extnValue>03 02 01 06</extnValue>
                            </Extension>
                            <Extension>
                                <extnID>2.5.29.30</extnID>
                                <critical><true/></critical>
                                <extnValue>
                                    30 30 A0 2E 30 2C A4 2A 30 28 31 13 30 11 06 03
                                    55 04 0A 0C 0A 47 45 4D 41 4C 54 4F 20 53 41 31
                                    11 30 0F 06 03 55 04 05 13 08 38 39 30 33 33 30
                                    32 33
                                </extnValue>
                            </Extension>
                            <Extension>
                                <extnID>2.5.29.17</extnID>
                                <critical><false/></critical>
                                <extnValue>30 0E 88 0C 2B 06 01 04 01 81 F8 02 87 6A 04 03</extnValue>
                            </Extension>
                            <Extension>
                                <extnID>2.5.29.14</extnID>
                                <critical><false/></critical>
                                <extnValue>
                                    04 14 DC DE 1A 69 1F E9 AF 75 DD A1 BB 92 99 31
                                    8B 29 B1 D4 16 B2
                                </extnValue>
                            </Extension>
                            <Extension>
                                <extnID>2.5.29.35</extnID>
                                <critical><false/></critical>
                                <extnValue>
                                    30 16 80 14 81 37 0F 51 25 D0 B1 D4 08 D4 C3 B2
                                    32 E6 D2 5E 79 5B EB FB
                                </extnValue>
                            </Extension>
                        </extensions>
                    </tbsCertificate>
                    <signatureAlgorithm>
                        <algorithm>1.2.840.10045.4.3.2</algorithm>
                    </signatureAlgorithm>
                    <signature>
                        0011000001000101000000100010000001000010001010010000111011101001
                        1110000010010110000011010001001111110011010110111110000101000101
                        1100110011101110111110110010001000110011111100101101000101110000
                        1100111001000111100111101001111101001111011010100010111111010010
                        0101010011010010100111001011101100000010001000010000000011001101
                        1110111001000101110011011100101010100011001011110010001101000110
                        0010100100011000111110100111110110100101111010010001000000010110
                        1100010001110011000011011010010100001010100110011011001011111110
                        01101100110111000101100010001010001001010001000110100011
                    </signature>
                </nextCertInChain>
            </otherSignedNotification>

    </notificationList>
</RetrieveNotificationsListResponse>   

mtb04313 avatar Mar 25 '25 02:03 mtb04313

So, the RSPDefinitions module is defined with the directive AUTOMATIC TAGS, but then in the object OtherSignedNotification, they tag the optional component otherCertsInChain manually with tag 1. I don't know exactly how this should be handled from the ASN.1 specification perspective, but pycrate allocates an overlapping tag 1 with the component euiccNotificationSignature. I need to further check X.680 to see how this should be handle, and eventually adapt the way the pycrate compiler allocates tags automatically.

mitshell avatar Apr 20 '25 08:04 mitshell

I checked ITU-T X.680 quickly on tagging: step 25.3 defines how automatic tagging is eventually superseded by manual tags present in SEQUENCE definitions. And pycrate seems to implement this here: https://github.com/pycrate-org/pycrate/blob/fe6a308dcee661de4276b49c68666f76998776d2/pycrate_asn1c/asnobj.py#L3244

This is the definition of OtherSignedNotification:

OtherSignedNotification ::= SEQUENCE {
    tbsOtherNotification        NotificationMetadata,
    euiccNotificationSignature  EuiccSign,
    euiccCertificate            Certificate, -- eUICC Certificate (CERT.EUICC.SIG)
    nextCertInChain             Certificate, -- The certificate certifying the eUICC Certificate
    otherCertsInChain       [1] CertificateChain OPTIONAL -- #SupportedFromV3.0.0# Other Certificates in the eUICC certificate chain, if any
    }

My understanding of X.680 is that automatic tagging should still apply to OtherSignedNotification, even with the presence of a manual tag for component otherCertsInChain. On the other side, your patch of the pycrate-generated module leads to a similar result as we would apply manual tagging to the entire OtherSignedNotification. Thus my next question @mtb04313: where does the data you provide for decoding comes from? Is it from an official test dataset? Or how was it generated?

mitshell avatar Apr 28 '25 20:04 mitshell