當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。