| 131 | |
| 132 | |
| 133 | class IntegerPayloadDecoder(AbstractSimplePayloadDecoder): |
| 134 | protoComponent = univ.Integer(0) |
| 135 | |
| 136 | def valueDecoder(self, substrate, asn1Spec, |
| 137 | tagSet=None, length=None, state=None, |
| 138 | decodeFun=None, substrateFun=None, |
| 139 | **options): |
| 140 | |
| 141 | if tagSet[0].tagFormat != tag.tagFormatSimple: |
| 142 | raise error.PyAsn1Error('Simple tag format expected') |
| 143 | |
| 144 | for chunk in readFromStream(substrate, length, options): |
| 145 | if isinstance(chunk, SubstrateUnderrunError): |
| 146 | yield chunk |
| 147 | |
| 148 | if chunk: |
| 149 | value = int.from_bytes(bytes(chunk), 'big', signed=True) |
| 150 | |
| 151 | else: |
| 152 | value = 0 |
| 153 | |
| 154 | yield self._createComponent(asn1Spec, tagSet, value, **options) |
| 155 | |
| 156 | |
| 157 | class BooleanPayloadDecoder(IntegerPayloadDecoder): |