本文整理汇总了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
示例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))
示例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'])
示例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']))
示例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']))
示例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)
示例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'])
示例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'])
示例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
示例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
示例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
示例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'])
示例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))
示例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'])
示例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())