本文整理汇总了Python中asn1crypto.core.Integer方法的典型用法代码示例。如果您正苦于以下问题:Python core.Integer方法的具体用法?Python core.Integer怎么用?Python core.Integer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类asn1crypto.core
的用法示例。
在下文中一共展示了core.Integer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: compare_primitive_info
# 需要导入模块: from asn1crypto import core [as 别名]
# 或者: from asn1crypto.core import Integer [as 别名]
def compare_primitive_info():
return (
(core.ObjectIdentifier('1.2.3'), core.ObjectIdentifier('1.2.3'), True),
(core.Integer(1), Enum(1), False),
(core.Integer(1), core.Integer(1, implicit=5), True),
(core.Integer(1), core.Integer(1, explicit=5), True),
(core.Integer(1), core.Integer(2), False),
(core.OctetString(b''), core.OctetString(b''), True),
(core.OctetString(b''), core.OctetString(b'1'), False),
(core.OctetString(b''), core.OctetBitString(b''), False),
(core.ParsableOctetString(b'12'), core.OctetString(b'12'), True),
(core.ParsableOctetBitString(b'12'), core.OctetBitString(b'12'), True),
(core.UTF8String('12'), core.UTF8String('12'), True),
(core.UTF8String('12'), core.UTF8String('1'), False),
(core.UTF8String('12'), core.IA5String('12'), False),
)
示例2: test_dsa_public_key_unwrap
# 需要导入模块: from asn1crypto import core [as 别名]
# 或者: from asn1crypto.core import Integer [as 别名]
def test_dsa_public_key_unwrap(self):
public = asymmetric.load_public_key(os.path.join(fixtures_dir, 'keys/test-dsa-1024.crt'))
self.assertIsInstance(public.unwrap(), core.Integer)
示例3: test_sequence_spec
# 需要导入模块: from asn1crypto import core [as 别名]
# 或者: from asn1crypto.core import Integer [as 别名]
def test_sequence_spec(self):
seq = Seq()
seq['id'] = '1.2.3'
self.assertEqual(core.Integer, seq.spec('value'))
seq['id'] = '2.3.4'
self.assertEqual(core.OctetString, seq.spec('value'))
示例4: integer
# 需要导入模块: from asn1crypto import core [as 别名]
# 或者: from asn1crypto.core import Integer [as 别名]
def integer(self, native, der_bytes):
i = core.Integer(native)
self.assertEqual(der_bytes, i.dump())
self.assertEqual(native, core.Integer.load(der_bytes).native)
示例5: test_load
# 需要导入模块: from asn1crypto import core [as 别名]
# 或者: from asn1crypto.core import Integer [as 别名]
def test_load(self):
i = core.load(b'\x02\x01\x00')
self.assertIsInstance(i, core.Integer)
self.assertEqual(0, i.native)
示例6: test_strict_on_class
# 需要导入模块: from asn1crypto import core [as 别名]
# 或者: from asn1crypto.core import Integer [as 别名]
def test_strict_on_class(self):
with self.assertRaises(ValueError):
core.Integer.load(b'\x02\x01\x00\x00', strict=True)
示例7: test_sequence_any_asn1value
# 需要导入模块: from asn1crypto import core [as 别名]
# 或者: from asn1crypto.core import Integer [as 别名]
def test_sequence_any_asn1value(self):
seq = SequenceAny()
seq.append(core.Integer(5))
self.assertEqual([5], seq.native)
示例8: test_copy
# 需要导入模块: from asn1crypto import core [as 别名]
# 或者: from asn1crypto.core import Integer [as 别名]
def test_copy(self):
a = core.Integer(200)
b = a.copy()
self.assertNotEqual(id(a), id(b))
self.assertEqual(a.contents, b.contents)
self.assertEqual(a.dump(), b.dump())
示例9: test_retag
# 需要导入模块: from asn1crypto import core [as 别名]
# 或者: from asn1crypto.core import Integer [as 别名]
def test_retag(self):
a = core.Integer(200)
b = a.retag('explicit', 0)
self.assertNotEqual(id(a), id(b))
self.assertEqual(a.contents, b.contents)
self.assertNotEqual(a.dump(), b.dump())
示例10: test_untag
# 需要导入模块: from asn1crypto import core [as 别名]
# 或者: from asn1crypto.core import Integer [as 别名]
def test_untag(self):
a = core.Integer(200, explicit=0)
b = a.untag()
self.assertNotEqual(id(a), id(b))
self.assertEqual(a.contents, b.contents)
self.assertNotEqual(a.dump(), b.dump())
示例11: test_fix_tagging_choice
# 需要导入模块: from asn1crypto import core [as 别名]
# 或者: from asn1crypto.core import Integer [as 别名]
def test_fix_tagging_choice(self):
correct = core.Integer(200, explicit=2)
choice = NumChoice(
name='three',
value=core.Integer(200, explicit=1)
)
self.assertEqual(correct.dump(), choice.dump())
self.assertEqual(correct.explicit, choice.chosen.explicit)
choice2 = NumChoiceOldApi(
name='three',
value=core.Integer(200, explicit=1)
)
self.assertEqual(correct.dump(), choice2.dump())
self.assertEqual(correct.explicit, choice2.chosen.explicit)
示例12: test_required_field
# 需要导入模块: from asn1crypto import core [as 别名]
# 或者: from asn1crypto.core import Integer [as 别名]
def test_required_field(self):
with self.assertRaisesRegex(ValueError, '"id" is missing from structure'):
Seq({'value': core.Integer(5)}).dump()
示例13: test_wrong_asn1value
# 需要导入模块: from asn1crypto import core [as 别名]
# 或者: from asn1crypto.core import Integer [as 别名]
def test_wrong_asn1value(self):
with self.assertRaises(TypeError):
Seq({
'id': core.Integer(1),
'value': 1
})
示例14: test_wrong_asn1value2
# 需要导入模块: from asn1crypto import core [as 别名]
# 或者: from asn1crypto.core import Integer [as 别名]
def test_wrong_asn1value2(self):
with self.assertRaises(TypeError):
CopySeq({
'name': core.UTF8String('Test'),
'pair': core.Integer(1)
})
示例15: test_wrong_asn1value3
# 需要导入模块: from asn1crypto import core [as 别名]
# 或者: from asn1crypto.core import Integer [as 别名]
def test_wrong_asn1value3(self):
with self.assertRaises(TypeError):
NestSeqAny({
'id': '3.4.5',
'value': core.Integer(1)
})