本文整理汇总了Python中pyasn1.compat.octets.ints2octs函数的典型用法代码示例。如果您正苦于以下问题:Python ints2octs函数的具体用法?Python ints2octs怎么用?Python ints2octs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ints2octs函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testIndefModeChunkedSubst
def testIndefModeChunkedSubst(self):
assert decoder.decode(
ints2octs((36, 128, 4, 4, 81, 117, 105, 99, 4, 4, 107, 32, 98, 114, 4, 4, 111, 119, 110, 32, 4, 3, 102, 111,
120, 0, 0)),
substrateFun=lambda a, b, c: (b, str2octs(''))
) == (ints2octs(
(4, 4, 81, 117, 105, 99, 4, 4, 107, 32, 98, 114, 4, 4, 111, 119, 110, 32, 4, 3, 102, 111, 120, 0, 0)), str2octs(''))
示例2: encode
def encode(self, encodeFun, value, defMode, maxChunkSize, ifNotEmpty=False):
substrate, isConstructed, isOctets = self.encodeValue(
encodeFun, value, defMode, maxChunkSize, ifNotEmpty=ifNotEmpty
)
if ifNotEmpty and not substrate:
return substrate
tagSet = value.tagSet
# tagged value?
if tagSet:
if not isConstructed: # primitive form implies definite mode
defMode = True
header = self.encodeTag(tagSet[-1], isConstructed)
header += self.encodeLength(len(substrate), defMode)
if isOctets:
substrate = ints2octs(header) + substrate
else:
substrate = ints2octs(header + substrate)
eoo = self._encodeEndOfOctets(encodeFun, defMode)
if eoo:
substrate += eoo
return substrate
示例3: testSpec
def testSpec(self):
try:
decoder.decode(ints2octs((2, 1, 12)), asn1Spec=univ.Null()) == (12, null)
except PyAsn1Error:
pass
else:
assert 0, "wrong asn1Spec worked out"
assert decoder.decode(ints2octs((2, 1, 12)), asn1Spec=univ.Integer()) == (12, null)
示例4: _bitsFilter
def _bitsFilter(value):
# rfc1902.Bits does not really initialize from sequences
# Clean bits values
# .1.3.6.1.2.1.17.6.1.1.1.0 = BITS: 5B 00 00 00 [[...]1 3 4 6 7
match = re.match(r'^([0-9a-fA-F]{2}(\s+[0-9a-fA-F]{2})*)\s+\[', value)
if match:
return ints2octs([int(y, 16) for y in match.group(1).split(' ')])
return ints2octs([int(y, 16) for y in value.split(' ')])
示例5: testDefModeChunkedSubst
def testDefModeChunkedSubst(self):
assert decoder.decode(
ints2octs(
(36, 23, 4, 4, 81, 117, 105, 99, 4, 4, 107, 32, 98, 114, 4, 4, 111, 119, 110, 32, 4, 3, 102, 111, 120)
),
substrateFun=lambda a, b, c: (b, c),
) == (
ints2octs((4, 4, 81, 117, 105, 99, 4, 4, 107, 32, 98, 114, 4, 4, 111, 119, 110, 32, 4, 3, 102, 111, 120)),
23,
)
示例6: testWithOptionalAndDefaultedIndefModeSubst
def testWithOptionalAndDefaultedIndefModeSubst(self):
assert decoder.decode(
ints2octs(
(48, 128, 5, 0, 36, 128, 4, 11, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 0, 0, 2, 1, 1, 0, 0)
),
substrateFun=lambda a, b, c: (b, c),
) == (
ints2octs((5, 0, 36, 128, 4, 11, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 0, 0, 2, 1, 1, 0, 0)),
-1,
)
示例7: encode
def encode(self, value, asn1Spec=None, encodeFun=None, **options):
if asn1Spec is None:
tagSet = value.tagSet
else:
tagSet = asn1Spec.tagSet
# untagged item?
if not tagSet:
substrate, isConstructed, isOctets = self.encodeValue(
value, asn1Spec, encodeFun, **options
)
return substrate
defMode = options.get('defMode', True)
for idx, singleTag in enumerate(tagSet.superTags):
defModeOverride = defMode
# base tag?
if not idx:
substrate, isConstructed, isOctets = self.encodeValue(
value, asn1Spec, encodeFun, **options
)
if not substrate and isConstructed and options.get('ifNotEmpty', False):
return substrate
# primitive form implies definite mode
if not isConstructed:
defModeOverride = True
header = self.encodeTag(singleTag, isConstructed)
header += self.encodeLength(len(substrate), defModeOverride)
if isOctets:
substrate = ints2octs(header) + substrate
if not defModeOverride:
substrate += self.eooOctetsSubstrate
else:
substrate = header + substrate
if not defModeOverride:
substrate += self.eooIntegerSubstrate
if not isOctets:
substrate = ints2octs(substrate)
return substrate
示例8: testReservedLength
def testReservedLength(self):
try:
decoder.decode(ints2octs((6, 255, 0)))
except PyAsn1Error:
pass
else:
assert 0, 'reserved length tolarated'
示例9: testIndefiniteLength
def testIndefiniteLength(self):
try:
decoder.decode(ints2octs((6, 128, 0)))
except PyAsn1Error:
pass
else:
assert 0, 'indefinite length tolarated'
示例10: __init__
def __init__(self, tagMap, typeMap={}):
self.__tagMap = tagMap
self.__typeMap = typeMap
# Tag & TagSet objects caches
self.__tagCache = {}
self.__tagSetCache = {}
self.__eooSentinel = ints2octs((0, 0))
示例11: testTagFormat
def testTagFormat(self):
try:
decoder.decode(ints2octs((33, 1, 1)))
except PyAsn1Error:
pass
else:
assert 0, 'wrong tagFormat worked out'
示例12: testNoConstructedEoo
def testNoConstructedEoo(self):
try:
decoder.decode(ints2octs((0x23, 0x80, 0x20, 0x00)))
except PyAsn1Error:
pass
else:
assert 0, 'end-of-contents octets accepted with invalid constructed encoding'
示例13: testDefiniteNoEoo
def testDefiniteNoEoo(self):
try:
decoder.decode(ints2octs((0x23, 0x02, 0x00, 0x00)))
except PyAsn1Error:
pass
else:
assert 0, 'end-of-contents octets accepted inside definite-length encoding'
示例14: testBin3
def testBin3(self):
# change binEncBase in the RealEncoder instance => for all further Real
binEncBase, encoder.typeMap[univ.Real.typeId].binEncBase = encoder.typeMap[univ.Real.typeId].binEncBase, 16
assert encoder.encode(
univ.Real((0.00390625, 2, 0)) # check encbase = 16
) == ints2octs((9, 3, 160, 254, 1))
encoder.typeMap[univ.Real.typeId].binEncBase = binEncBase
示例15: testLarge2
def testLarge2(self):
assert decoder.decode(
ints2octs(
(
0x06,
0x13,
0x88,
0x37,
0x83,
0xC6,
0xDF,
0xD4,
0xCC,
0xB3,
0xFF,
0xFF,
0xFE,
0xF0,
0xB8,
0xD6,
0xB8,
0xCB,
0xE2,
0xB6,
0x47,
)
)
) == ((2, 999, 18446744073709551535184467440737095), null)