本文整理汇总了Python中asn1crypto.core.OctetString方法的典型用法代码示例。如果您正苦于以下问题:Python core.OctetString方法的具体用法?Python core.OctetString怎么用?Python core.OctetString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类asn1crypto.core
的用法示例。
在下文中一共展示了core.OctetString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: compare_primitive_info
# 需要导入模块: from asn1crypto import core [as 别名]
# 或者: from asn1crypto.core import OctetString [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_sequence_spec
# 需要导入模块: from asn1crypto import core [as 别名]
# 或者: from asn1crypto.core import OctetString [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'))
示例3: test_indefinite_length_octet_string
# 需要导入模块: from asn1crypto import core [as 别名]
# 或者: from asn1crypto.core import OctetString [as 别名]
def test_indefinite_length_octet_string(self):
data = b'$\x80\x04\x02\x01\x01\x04\x01\x01\x00\x00'
a = core.OctetString.load(data)
self.assertEqual(b'\x01\x01\x01', a.native)
self.assertEqual(b'\x01\x01\x01', a.__bytes__())
self.assertEqual(1, a.method)
# Test copying moves internal state
self.assertEqual(a._bytes, a.copy()._bytes)
示例4: test_indefinite_length_octet_string_2
# 需要导入模块: from asn1crypto import core [as 别名]
# 或者: from asn1crypto.core import OctetString [as 别名]
def test_indefinite_length_octet_string_2(self):
data = b'$\x80\x04\r\x8d\xff\xf0\x98\x076\xaf\x93nB:\xcf\xcc\x04\x15' \
b'\x92w\xf7\xf0\xe4y\xff\xc7\xdc3\xb2\xd0={\x1a\x18mDr\xaaI\x00\x00'
a = core.OctetString.load(data)
self.assertEqual(
b'\x8d\xff\xf0\x98\x076\xaf\x93nB:\xcf\xcc\x92w\xf7\xf0\xe4y\xff\xc7\xdc3\xb2\xd0={\x1a\x18mDr\xaaI',
a.native
)
示例5: test_indefinite_length_integer_octet_string
# 需要导入模块: from asn1crypto import core [as 别名]
# 或者: from asn1crypto.core import OctetString [as 别名]
def test_indefinite_length_integer_octet_string(self):
data = b'$\x80\x04\x02\x01\x01\x04\x01\x01\x00\x00'
a = core.IntegerOctetString.load(data)
self.assertEqual(65793, a.native)
self.assertEqual(1, a.method)
self.assertEqual(b'\x01\x01\x01', a.cast(core.OctetString).native)
示例6: test_ccm_parameters
# 需要导入模块: from asn1crypto import core [as 别名]
# 或者: from asn1crypto.core import OctetString [as 别名]
def test_ccm_parameters(self):
with open(os.path.join(fixtures_dir, 'aesccm_algo.der'), 'rb') as f:
# PBES2 AlgorithmIdentifier
algo = algos.EncryptionAlgorithm().load(f.read())
scheme = algo['parameters']['encryption_scheme']
self.assertEqual(scheme['parameters'].__class__, algos.CcmParams)
self.assertEqual(scheme['parameters']['aes_nonce'].__class__, core.OctetString)
self.assertEqual(scheme['parameters']['aes_nonce'].native, b'z\xb7\xbd\xb7\xe1\xc6\xc0\x11\xc1?\xf00')
self.assertEqual(scheme['parameters']['aes_icvlen'].__class__, core.Integer)
self.assertEqual(scheme['parameters']['aes_icvlen'].native, 8)