本文整理匯總了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)