2

Im trying to decode a field called Subject Key Identifier (RFC 5820), which was contained within a CMS certificate (RFC 6488). I have for most of the previous "work" successfully used pyasn1 and pyasn1_modules to decode ASN1 structures. However i get the error:

pyasn1.error.SubstrateUnderrunError: 31<18 at <TagSet object, tags 128:32:15>

Using the debugger i found that the problem occurred when reading:

AF 9F 00 96 C2 39 12 D7 8F 6A D6 D6 35 9B A4 88 FB 3A 32 A0

Looking at the first Octet (AF -> 10101111) my understanding is that this is Constructed Definite length-method with the identifier is 15.

Since the first octet is done, the second is the length. 9F -> 10011111, since MSB is set, the length will set by the 31 next octets. However the whole "payload" is 20 bytes (octets). How does this make sense?

(I suppose that the values, 31 and 18 is what the error tells me, but ill keep the explanation if any other beginner finds it useful!)

shinypants
  • 31
  • 1
  • 3
    You're right, it doesn't make sense. What you are looking at is consistent with the OCTET STRING payload of the KeyIdentifier. If you go backwards you'll no doubt find the header information. I will bet you one shiny latinum bar that the previous two bytes were 04 14, and the two before that were 04 16 – President James K. Polk May 25 '20 at 22:36
  • You are very right, thank you! This was exactly the problem. To solve this, i just decoded it as an OCTET STRING. – shinypants May 26 '20 at 11:57

0 Answers0