summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelie <elie>2013-01-27 21:23:51 +0000
committerelie <elie>2013-01-27 21:23:51 +0000
commit6c8b88f1a7c9f44c33dad1116f341524a20cda60 (patch)
tree67005c388e0b3c4531f61414458c24b6b062f84f
parent3f1f9a84dbb54cc6c61174b62056cb4acd71faa1 (diff)
downloadpyasn1-6c8b88f1a7c9f44c33dad1116f341524a20cda60.tar.gz
fix to CHOICE decoder to handle explicitly tagged, indefinite length
mode encoding
-rw-r--r--CHANGES2
-rw-r--r--pyasn1/codec/ber/decoder.py21
2 files changed, 22 insertions, 1 deletions
diff --git a/CHANGES b/CHANGES
index 37c0576..7c84c42 100644
--- a/CHANGES
+++ b/CHANGES
@@ -5,6 +5,8 @@ Revision 0.1.7
format for the type (e.g. BOOLEAN is always PRIMITIVE, SET is always
CONSTRUCTED and OCTET STRING is either of the two)
- Fix to REAL type encoder to force primitive encoding form encoding.
+- Fix to CHOICE decoder to handle explicitly tagged, indefinite length
+ mode encoding
Revision 0.1.6
--------------
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()