debug.logger('decoder called at scope %s with state %d, working with up to %d octets of substrate: %s'%(debug.scope,state,len(substrate),debug.hexdump(substrate)))
debug.logger('decoder called at scope %s with state %d, working with up to %d octets of substrate: %s'%(debug.scope,state,len(substrate),debug.hexdump(substrate)))
debug.loggeranddebug.logger&debug.flagDecoderanddebug.logger('tag decoded into %r, decoding length'%tagSet)
debug.loggeranddebug.logger&debug.flagDecoderanddebug.logger('tag decoded into %s, decoding length'%tagSet)
ifstate==stDecodeLength:
ifstate==stDecodeLength:
# Decode length
# Decode length
ifnotsubstrate:
ifnotsubstrate:
raiseerror.SubstrateUnderrunError(
raiseerror.SubstrateUnderrunError(
'Short octet stream on length decoding'
'Short octet stream on length decoding'
)
)
firstOctet=oct2int(substrate[0])
firstOctet=oct2int(substrate[0])
iffirstOctet==128:
iffirstOctet==128:
size=1
size=1
@ -670,6 +705,8 @@ class Decoder:
raiseerror.SubstrateUnderrunError(
raiseerror.SubstrateUnderrunError(
'%d-octet short'%(length-len(substrate))
'%d-octet short'%(length-len(substrate))
)
)
iflength==-1andnotself.supportIndefLength:
error.PyAsn1Error('Indefinite length encoding not supported by this codec')
state=stGetValueDecoder
state=stGetValueDecoder
debug.loggeranddebug.logger&debug.flagDecoderanddebug.logger('value length decoded into %d, payload substrate is: %s'%(length,debug.hexdump(length==-1andsubstrateorsubstrate[:length])))
debug.loggeranddebug.logger&debug.flagDecoderanddebug.logger('value length decoded into %d, payload substrate is: %s'%(length,debug.hexdump(length==-1andsubstrateorsubstrate[:length])))
ifstate==stGetValueDecoder:
ifstate==stGetValueDecoder:
@ -722,12 +759,12 @@ class Decoder:
ifdebug.loggeranddebug.logger&debug.flagDecoder:
ifdebug.loggeranddebug.logger&debug.flagDecoder:
debug.logger('candidate ASN.1 spec is a map of:')
debug.logger('candidate ASN.1 spec is a map of:')
fort,vinasn1Spec.getPosMap().items():
fort,vinasn1Spec.getPosMap().items():
debug.logger('%r -> %s'%(t,v.__class__.__name__))
debug.logger('%s -> %s'%(t,v.__class__.__name__))
ifasn1Spec.getNegMap():
ifasn1Spec.getNegMap():
debug.logger('but neither of: ')
debug.logger('but neither of: ')
foriinasn1Spec.getNegMap().items():
fort,vinasn1Spec.getNegMap().items():
debug.logger('%r -> %s'%(t,v.__class__.__name__))
debug.logger('%s -> %s'%(t,v.__class__.__name__))
debug.logger('new candidate ASN.1 spec is %s, chosen by %r'%(__chosenSpecisNoneand'<none>'or__chosenSpec.__class__.__name__,tagSet))
debug.logger('new candidate ASN.1 spec is %s, chosen by %s'%(__chosenSpecisNoneand'<none>'or__chosenSpec.prettyPrintType(),tagSet))
else:
else:
__chosenSpec=asn1Spec
__chosenSpec=asn1Spec
debug.loggeranddebug.logger&debug.flagDecoderanddebug.logger('candidate ASN.1 spec is %s'%asn1Spec.__class__.__name__)
debug.loggeranddebug.logger&debug.flagDecoderanddebug.logger('candidate ASN.1 spec is %s'%asn1Spec.__class__.__name__)
@ -745,7 +782,7 @@ class Decoder:
elifbaseTagSetinself.__tagMap:
elifbaseTagSetinself.__tagMap:
# base type or tagged subtype
# base type or tagged subtype
concreteDecoder=self.__tagMap[baseTagSet]
concreteDecoder=self.__tagMap[baseTagSet]
debug.loggeranddebug.logger&debug.flagDecoderanddebug.logger('value decoder chosen by base %r'%(baseTagSet,))
debug.loggeranddebug.logger&debug.flagDecoderanddebug.logger('value decoder chosen by base %s'%(baseTagSet,))
debug.loggeranddebug.logger&debug.flagDecoderanddebug.logger('codec %s yields type %s, value:\n%s\n...remaining substrate is: %s'%(concreteDecoder.__class__.__name__,value.__class__.__name__,value.prettyPrint(),substrateanddebug.hexdump(substrate)or'<none>'))
debug.loggeranddebug.logger&debug.flagDecoderanddebug.logger('codec %s yields type %s, value:\n%s\n...remaining substrate is: %s'%(concreteDecoder.__class__.__name__,value.__class__.__name__,value.prettyPrint(),substrateanddebug.hexdump(substrate)or'<none>'))
ifstate==stErrorCondition:
ifstate==stErrorCondition:
raiseerror.PyAsn1Error(
raiseerror.PyAsn1Error(
'%r not in asn1Spec: %r'%(tagSet,asn1Spec)
'%s not in asn1Spec: %s'%(tagSet,asn1Spec)
)
)
ifdebug.loggeranddebug.logger&debug.flagDecoder:
ifdebug.loggeranddebug.logger&debug.flagDecoder:
debug.scope.pop()
debug.scope.pop()
debug.logger('decoder left scope %s, call completed'%debug.scope)
debug.logger('decoder left scope %s, call completed'%debug.scope)
debug.logger&debug.flagEncoderanddebug.logger('encoder called in %sdef mode, chunk size %s for type %s, value:\n%s'%(notdefModeand'in'or'',maxChunkSize,value.__class__.__name__,value.prettyPrint()))
ifnotdefModeandnotself.supportIndefLength:
raiseerror.PyAsn1Error('Indefinite length encoding not supported by this codec')
debug.logger&debug.flagEncoderanddebug.logger('encoder called in %sdef mode, chunk size %s for type %s, value:\n%s'%(notdefModeand'in'or'',maxChunkSize,value.prettyPrintType(),value.prettyPrint()))
tagSet=value.getTagSet()
tagSet=value.getTagSet()
iflen(tagSet)>1:
iflen(tagSet)>1:
concreteEncoder=explicitlyTaggedItemEncoder
concreteEncoder=explicitlyTaggedItemEncoder
@ -343,7 +423,7 @@ class Encoder:
concreteEncoder=self.__tagMap[tagSet]
concreteEncoder=self.__tagMap[tagSet]
else:
else:
raiseError('No encoder for %s'%(value,))
raiseError('No encoder for %s'%(value,))
debug.logger&debug.flagEncoderanddebug.logger('using value codec %s chosen by %r'%(concreteEncoder.__class__.__name__,tagSet))
debug.logger&debug.flagEncoderanddebug.logger('using value codec %s chosen by %s'%(concreteEncoder.__class__.__name__,tagSet))