Indefinite length encoding supported on input?
See original GitHub issuev0.21.1
Encountered a p12 file using indefinite length encoding in auth_safe. The Content-Info OctetString is not aggregated correctly from the substrings. The reconstructed OctetString is too large and the native value contains the ASN.1 headers of the substrings instead of only content.
Test case
Input string in hex = ‘2480040d8dfff0980736af936e423acfcc04159277f7f0e479ffc7dc33b2d03d7b1a186d4472aa490000’
$ openssl asn1parse -inform DER -in dummy.da2
0:d=0 hl=2 l=inf cons: OCTET STRING
2:d=1 hl=2 l= 13 prim: OCTET STRING [HEX DUMP]:8DFFF0980736AF936E423ACFCC
17:d=1 hl=2 l= 21 prim: OCTET STRING [HEX DUMP]:9277F7F0E479FFC7DC33B2D03D7B1A186D4472AA49
40:d=1 hl=2 l= 0 prim: EOC
Expected behaviour: an OctetString whose native value is a byte string of length 34
>>> data = binascii.unhexlify('2480040d8dfff0980736af936e423acfcc04159277f7f0e479ffc7dc33b2d03d7b1a186d4472aa490000')
>>> x = core.OctetString.load(data)
>>> len(x.native)
34
>>> binascii.hexlify(x.native)
b'8dfff0980736af936e423acfcc9277f7f0e479ffc7dc33b2d03d7b1a186d4472aa49'
Observed behaviour:
>>> data = binascii.unhexlify('2480040d8dfff0980736af936e423acfcc04159277f7f0e479ffc7dc33b2d03d7b1a186d4472aa490000')
>>> x = core.OctetString.load(data)
>>> len(x.native)
38
>>> binascii.hexlify(x.native)
b'040d8dfff0980736af936e423acfcc04159277f7f0e479ffc7dc33b2d03d7b1a186d4472aa49'
## note ASN.1 headers 040d and 0415 are in the native value
Issue Analytics
- State:
- Created 7 years ago
- Comments:15 (11 by maintainers)

Top Related StackOverflow Question
This should be resolved by f577cfff05e37b4baf4820973400730868155477 and 04c7ea7657e57f54604b68e2ca497781819c7fc7
I believe this is all set now.