Python pyasn1.type.univ.Null() Examples
The following are 30
code examples of pyasn1.type.univ.Null().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pyasn1.type.univ
, or try the search function
.
Example #1
Source File: test_rfc4357.py From pyasn1-modules with BSD 2-Clause "Simplified" License | 6 votes |
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']))
Example #2
Source File: decoder.py From learn_python3_spider with MIT License | 6 votes |
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
Example #3
Source File: decoder.py From bash-lambda-layer with MIT License | 6 votes |
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
Example #4
Source File: test_rfc3058.py From pyasn1-modules with BSD 2-Clause "Simplified" License | 6 votes |
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'])
Example #5
Source File: test_rfc6955.py From pyasn1-modules with BSD 2-Clause "Simplified" License | 6 votes |
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'])
Example #6
Source File: test_rfc3537.py From pyasn1-modules with BSD 2-Clause "Simplified" License | 6 votes |
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)
Example #7
Source File: decoder.py From luci-py with Apache License 2.0 | 6 votes |
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
Example #8
Source File: test_rfc4357.py From pyasn1-modules with BSD 2-Clause "Simplified" License | 6 votes |
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']))
Example #9
Source File: test_rfc4055.py From pyasn1-modules with BSD 2-Clause "Simplified" License | 6 votes |
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'])
Example #10
Source File: ca.py From pymobiledevice with GNU General Public License v3.0 | 6 votes |
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
Example #11
Source File: test_rfc4490.py From pyasn1-modules with BSD 2-Clause "Simplified" License | 6 votes |
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))
Example #12
Source File: decoder.py From teleport with Apache License 2.0 | 6 votes |
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
Example #13
Source File: decoder.py From teleport with Apache License 2.0 | 6 votes |
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
Example #14
Source File: decoder.py From teleport with Apache License 2.0 | 6 votes |
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
Example #15
Source File: decoder.py From aws-kube-codesuite with Apache License 2.0 | 6 votes |
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
Example #16
Source File: decoder.py From plugin.video.bdyun with GNU General Public License v3.0 | 5 votes |
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
Example #17
Source File: decoder.py From opsbro with MIT License | 5 votes |
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
Example #18
Source File: decoder.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
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
Example #19
Source File: decoder.py From pelisalacarta-ce with GNU General Public License v3.0 | 5 votes |
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
Example #20
Source File: decoder.py From xunfengES with GNU General Public License v3.0 | 5 votes |
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
Example #21
Source File: decoder.py From xunfengES with GNU General Public License v3.0 | 5 votes |
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
Example #22
Source File: PKCS7SignedData.py From aurasium with GNU General Public License v3.0 | 5 votes |
def _ValidateEmptyParams(self, params): if params: param_value, rest = decoder.decode(params) if rest: raise Asn1Error('Extra unparsed content.') if param_value != univ.Null(): raise Asn1Error('Hasher has parameters. No idea what to do with them.')
Example #23
Source File: decoder.py From xbmc-addons-chinese with GNU General Public License v2.0 | 5 votes |
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
Example #24
Source File: decoder.py From xbmc-addons-chinese with GNU General Public License v2.0 | 5 votes |
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
Example #25
Source File: decoder.py From addon with GNU General Public License v3.0 | 5 votes |
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
Example #26
Source File: decoder.py From scalyr-agent-2 with Apache License 2.0 | 5 votes |
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
Example #27
Source File: decoder.py From aqua-monitor with GNU Lesser General Public License v3.0 | 5 votes |
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
Example #28
Source File: decoder.py From oss-ftp with MIT License | 5 votes |
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
Example #29
Source File: decoder.py From nzb-subliminal with GNU General Public License v3.0 | 5 votes |
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
Example #30
Source File: test_rfc3279.py From pyasn1-modules with BSD 2-Clause "Simplified" License | 5 votes |
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'])