diff options
author | elie <elie> | 2013-01-27 21:23:51 +0000 |
---|---|---|
committer | elie <elie> | 2013-01-27 21:23:51 +0000 |
commit | 6c8b88f1a7c9f44c33dad1116f341524a20cda60 (patch) | |
tree | 67005c388e0b3c4531f61414458c24b6b062f84f /pyasn1 | |
parent | 3f1f9a84dbb54cc6c61174b62056cb4acd71faa1 (diff) | |
download | pyasn1-6c8b88f1a7c9f44c33dad1116f341524a20cda60.tar.gz |
fix to CHOICE decoder to handle explicitly tagged, indefinite length
mode encoding
Diffstat (limited to 'pyasn1')
-rw-r--r-- | pyasn1/codec/ber/decoder.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/pyasn1/codec/ber/decoder.py b/pyasn1/codec/ber/decoder.py index b7330a9..82b3352 100644 --- a/pyasn1/codec/ber/decoder.py +++ b/pyasn1/codec/ber/decoder.py @@ -427,7 +427,26 @@ class ChoiceDecoder(AbstractConstructedDecoder): r.setComponentByType(effectiveTagSet, component, 0, asn1Spec is None) return r, tail - indefLenValueDecoder = valueDecoder + def indefLenValueDecoder(self, fullSubstrate, substrate, asn1Spec, tagSet, + length, state, decodeFun, substrateFun): + r = self._createComponent(asn1Spec, tagSet) + if substrateFun: + return substrateFun(r, substrate, length) + if r.getTagSet() == tagSet: # explicitly tagged Choice + component, substrate = decodeFun(substrate, r.getComponentTagMap()) + eooMarker, substrate = decodeFun(substrate) # eat up EOO marker + if eooMarker != eoo.endOfOctets: + raise error.PyAsn1Error('No EOO seen before substrate ends') + else: + component, substrate= decodeFun( + substrate, r.getComponentTagMap(), tagSet, length, state + ) + if isinstance(component, univ.Choice): + effectiveTagSet = component.getEffectiveTagSet() + else: + effectiveTagSet = component.getTagSet() + r.setComponentByType(effectiveTagSet, component, 0, asn1Spec is None) + return r, substrate class AnyDecoder(AbstractSimpleDecoder): protoComponent = univ.Any() |