當前位置: 首頁>>代碼示例>>Python>>正文


Python univ.ObjectIdentifier方法代碼示例

本文整理匯總了Python中pyasn1.type.univ.ObjectIdentifier方法的典型用法代碼示例。如果您正苦於以下問題:Python univ.ObjectIdentifier方法的具體用法?Python univ.ObjectIdentifier怎麽用?Python univ.ObjectIdentifier使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pyasn1.type.univ的用法示例。


在下文中一共展示了univ.ObjectIdentifier方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: testDerCodec

# 需要導入模塊: from pyasn1.type import univ [as 別名]
# 或者: from pyasn1.type.univ import ObjectIdentifier [as 別名]
def testDerCodec(self):
        substrate = pem.readBase64fromText(self.ec_cert_pem_text)
        asn1Object, rest = der_decoder(substrate, asn1Spec=self.asn1Spec)

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

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

        self.assertEqual(rfc3279.id_ecPublicKey, spki_a['algorithm'])

        spki_a_p, rest = der_decoder(
            spki_a['parameters'], asn1Spec=rfc3279.EcpkParameters())

        self.assertFalse(rest)
        self.assertTrue(spki_a_p.prettyPrint())
        self.assertEqual(spki_a['parameters'], der_encoder(spki_a_p))
        self.assertEqual(univ.ObjectIdentifier('1.3.132.0.34'), spki_a_p['namedCurve']) 
開發者ID:etingof,項目名稱:pyasn1-modules,代碼行數:21,代碼來源:test_rfc3279.py

示例2: testOpenTypes

# 需要導入模塊: from pyasn1.type import univ [as 別名]
# 或者: from pyasn1.type.univ import ObjectIdentifier [as 別名]
def testOpenTypes(self):
        substrate = pem.readBase64fromText(self.asymmetric_key_pkg_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.assertIn(
            rfc5958.id_ct_KP_aKeyPackage, rfc5652.cmsContentTypesMap)

        oneKey = asn1Object['content'][0]

        self.assertEqual(
            rfc8410.id_Ed25519, oneKey['privateKeyAlgorithm']['algorithm'])

        pkcs_9_at_friendlyName = univ.ObjectIdentifier('1.2.840.113549.1.9.9.20')

        self.assertEqual(
            pkcs_9_at_friendlyName, oneKey['attributes'][0]['attrType']) 
開發者ID:etingof,項目名稱:pyasn1-modules,代碼行數:22,代碼來源:test_rfc5958.py

示例3: testOpenTypes

# 需要導入模塊: from pyasn1.type import univ [as 別名]
# 或者: from pyasn1.type.univ import ObjectIdentifier [as 別名]
def testOpenTypes(self):
        openTypesMap = rfc5652.cmsAttributesMap.copy()

        for at in self.the_attrTypes:
            openTypesMap.update({at: univ.ObjectIdentifier()})

        substrate = pem.readBase64fromText(self.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))

        for attr_or_oid in asn1Object:
            if attr_or_oid.getName() == 'attribute':
                valString = attr_or_oid['attribute']['attrValues'][0].prettyPrint()

                if attr_or_oid['attribute']['attrType'] == self.the_attrTypes[0]:
                    self.assertEqual(self.the_attrVals[0], valString)

                if attr_or_oid['attribute']['attrType'] == self.the_attrTypes[1]:
                    self.assertEqual(self.the_attrVals[1], valString) 
開發者ID:etingof,項目名稱:pyasn1-modules,代碼行數:26,代碼來源:test_rfc7030.py

示例4: load_pkcs1_openssl_der

# 需要導入模塊: from pyasn1.type import univ [as 別名]
# 或者: from pyasn1.type.univ import ObjectIdentifier [as 別名]
def load_pkcs1_openssl_der(cls, keyfile):
        """Loads a PKCS#1 DER-encoded public key file from OpenSSL.

        :param keyfile: contents of a DER-encoded file that contains the public
            key, from OpenSSL.
        :return: a PublicKey object

        """

        from rsa.asn1 import OpenSSLPubKey
        from pyasn1.codec.der import decoder
        from pyasn1.type import univ

        (keyinfo, _) = decoder.decode(keyfile, asn1Spec=OpenSSLPubKey())

        if keyinfo['header']['oid'] != univ.ObjectIdentifier('1.2.840.113549.1.1.1'):
            raise TypeError("This is not a DER-encoded OpenSSL-compatible public key")

        return cls._load_pkcs1_der(keyinfo['key'][1:]) 
開發者ID:Deltares,項目名稱:aqua-monitor,代碼行數:21,代碼來源:key.py

示例5: load_pkcs1_openssl_der

# 需要導入模塊: from pyasn1.type import univ [as 別名]
# 或者: from pyasn1.type.univ import ObjectIdentifier [as 別名]
def load_pkcs1_openssl_der(cls, keyfile):
        '''Loads a PKCS#1 DER-encoded public key file from OpenSSL.

        @param keyfile: contents of a DER-encoded file that contains the public
            key, from OpenSSL.
        @return: a PublicKey object
        '''
    
        from rsa.asn1 import OpenSSLPubKey
        from pyasn1.codec.der import decoder
        from pyasn1.type import univ
        
        (keyinfo, _) = decoder.decode(keyfile, asn1Spec=OpenSSLPubKey())
        
        if keyinfo['header']['oid'] != univ.ObjectIdentifier('1.2.840.113549.1.1.1'):
            raise TypeError("This is not a DER-encoded OpenSSL-compatible public key")
                
        return cls._load_pkcs1_der(keyinfo['key'][1:]) 
開發者ID:deadblue,項目名稱:baidupan_shell,代碼行數:20,代碼來源:key.py

示例6: oidToMibName

# 需要導入模塊: from pyasn1.type import univ [as 別名]
# 或者: from pyasn1.type.univ import ObjectIdentifier [as 別名]
def oidToMibName(mibView, oid):
    if not isinstance(oid, tuple):
        oid = tuple(univ.ObjectIdentifier(oid))
    _oid, label, suffix = mibView.getNodeNameByOid(oid)
    modName, symName, __suffix = mibView.getNodeLocation(_oid)
    mibNode, = mibView.mibBuilder.importSymbols(
        modName, symName
        )
    if hasattr(mibNode, 'createTest'): # table column
        __modName, __symName, __s = mibView.getNodeLocation(_oid[:-1])
        rowNode, = mibView.mibBuilder.importSymbols(__modName, __symName)
        return (symName, modName), rowNode.getIndicesFromInstId(suffix)
    elif not suffix: # scalar
        return (symName, modName), suffix
    elif suffix == (0,): # scalar
        return (symName, modName), __scalarSuffix
    else:
        raise NoSuchObjectError(
            str='No MIB registered that defines %s object, closest known parent is %s (%s::%s)' % (univ.ObjectIdentifier(oid), univ.ObjectIdentifier(mibNode.name), modName, symName)
            )

# Value 
開發者ID:scalyr,項目名稱:scalyr-agent-2,代碼行數:24,代碼來源:mibvar.py

示例7: generateNegotiateSecurityBlob

# 需要導入模塊: from pyasn1.type import univ [as 別名]
# 或者: from pyasn1.type.univ import ObjectIdentifier [as 別名]
def generateNegotiateSecurityBlob(ntlm_data):
    mech_token = univ.OctetString(ntlm_data).subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))
    mech_types = MechTypeList().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))
    mech_types.setComponentByPosition(0, univ.ObjectIdentifier('1.3.6.1.4.1.311.2.2.10'))

    n = NegTokenInit().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))
    n.setComponentByName('mechTypes', mech_types)
    n.setComponentByName('mechToken', mech_token)

    nt = NegotiationToken()
    nt.setComponentByName('negTokenInit', n)

    ct = ContextToken()
    ct.setComponentByName('thisMech', univ.ObjectIdentifier('1.3.6.1.5.5.2'))
    ct.setComponentByName('innerContextToken', nt)

    return encoder.encode(ct) 
開發者ID:alfa-addon,項目名稱:addon,代碼行數:19,代碼來源:securityblob.py

示例8: _load_rsa_private_key

# 需要導入模塊: from pyasn1.type import univ [as 別名]
# 或者: from pyasn1.type.univ import ObjectIdentifier [as 別名]
def _load_rsa_private_key(pem):
  """PEM encoded PKCS#8 private key -> rsa.PrivateKey."""
  # ADB uses private RSA keys in pkcs#8 format. 'rsa' library doesn't support
  # them natively. Do some ASN unwrapping to extract naked RSA key
  # (in der-encoded form). See https://www.ietf.org/rfc/rfc2313.txt.
  # Also http://superuser.com/a/606266.
  try:
    der = rsa.pem.load_pem(pem, 'PRIVATE KEY')
    keyinfo, _ = decoder.decode(der)
    if keyinfo[1][0] != univ.ObjectIdentifier(
        '1.2.840.113549.1.1.1'):  # pragma: no cover
      raise ValueError('Not a DER-encoded OpenSSL private RSA key')
    private_key_der = keyinfo[2].asOctets()
  except IndexError:  # pragma: no cover
    raise ValueError('Not a DER-encoded OpenSSL private RSA key')
  return rsa.PrivateKey.load_pkcs1(private_key_der, format='DER') 
開發者ID:luci,項目名稱:luci-py,代碼行數:18,代碼來源:sign_pythonrsa.py

示例9: _parse_private_key

# 需要導入模塊: from pyasn1.type import univ [as 別名]
# 或者: from pyasn1.type.univ import ObjectIdentifier [as 別名]
def _parse_private_key(pem):
  """PEM encoded OpenSSL private RSA key -> rsa.PrivateKey."""
  # Cloud console generates OpenSSL compatible private RSA keys. 'rsa' library
  # doesn't support them natively. Do some ASN unwrapping to extract naked
  # RSA key (in der-encoded form). See https://www.ietf.org/rfc/rfc2313.txt.
  try:
    der = rsa.pem.load_pem(pem, 'PRIVATE KEY')
    keyinfo, _ = decoder.decode(der)
    if keyinfo[1][0] != univ.ObjectIdentifier('1.2.840.113549.1.1.1'):
      raise BadServiceAccountCredentials(
          'Not a DER-encoded OpenSSL private RSA key')
    private_key_der = keyinfo[2].asOctets()
  except IndexError:
    raise BadServiceAccountCredentials(
        'Not a DER-encoded OpenSSL private RSA key')
  return rsa.PrivateKey.load_pkcs1(private_key_der, format='DER') 
開發者ID:luci,項目名稱:luci-py,代碼行數:18,代碼來源:oauth.py

示例10: _decode_authencrypt

# 需要導入模塊: from pyasn1.type import univ [as 別名]
# 或者: from pyasn1.type.univ import ObjectIdentifier [as 別名]
def _decode_authencrypt(self, buff):
        _, remains = der_decode(buff, ObjectIdentifier())
        mac_oid, remains = der_decode(remains, ObjectIdentifier())
        encryption_oid, remains = der_decode(remains, ObjectIdentifier())

        if self.DEBUG:
            sys.stderr.write("Decoded Algorithm OIDS\n Encryption Algorithm OID: {0}\n MAC Algorithm OID: {1}\n".format(encryption_oid, mac_oid))
        return encryption_oid, mac_oid, remains 
開發者ID:fireeye,項目名稱:ADFSpoof,代碼行數:10,代碼來源:EncryptedPfx.py

示例11: OidFromAttid

# 需要導入模塊: from pyasn1.type import univ [as 別名]
# 或者: from pyasn1.type.univ import ObjectIdentifier [as 別名]
def OidFromAttid(prefixTable, attr):
    # separate the ATTRTYP into two parts
    upperWord = attr / 65536
    lowerWord = attr % 65536

    # search in the prefix table to find the upperWord, if found,
    # construct the binary OID by appending lowerWord to the end of
    # found prefix.

    binaryOID = None
    for j, item in enumerate(prefixTable):
        if item['ndx'] == upperWord:
            binaryOID = item['prefix']['elements'][:item['prefix']['length']]
            if lowerWord < 128:
                binaryOID.append(chr(lowerWord))
            else:
                if lowerWord >= 32768:
                    lowerWord -= 32768
                binaryOID.append(chr(((lowerWord/128) % 128)+128))
                binaryOID.append(chr(lowerWord%128))
            break

    if binaryOID is None:
        return None

    return str(decoder.decode('\x06' + chr(len(binaryOID)) + ''.join(binaryOID), asn1Spec = univ.ObjectIdentifier())[0]) 
開發者ID:joxeankoret,項目名稱:CVE-2017-7494,代碼行數:28,代碼來源:drsuapi.py

示例12: _buildOid

# 需要導入模塊: from pyasn1.type import univ [as 別名]
# 或者: from pyasn1.type.univ import ObjectIdentifier [as 別名]
def _buildOid(*components):
    output = []
    for x in tuple(components):
        if isinstance(x, univ.ObjectIdentifier):
            output.extend(list(x))
        else:
            output.append(int(x))

    return univ.ObjectIdentifier(output) 
開發者ID:etingof,項目名稱:pyasn1-modules,代碼行數:11,代碼來源:rfc3281.py

示例13: _buildOid

# 需要導入模塊: from pyasn1.type import univ [as 別名]
# 或者: from pyasn1.type.univ import ObjectIdentifier [as 別名]
def _buildOid(*components):
    output = []
    for x in tuple(components):
        if isinstance(x, univ.ObjectIdentifier):
            output.extend(list(x))
        else:
            output.append(int(x))

    return univ.ObjectIdentifier(output)


# Since CMS Attributes and CMC Controls both use 'attrType', one map is used 
開發者ID:etingof,項目名稱:pyasn1-modules,代碼行數:14,代碼來源:rfc6402.py

示例14: _OID

# 需要導入模塊: from pyasn1.type import univ [as 別名]
# 或者: from pyasn1.type.univ import ObjectIdentifier [as 別名]
def _OID(*components):
    output = []
    for x in tuple(components):
        if isinstance(x, univ.ObjectIdentifier):
            output.extend(list(x))
        else:
            output.append(int(x))
    return univ.ObjectIdentifier(output) 
開發者ID:etingof,項目名稱:pyasn1-modules,代碼行數:10,代碼來源:rfc4055.py

示例15: _OID

# 需要導入模塊: from pyasn1.type import univ [as 別名]
# 或者: from pyasn1.type.univ import ObjectIdentifier [as 別名]
def _OID(*components):
    output = []
    for x in tuple(components):
        if isinstance(x, univ.ObjectIdentifier):
            output.extend(list(x))
        else:
            output.append(int(x))
    return univ.ObjectIdentifier(output)


# Imports from RFC 5652 and RFC 8018 
開發者ID:etingof,項目名稱:pyasn1-modules,代碼行數:13,代碼來源:rfc5751.py


注:本文中的pyasn1.type.univ.ObjectIdentifier方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。