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

Method encodeLength

pager_lib/pyasn1/codec/ber/encoder.py:53–71  ·  view source on GitHub ↗
(self, length, defMode)

Source from the content-addressed store, hash-verified

51 return (encodedTag | 0x1F,) + substrate
52
53 def encodeLength(self, length, defMode):
54 if not defMode and self.supportIndefLenMode:
55 return (0x80,)
56
57 if length < 0x80:
58 return length,
59
60 else:
61 substrate = ()
62 while length:
63 substrate = (length & 0xff,) + substrate
64 length >>= 8
65
66 substrateLen = len(substrate)
67
68 if substrateLen > 126:
69 raise error.PyAsn1Error('Length octets overflow (%d)' % substrateLen)
70
71 return (0x80 | substrateLen,) + substrate
72
73 def encodeValue(self, value, asn1Spec, encodeFun, **options):
74 raise error.PyAsn1Error('Not implemented')

Callers 1

encodeMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected