MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / OctetStringPayloadDecoder

Class OctetStringPayloadDecoder

pager_lib/pyasn1/codec/ber/decoder.py:296–379  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

294
295
296class OctetStringPayloadDecoder(AbstractSimplePayloadDecoder):
297 protoComponent = univ.OctetString('')
298 supportConstructedForm = True
299
300 def valueDecoder(self, substrate, asn1Spec,
301 tagSet=None, length=None, state=None,
302 decodeFun=None, substrateFun=None,
303 **options):
304 if substrateFun:
305 asn1Object = self._createComponent(asn1Spec, tagSet, noValue, **options)
306
307 for chunk in substrateFun(asn1Object, substrate, length, options):
308 yield chunk
309
310 return
311
312 if tagSet[0].tagFormat == tag.tagFormatSimple: # XXX what tag to check?
313 for chunk in readFromStream(substrate, length, options):
314 if isinstance(chunk, SubstrateUnderrunError):
315 yield chunk
316
317 yield self._createComponent(asn1Spec, tagSet, chunk, **options)
318
319 return
320
321 if not self.supportConstructedForm:
322 raise error.PyAsn1Error('Constructed encoding form prohibited at %s' % self.__class__.__name__)
323
324 if LOG:
325 LOG('assembling constructed serialization')
326
327 # All inner fragments are of the same type, treat them as octet string
328 substrateFun = self.substrateCollector
329
330 header = b''
331
332 original_position = substrate.tell()
333 # head = popSubstream(substrate, length)
334 while substrate.tell() - original_position < length:
335 for component in decodeFun(
336 substrate, self.protoComponent, substrateFun=substrateFun,
337 **options):
338 if isinstance(component, SubstrateUnderrunError):
339 yield component
340
341 header += component
342
343 yield self._createComponent(asn1Spec, tagSet, header, **options)
344
345 def indefLenValueDecoder(self, substrate, asn1Spec,
346 tagSet=None, length=None, state=None,
347 decodeFun=None, substrateFun=None,
348 **options):
349 if substrateFun and substrateFun is not self.substrateCollector:
350 asn1Object = self._createComponent(asn1Spec, tagSet, noValue, **options)
351
352 for chunk in substrateFun(asn1Object, substrate, length, options):
353 yield chunk

Callers 2

decoder.pyFile · 0.70
decoder.pyFile · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected