当前位置: 首页>>代码示例>>Python>>正文


Python univ.Null方法代码示例

本文整理汇总了Python中pyasn1.type.univ.Null方法的典型用法代码示例。如果您正苦于以下问题:Python univ.Null方法的具体用法?Python univ.Null怎么用?Python univ.Null使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyasn1.type.univ的用法示例。


在下文中一共展示了univ.Null方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: valueDecoder

# 需要导入模块: from pyasn1.type import univ [as 别名]
# 或者: from pyasn1.type.univ import Null [as 别名]
def valueDecoder(self, substrate, asn1Spec,
                     tagSet=None, length=None, state=None,
                     decodeFun=None, substrateFun=None,
                     **options):

        if tagSet[0].tagFormat != tag.tagFormatSimple:
            raise error.PyAsn1Error('Simple tag format expected')

        head, tail = substrate[:length], substrate[length:]

        component = self._createComponent(asn1Spec, tagSet, '', **options)

        if head:
            raise error.PyAsn1Error('Unexpected %d-octet substrate for Null' % length)

        return component, tail 
开发者ID:tp4a,项目名称:teleport,代码行数:18,代码来源:decoder.py

示例2: testOpenTypes

# 需要导入模块: from pyasn1.type import univ [as 别名]
# 或者: from pyasn1.type.univ import Null [as 别名]
def testOpenTypes(self):
        substrate = pem.readBase64fromText(self.signed_pem_text)
        asn1Object, rest = der_decoder(
            substrate, asn1Spec=self.asn1Spec, decodeOpenTypes=True)
        self.assertFalse(rest)
        self.assertTrue(asn1Object.prettyPrint())
        self.assertEqual(substrate, der_encoder(asn1Object))
        self.assertEqual(rfc5652.id_signedData, asn1Object['contentType'])

        si = asn1Object['content']['signerInfos'][0]
        self.assertEqual(rfc4357.id_GostR3411_94, si['digestAlgorithm']['algorithm'])
        self.assertEqual(univ.Null(""), si['digestAlgorithm']['parameters'])

        self.assertEqual(rfc4357.id_GostR3410_2001, si['signatureAlgorithm']['algorithm'])
        self.assertEqual(univ.Null(""), si['signatureAlgorithm']['parameters'])

        sig = rfc4490.GostR3410_2001_Signature()
        sig = si['signature']
        self.assertEqual(64, len(sig)) 
开发者ID:etingof,项目名称:pyasn1-modules,代码行数:21,代码来源:test_rfc4490.py

示例3: testOpenTypes

# 需要导入模块: from pyasn1.type import univ [as 别名]
# 或者: from pyasn1.type.univ import Null [as 别名]
def testOpenTypes(self):
        substrate = pem.readBase64fromText(self.oaep_full_pem_text)
        asn1Object, rest = der_decoder.decode(substrate,
                                              asn1Spec=self.asn1Spec,
                                              decodeOpenTypes=True)
        self.assertFalse(rest)
        self.assertTrue(asn1Object.prettyPrint())
        self.assertEqual(substrate, der_encoder.encode(asn1Object))

        self.assertTrue(asn1Object['parameters'].hasValue())

        oaep_p = asn1Object['parameters']

        self.assertEqual(univ.Null(""), oaep_p['hashFunc']['parameters'])
        self.assertEqual(
            univ.Null(""), oaep_p['maskGenFunc']['parameters']['parameters'])
        self.assertEqual(
            univ.OctetString(value='foobar'),
            oaep_p['pSourceFunc']['parameters']) 
开发者ID:etingof,项目名称:pyasn1-modules,代码行数:21,代码来源:test_rfc4055.py

示例4: testDerCodec

# 需要导入模块: from pyasn1.type import univ [as 别名]
# 或者: from pyasn1.type.univ import Null [as 别名]
def testDerCodec(self):
        substrate = pem.readBase64fromText(self.signed_pem_text)
        asn1Object, rest = der_decoder(substrate, asn1Spec=self.asn1Spec)
        self.assertFalse(rest)
        self.assertTrue(asn1Object.prettyPrint())
        self.assertEqual(substrate, der_encoder(asn1Object))
        self.assertEqual(rfc5652.id_signedData, asn1Object['contentType'])
        
        sd, rest = der_decoder(
            asn1Object['content'], asn1Spec=rfc5652.SignedData())
        self.assertFalse(rest)
        self.assertTrue(sd.prettyPrint())
        self.assertEqual(asn1Object['content'], der_encoder(sd))

        encoded_null = der_encoder(univ.Null(""))

        si = sd['signerInfos'][0]
        self.assertEqual(rfc4357.id_GostR3411_94, si['digestAlgorithm']['algorithm'])
        self.assertEqual(encoded_null, si['digestAlgorithm']['parameters'])

        self.assertEqual(rfc4357.id_GostR3410_2001, si['signatureAlgorithm']['algorithm'])
        self.assertEqual(encoded_null, si['signatureAlgorithm']['parameters'])
        self.assertEqual(64, len(si['signature'])) 
开发者ID:etingof,项目名称:pyasn1-modules,代码行数:25,代码来源:test_rfc4357.py

示例5: testOpenTypes

# 需要导入模块: from pyasn1.type import univ [as 别名]
# 或者: from pyasn1.type.univ import Null [as 别名]
def testOpenTypes(self):
        substrate = pem.readBase64fromText(self.signed_pem_text)
        asn1Object, rest = der_decoder(
            substrate, asn1Spec=self.asn1Spec, decodeOpenTypes=True)
        self.assertFalse(rest)
        self.assertTrue(asn1Object.prettyPrint())
        self.assertEqual(substrate, der_encoder(asn1Object))
        self.assertEqual(rfc5652.id_signedData, asn1Object['contentType'])

        si = asn1Object['content']['signerInfos'][0]
        self.assertEqual(rfc4357.id_GostR3411_94, si['digestAlgorithm']['algorithm'])
        self.assertEqual(univ.Null(""), si['digestAlgorithm']['parameters'])

        self.assertEqual(rfc4357.id_GostR3410_2001, si['signatureAlgorithm']['algorithm'])
        self.assertEqual(univ.Null(""), si['signatureAlgorithm']['parameters'])

        self.assertEqual(64, len(si['signature'])) 
开发者ID:etingof,项目名称:pyasn1-modules,代码行数:19,代码来源:test_rfc4357.py

示例6: testOpenTypes

# 需要导入模块: from pyasn1.type import univ [as 别名]
# 或者: from pyasn1.type.univ import Null [as 别名]
def testOpenTypes(self):
        openTypesMap = {
            rfc3537.id_alg_HMACwithAESwrap: univ.Null(""),
            rfc3537.id_alg_HMACwith3DESwrap: univ.Null(""),
        }

        asn1Spec=rfc5751.SMIMECapabilities()
        substrate = pem.readBase64fromText(self.smime_capabilities_pem_text)
        asn1Object, rest = der_decoder(
            substrate, asn1Spec=self.asn1Spec,
            openTypes=openTypesMap, decodeOpenTypes=True)
        self.assertFalse(rest)
        self.assertTrue(asn1Object.prettyPrint())
        self.assertEqual(substrate, der_encoder(asn1Object))

        count = 0
        for cap in asn1Object:
            self.assertEqual(univ.Null(""), cap['parameters'])
            self.assertTrue(cap['capabilityID'] in openTypesMap.keys())
            count += 1

        self.assertEqual(count, 2) 
开发者ID:etingof,项目名称:pyasn1-modules,代码行数:24,代码来源:test_rfc3537.py

示例7: testOpenTypes

# 需要导入模块: from pyasn1.type import univ [as 别名]
# 或者: from pyasn1.type.univ import Null [as 别名]
def testOpenTypes(self):
        substrate = pem.readBase64fromText(self.pem_text)
        asn1Object, rest = der_decoder(
            substrate, asn1Spec=self.asn1Spec, decodeOpenTypes=True)

        self.assertFalse(rest)
        self.assertTrue(asn1Object.prettyPrint())
        self.assertEqual(substrate, der_encoder(asn1Object))

        spki_a = asn1Object['certificationRequestInfo']['subjectPublicKeyInfo']['algorithm']

        self.assertEqual(rfc5480.dhpublicnumber, spki_a['algorithm'])
        self.assertEqual(
            55, spki_a['parameters']['validationParms']['pgenCounter'])

        sig_a = asn1Object['signatureAlgorithm']

        self.assertEqual(
            rfc6955.id_dhPop_static_sha1_hmac_sha1, sig_a['algorithm'])
        self.assertEqual(univ.Null(""), sig_a['parameters']) 
开发者ID:etingof,项目名称:pyasn1-modules,代码行数:22,代码来源:test_rfc6955.py

示例8: testOpenTypes

# 需要导入模块: from pyasn1.type import univ [as 别名]
# 或者: from pyasn1.type.univ import Null [as 别名]
def testOpenTypes(self):
        substrate = pem.readBase64fromText(self.env_data_pem_text)
        asn1Object, rest = der_decoder(
            substrate, asn1Spec=self.asn1Spec, decodeOpenTypes=True)

        self.assertFalse(rest)
        self.assertTrue(asn1Object.prettyPrint())
        self.assertEqual(substrate, der_encoder(asn1Object))

        kekri = asn1Object['content']['recipientInfos'][0]['kekri']
        kwa = kekri['keyEncryptionAlgorithm']
        self.assertEqual(rfc3058.id_alg_CMSIDEAwrap, kwa['algorithm'])
        self.assertEqual(univ.Null(""), kwa['parameters'])

        eci = asn1Object['content']['encryptedContentInfo']
        cea = eci['contentEncryptionAlgorithm']
        self.assertEqual(rfc3058.id_IDEA_CBC, cea['algorithm'])

        iv = univ.OctetString(hexValue='424f4755535f4956')
        self.assertEqual(iv, cea['parameters']['iv']) 
开发者ID:etingof,项目名称:pyasn1-modules,代码行数:22,代码来源:test_rfc3058.py

示例9: convertPKCS1toPKCS8pubKey

# 需要导入模块: from pyasn1.type import univ [as 别名]
# 或者: from pyasn1.type.univ import Null [as 别名]
def convertPKCS1toPKCS8pubKey(bitsdata):
    pubkey_pkcs1_b64 = b''.join(bitsdata.split(b'\n')[1:-2])
    pubkey_pkcs1, restOfInput = der_decoder.decode(base64.b64decode(pubkey_pkcs1_b64))
    bitstring = univ.Sequence()
    bitstring.setComponentByPosition(0, univ.Integer(pubkey_pkcs1[0]))
    bitstring.setComponentByPosition(1, univ.Integer(pubkey_pkcs1[1]))
    bitstring = der_encoder.encode(bitstring)
    try:
        bitstring = ''.join([('00000000'+bin(ord(x))[2:])[-8:] for x in list(bitstring)])
    except:
        bitstring = ''.join([('00000000'+bin(x)[2:])[-8:] for x in list(bitstring)])
    bitstring = univ.BitString("'%s'B" % bitstring)
    pubkeyid = univ.Sequence()
    pubkeyid.setComponentByPosition(0, univ.ObjectIdentifier('1.2.840.113549.1.1.1')) # == OID for rsaEncryption
    pubkeyid.setComponentByPosition(1, univ.Null(''))
    pubkey_seq = univ.Sequence()
    pubkey_seq.setComponentByPosition(0, pubkeyid)
    pubkey_seq.setComponentByPosition(1, bitstring)
    base64.MAXBINSIZE = (64//4)*3
    res =  b"-----BEGIN PUBLIC KEY-----\n"
    res += base64.encodestring(der_encoder.encode(pubkey_seq))
    res += b"-----END PUBLIC KEY-----\n"
    return res 
开发者ID:iOSForensics,项目名称:pymobiledevice,代码行数:25,代码来源:ca.py

示例10: valueDecoder

# 需要导入模块: from pyasn1.type import univ [as 别名]
# 或者: from pyasn1.type.univ import Null [as 别名]
def valueDecoder(self, substrate, asn1Spec,
                     tagSet=None, length=None, state=None,
                     decodeFun=None, substrateFun=None,
                     **options):

        if tagSet[0].tagFormat != tag.tagFormatSimple:
            raise error.PyAsn1Error('Simple tag format expected')

        head, tail = substrate[:length], substrate[length:]

        component = self._createComponent(asn1Spec, tagSet)

        if head:
            raise error.PyAsn1Error('Unexpected %d-octet substrate for Null' % length)

        return component, tail 
开发者ID:aws-samples,项目名称:aws-kube-codesuite,代码行数:18,代码来源:decoder.py

示例11: valueDecoder

# 需要导入模块: from pyasn1.type import univ [as 别名]
# 或者: from pyasn1.type.univ import Null [as 别名]
def valueDecoder(self, fullSubstrate, substrate, asn1Spec, tagSet,
                     length, state, decodeFun, substrateFun):
        head, tail = substrate[:length], substrate[length:]
        r = self._createComponent(asn1Spec, tagSet)
        if head:
            raise error.PyAsn1Error('Unexpected %d-octet substrate for Null' % length)
        return r, tail 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:9,代码来源:decoder.py

示例12: testOpenTypes

# 需要导入模块: from pyasn1.type import univ [as 别名]
# 或者: from pyasn1.type.univ import Null [as 别名]
def testOpenTypes(self):
        substrate = pem.readBase64fromText(self.rsa_cert_pem_text)
        asn1Object, rest = der_decoder(
            substrate, asn1Spec=self.asn1Spec, decodeOpenTypes=True)

        self.assertFalse(rest)
        self.assertTrue(asn1Object.prettyPrint())
        self.assertEqual(substrate, der_encoder(asn1Object))

        spki_a = asn1Object['tbsCertificate']['subjectPublicKeyInfo']['algorithm']

        self.assertEqual(rfc3279.rsaEncryption, spki_a['algorithm'])
        self.assertEqual(univ.Null(""), spki_a['parameters']) 
开发者ID:etingof,项目名称:pyasn1-modules,代码行数:15,代码来源:test_rfc3279.py

示例13: testDerCodec

# 需要导入模块: from pyasn1.type import univ [as 别名]
# 或者: from pyasn1.type.univ import Null [as 别名]
def testDerCodec(self):
        substrate = pem.readBase64fromText(self.signed_pem_text)
        asn1Object, rest = der_decoder(substrate, asn1Spec=self.asn1Spec)
        self.assertFalse(rest)
        self.assertTrue(asn1Object.prettyPrint())
        self.assertEqual(substrate, der_encoder(asn1Object))
        self.assertEqual(rfc5652.id_signedData, asn1Object['contentType'])
        
        sd, rest = der_decoder(
            asn1Object['content'], asn1Spec=rfc5652.SignedData())
        self.assertFalse(rest)
        self.assertTrue(sd.prettyPrint())
        self.assertEqual(asn1Object['content'], der_encoder(sd))

        encoded_null = der_encoder(univ.Null(""))

        si = sd['signerInfos'][0]
        self.assertEqual(rfc4357.id_GostR3411_94, si['digestAlgorithm']['algorithm'])
        self.assertEqual(encoded_null, si['digestAlgorithm']['parameters'])

        self.assertEqual(rfc4357.id_GostR3410_2001, si['signatureAlgorithm']['algorithm'])
        self.assertEqual(encoded_null, si['signatureAlgorithm']['parameters'])

        sig = rfc4490.GostR3410_2001_Signature()
        sig = si['signature']
        self.assertEqual(64, len(sig)) 
开发者ID:etingof,项目名称:pyasn1-modules,代码行数:28,代码来源:test_rfc4490.py

示例14: testDerCodec

# 需要导入模块: from pyasn1.type import univ [as 别名]
# 或者: from pyasn1.type.univ import Null [as 别名]
def testDerCodec(self):
        substrate = pem.readBase64fromText(self.smime_capabilities_pem_text)
        asn1Object, rest = der_decoder(substrate, asn1Spec=self.asn1Spec)

        self.assertFalse(rest)
        self.assertTrue(asn1Object.prettyPrint())
        self.assertEqual(substrate, der_encoder(asn1Object))

        for cap in asn1Object:
            self.assertIn(cap['algorithm'], rfc5280.algorithmIdentifierMap)

            if cap['parameters'].hasValue():
                p, rest = der_decoder(
                    cap['parameters'],
                    asn1Spec=rfc5280.algorithmIdentifierMap[cap['algorithm']])

                self.assertFalse(rest)
                if not p == univ.Null(""):
                    self.assertTrue(p.prettyPrint())
                self.assertEqual(cap['parameters'], der_encoder(p))

                if cap['algorithm'] == rfc8017.id_RSAES_OAEP:
                    self.assertEqual(
                        rfc8017.id_sha384, p['hashFunc']['algorithm'])
                    self.assertEqual(
                        rfc8017.id_mgf1, p['maskGenFunc']['algorithm']) 
开发者ID:etingof,项目名称:pyasn1-modules,代码行数:28,代码来源:test_rfc8017.py

示例15: testDerCodec

# 需要导入模块: from pyasn1.type import univ [as 别名]
# 或者: from pyasn1.type.univ import Null [as 别名]
def testDerCodec(self):

        substrate = pem.readBase64fromText(self.pem_text)

        openTypesMap = {
            univ.ObjectIdentifier('1.2.840.113549.1.1.1'): univ.Null(""),
            univ.ObjectIdentifier('1.2.840.113549.1.1.5'): univ.Null(""),
            univ.ObjectIdentifier('1.2.840.113549.1.1.11'): univ.Null(""),
        }

        asn1Object, rest = der_decoder(
            substrate, asn1Spec=self.asn1Spec, openTypes=openTypesMap,
            decodeOpenTypes=True)

        self.assertFalse(rest)
        self.assertTrue(asn1Object.prettyPrint())
        self.assertEqual(substrate, der_encoder(asn1Object))

        sig_alg = asn1Object['tbsCertificate']['signature']

        self.assertEqual(univ.Null(""), sig_alg['parameters'])

        spki_alg = asn1Object['tbsCertificate']['subjectPublicKeyInfo']['algorithm']

        self.assertEqual(univ.Null(""), spki_alg['parameters'])

        for rdn in asn1Object['tbsCertificate']['subject']['rdnSequence']:
            for atv in rdn:
                if atv['type'] == rfc5280.id_emailAddress:
                    self.assertIn("valicert.com", atv['value'])
                else:
                    atv_ps = str(atv['value']['printableString'])
                    self.assertIn("valicert", atv_ps.lower()) 
开发者ID:etingof,项目名称:pyasn1-modules,代码行数:35,代码来源:test_rfc5280.py


注:本文中的pyasn1.type.univ.Null方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。