class JWTClaimNames(univ.SequenceOf): pass JWTClaimNames.componentType = JWTClaimName() JWTClaimNames.sizeSpec = constraint.ValueSizeConstraint(1, MAX) class JWTClaimPermittedValues(univ.Sequence): pass JWTClaimPermittedValues.componentType = namedtype.NamedTypes( namedtype.NamedType('claim', JWTClaimName()), namedtype.NamedType('permitted', univ.SequenceOf( componentType=char.UTF8String()).subtype( sizeSpec=constraint.ValueSizeConstraint(1, MAX))) ) class JWTClaimPermittedValuesList(univ.SequenceOf): pass JWTClaimPermittedValuesList.componentType = JWTClaimPermittedValues() JWTClaimPermittedValuesList.sizeSpec = constraint.ValueSizeConstraint(1, MAX) class JWTClaimConstraints(univ.Sequence): pass JWTClaimConstraints.componentType = namedtype.NamedTypes(
def setUp(self): self.s1 = univ.SequenceOf( componentType=univ.OctetString('') ) self.s2 = self.s1.clone()
class _Name(univ.Choice): componentType = namedtype.NamedTypes( namedtype.NamedType('rdnSequence', univ.SequenceOf()), )
namedtype.NamedType('classId', UUID()), namedtype.NamedType('deviceId', UUID()), namedtype.NamedType('nonce', univ.OctetString()), namedtype.NamedType('vendorInfo', univ.OctetString()), namedtype.OptionalNamedType('applyPeriod', univ.Sequence(componentType=namedtype.NamedTypes( namedtype.NamedType('validFrom', univ.Integer()), namedtype.NamedType('validTo', univ.Integer()) )) ), namedtype.NamedType('applyImmediately', univ.Boolean()), namedtype.NamedType('encryptionMode', univ.Choice(componentType=namedtype.NamedTypes( namedtype.NamedType('enum', univ.Enumerated(namedValues=namedval.NamedValues(('invalid', 0), ('aes-128-ctr-ecc-secp256r1-sha256', 1), ('none-ecc-secp256r1-sha256', 2), ('none-none-sha256', 3)))), namedtype.NamedType('objectId', univ.ObjectIdentifier()) )) ), namedtype.NamedType('aliases', univ.SequenceOf(componentType=ResourceAlias())), namedtype.NamedType('dependencies', univ.SequenceOf(componentType=ResourceReference())), namedtype.OptionalNamedType('payload', PayloadDescription()) ) class Payload(univ.OctetString): pass class Resource(univ.Sequence): pass Resource.componentType = namedtype.NamedTypes( namedtype.OptionalNamedType('uri', Uri()),
pass CertificateReference.componentType = namedtype.NamedTypes( namedtype.NamedType('fingerprint', Bytes()), namedtype.NamedType('uri', Uri())) class SignatureBlock(univ.Sequence): pass SignatureBlock.componentType = namedtype.NamedTypes( namedtype.NamedType('signature', univ.OctetString()), namedtype.NamedType('certificates', univ.SequenceOf(componentType=CertificateReference()))) class MacBlock(univ.Sequence): pass MacBlock.componentType = namedtype.NamedTypes( namedtype.NamedType('pskID', univ.OctetString()), namedtype.NamedType('keyTableVersion', univ.Integer()), namedtype.OptionalNamedType('keyTableIV', univ.OctetString()), namedtype.OptionalNamedType('keyTableRef', char.UTF8String()), namedtype.NamedType('keyTableIndexSize', univ.Integer()), namedtype.NamedType('keyTableRecordSize', univ.Integer()))
def test_goose_message(): g = IECGoosePDU().subtype( implicitTag=tag.Tag( tag.tagClassApplication, tag.tagFormatConstructed, 1 ) ) g.setComponentByName( 'gocbRef', 'DENNY_11F_13_100CFG/LLN0$GO$Dset_SubnetCtrl' ) g.setComponentByName('timeAllowedtoLive', 2000) g.setComponentByName('datSet', 'DENNY_11F_13_100CFG/LLN0$G_NetCtrl') g.setComponentByName('goID', '11F_13_100Dset_SubnetCtrl') g.setComponentByName('t', b'\x5a\xaa\xe0\xa4\x6f\xf3\x5e\x92') g.setComponentByName('stNum', 96) g.setComponentByName('sqNum', 16192) g.setComponentByName('test', False) g.setComponentByName('confRev', 2) g.setComponentByName('ndsCom', False) g.setComponentByName('numDatSetEntries', 5) all_data = AllData().subtype( implicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 11 ) ) inner1 = univ.SequenceOf(componentType=Data()).subtype( implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2) ) inner1.setComponentByPosition(0, Data().setComponentByName("boolean", False)) inner1.setComponentByPosition(1, Data().setComponentByName("bit-string", "'0000000000000'B")) inner1.setComponentByPosition(2, Data().setComponentByName('utc-time', b'\x5a\xaa\xe0\xa4\x6f\xf3\x5e\x92')) data1 = Data() data1.setComponentByName('structure', inner1) inner2 = univ.SequenceOf(componentType=Data()).subtype( implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2) ) inner2.setComponentByPosition(0, Data().setComponentByName("boolean", False)) inner2.setComponentByPosition(1, Data().setComponentByName("bit-string", "'0000000000000'B")) inner2.setComponentByPosition(2, Data().setComponentByName('utc-time', b'\x5a\xa9\x39\x5a\x03\xea\x4a\x92')) data2 = Data() data2.setComponentByName('structure', inner2) inner3 = univ.SequenceOf(componentType=Data()).subtype( implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2) ) inner3.setComponentByPosition(0, Data().setComponentByName("boolean", False)) inner3.setComponentByPosition(1, Data().setComponentByName("bit-string", "'0000000000000'B")) inner3.setComponentByPosition(2, Data().setComponentByName('utc-time', b'\x5a\xa9\x39\x5a\x03\xea\x4a\x92')) data3 = Data() data3.setComponentByName('structure', inner3) inner4 = univ.SequenceOf(componentType=Data()).subtype( implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2) ) inner4.setComponentByPosition(0, Data().setComponentByName("boolean", False)) inner4.setComponentByPosition(1, Data().setComponentByName("bit-string", "'0000000000000'B")) inner4.setComponentByPosition(2, Data().setComponentByName('utc-time', b'\x5a\xa9\x39\x5a\x03\xea\x4a\x92')) data4 = Data() data4.setComponentByName('structure', inner4) inner5 = univ.SequenceOf(componentType=Data()).subtype( implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2) ) inner5.setComponentByPosition(0, Data().setComponentByName("boolean", False)) inner5.setComponentByPosition(1, Data().setComponentByName("bit-string", "'0000000000000'B")) inner5.setComponentByPosition(2, Data().setComponentByName('utc-time', b'\x5a\xaa\xd1\x7d\xd2\x48\x21\x92')) data5 = Data() data5.setComponentByName('structure', inner5) all_data.setComponentByPosition(0, data1) all_data.setComponentByPosition(1, data2) all_data.setComponentByPosition(2, data3) all_data.setComponentByPosition(3, data4) all_data.setComponentByPosition(4, data5) g.setComponentByName('allData', all_data) calculated = raw( Ether(dst='01:0c:cd:01:00:00', src='00:30:a7:13:2e:92') / Dot1Q(vlan=10, type=0x88b8, prio=6) / GOOSE(appid=int(0x0000)) / encoder.encode(g), ) expected = ( b"\x01\x0c\xcd\x01\x00\x00\x00\x30\xa7\x13\x2e\x92\x81\x00\xc0\x0a" b"\x88\xb8\x00\x00\x00\xfe\x00\x00\x00\x00\x61\x81\xf3\x80\x2b\x44" b"\x45\x4e\x4e\x59\x5f\x31\x31\x46\x5f\x31\x33\x5f\x31\x30\x30\x43" b"\x46\x47\x2f\x4c\x4c\x4e\x30\x24\x47\x4f\x24\x44\x73\x65\x74\x5f" b"\x53\x75\x62\x6e\x65\x74\x43\x74\x72\x6c\x81\x02\x07\xd0\x82\x22" b"\x44\x45\x4e\x4e\x59\x5f\x31\x31\x46\x5f\x31\x33\x5f\x31\x30\x30" b"\x43\x46\x47\x2f\x4c\x4c\x4e\x30\x24\x47\x5f\x4e\x65\x74\x43\x74" b"\x72\x6c\x83\x19\x31\x31\x46\x5f\x31\x33\x5f\x31\x30\x30\x44\x73" b"\x65\x74\x5f\x53\x75\x62\x6e\x65\x74\x43\x74\x72\x6c\x84\x08\x5a" b"\xaa\xe0\xa4\x6f\xf3\x5e\x92\x85\x01\x60\x86\x02\x3f\x40\x87\x01" b"\x00\x88\x01\x02\x89\x01\x00\x8a\x01\x05\xab\x64\xa2\x12\x83\x01" b"\x00\x84\x03\x03\x00\x00\x91\x08\x5a\xaa\xe0\xa4\x6f\xf3\x5e\x92" b"\xa2\x12\x83\x01\x00\x84\x03\x03\x00\x00\x91\x08\x5a\xa9\x39\x5a" b"\x03\xea\x4a\x92\xa2\x12\x83\x01\x00\x84\x03\x03\x00\x00\x91\x08" b"\x5a\xa9\x39\x5a\x03\xea\x4a\x92\xa2\x12\x83\x01\x00\x84\x03\x03" b"\x00\x00\x91\x08\x5a\xa9\x39\x5a\x03\xea\x4a\x92\xa2\x12\x83\x01" b"\x00\x84\x03\x03\x00\x00\x91\x08\x5a\xaa\xd1\x7d\xd2\x48\x21\x92" ) assert calculated[0:7] == expected[0:7] # destination MAC assert calculated[7:12] == expected[7:12] # source MAC assert calculated[12:14] == expected[12:14] # type assert calculated[14:18] == expected[14:18] # 802.1Q assert calculated[18:20] == expected[18:20] # APPID assert calculated[20:22] == expected[20:22] # Length assert calculated[22:26] == expected[22:26] # Reserved1 and Reserved2 assert calculated[26:28] == expected[26:28] # goosePDU asn.1 tag assert calculated[28:74] == expected[28:74] # gocbRef assert calculated[74:78] == expected[74:78] # timeAllowedtoLive assert calculated[78:114] == expected[78:114] # datSet assert calculated[114:141] == expected[114:141] # goID assert calculated[141:151] == expected[141:151] # t assert calculated[151:154] == expected[151:154] # stNum assert calculated[154:158] == expected[154:158] # sqNum assert calculated[158:161] == expected[158:161] # test assert calculated[161:164] == expected[161:164] # confRev assert calculated[164:167] == expected[164:167] # ndsCom assert calculated[167:170] == expected[167:170] # numDatSetEntries assert calculated[170:172] == expected[170:172] # allData asn.1 assert calculated[172:174] == expected[172:174] # structure #1 asn.1 assert calculated[174:192] == expected[174:192] # structure #1 assert calculated[192:194] == expected[192:194] # structure #2 asn.1 assert calculated[194:212] == expected[194:212] # structure #2 assert calculated[212:214] == expected[212:214] # structure #3 asn.1 assert calculated[214:232] == expected[214:232] # structure #3 assert calculated[232:234] == expected[232:234] # structure #4 asn.1 assert calculated[234:252] == expected[234:252] # structure #4 assert calculated[252:254] == expected[252:254] # structure #5 asn.1 assert calculated[254:272] == expected[254:272] # structure #5 asn.1 assert calculated == expected
class ESSCertIDv2(univ.Sequence): pass ESSCertIDv2.componentType = namedtype.NamedTypes( namedtype.DefaultedNamedType('hashAlgorithm', sha256AlgId), namedtype.NamedType('certHash', Hash()), namedtype.OptionalNamedType('issuerSerial', IssuerSerial())) class SigningCertificateV2(univ.Sequence): pass SigningCertificateV2.componentType = namedtype.NamedTypes( namedtype.NamedType('certs', univ.SequenceOf(componentType=ESSCertIDv2())), namedtype.OptionalNamedType( 'policies', univ.SequenceOf(componentType=PolicyInformation()))) # Mail List Expansion History Attribute id_aa_mlExpandHistory = rfc2634.id_aa_mlExpandHistory ub_ml_expansion_history = rfc2634.ub_ml_expansion_history EntityIdentifier = rfc2634.EntityIdentifier MLReceiptPolicy = rfc2634.MLReceiptPolicy MLData = rfc2634.MLData
def testSchemalessDecoder(self): assert decoder.decode( ints2octs((48, 13, 4, 11, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110)), asn1Spec=univ.SequenceOf() ) == (self.s, null)
def setUp(self): BaseTestCase.setUp(self) self.s = univ.SequenceOf(componentType=univ.OctetString()) self.s.setComponentByPosition(0, univ.OctetString('quick brown'))
class SigningCertificate(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('certs', univ.SequenceOf(componentType=ESSCertID())), namedtype.OptionalNamedType('policies', univ.SequenceOf(componentType=PolicyInformation())), )
univ.Choice(componentType=namedtype.NamedTypes( namedtype.NamedType( 'baseCertificateID', rfc3281.IssuerSerial().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatSimple, 0))), namedtype.NamedType( 'subjectName', rfc3280.GeneralNames().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatSimple, 1)))))), namedtype.NamedType('issuer', rfc3280.GeneralNames()), namedtype.NamedType('signature', rfc3280.AlgorithmIdentifier()), namedtype.NamedType('serialNumber', rfc3280.CertificateSerialNumber()), namedtype.NamedType('attCertValidityPeriod', rfc3281.AttCertValidityPeriod()), namedtype.NamedType('attributes', univ.SequenceOf(componentType=rfc3280.Attribute())), namedtype.OptionalNamedType('issuerUniqueID', rfc3280.UniqueIdentifier()), namedtype.OptionalNamedType('extensions', rfc3280.Extensions())) class AttributeCertificateV1(univ.Sequence): pass AttributeCertificateV1.componentType = namedtype.NamedTypes( namedtype.NamedType('acInfo', AttributeCertificateInfoV1()), namedtype.NamedType('signatureAlgorithm', rfc3280.AlgorithmIdentifier()), namedtype.NamedType('signature', univ.BitString())) class CertificateChoices(univ.Choice):
class TBSCertList(univ.Sequence): pass TBSCertList.componentType = namedtype.NamedTypes( namedtype.OptionalNamedType('version', Version()), namedtype.NamedType('signature', AlgorithmIdentifier()), namedtype.NamedType('issuer', Name()), namedtype.NamedType('thisUpdate', Time()), namedtype.OptionalNamedType('nextUpdate', Time()), namedtype.OptionalNamedType( 'revokedCertificates', univ.SequenceOf(componentType=univ.Sequence( componentType=namedtype.NamedTypes( namedtype.NamedType('userCertificate', CertificateSerialNumber( )), namedtype.NamedType('revocationDate', Time()), namedtype.OptionalNamedType('crlEntryExtensions', Extensions()))))), namedtype.OptionalNamedType( 'crlExtensions', Extensions().subtype( explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)))) local_postal_attributes = univ.Integer(21) pkcs_9 = _OID(1, 2, 840, 113549, 1, 9) class PhysicalDeliveryCountryName(univ.Choice): pass
class PrincipalName(univ.Sequence): componentType = namedtype.NamedTypes( _sequence_component("name-type", 0, Int32()), _sequence_component("name-string", 1, univ.SequenceOf(componentType=KerberosString())) )
ContentCollection.componentType = rfc5652.ContentInfo() ContentCollection.sizeSpec = constraint.ValueSizeConstraint(1, MAX) # Content With Attributes Content Type and Object Identifier id_ct_contentWithAttrs = univ.ObjectIdentifier('1.2.840.113549.1.9.16.1.20') class ContentWithAttributes(univ.Sequence): pass ContentWithAttributes.componentType = namedtype.NamedTypes( namedtype.NamedType('content', rfc5652.ContentInfo()), namedtype.NamedType( 'attrs', univ.SequenceOf(componentType=rfc5652.Attribute()).subtype( sizeSpec=constraint.ValueSizeConstraint(1, MAX)))) # Map of Content Type OIDs to Content Types is added to the # ones that are in rfc5652.py _cmsContentTypesMapUpdate = { id_ct_contentCollection: ContentCollection(), id_ct_contentWithAttrs: ContentWithAttributes(), } rfc5652.cmsContentTypesMap.update(_cmsContentTypesMapUpdate)
class OcspListID(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('ocspResponses', univ.SequenceOf(componentType=OcspResponsesID())) )
class PrincipalName(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('name-type', _c(0, univ.Integer())), namedtype.NamedType( 'name-string', _c(1, univ.SequenceOf(componentType=char.GeneralString()))))
class KerberosString(char.GeneralString): pass class NameType(Int32): pass class PrincipalName(univ.Sequence): pass PrincipalName.componentType = namedtype.NamedTypes( namedtype.NamedType('name-type', NameType().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))), namedtype.NamedType('name-string', univ.SequenceOf(componentType=KerberosString()).subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))) ) class Realm(KerberosString): pass class AD_KDCIssued(univ.Sequence): pass AD_KDCIssued.componentType = namedtype.NamedTypes( namedtype.NamedType('ad-checksum', Checksum().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))), namedtype.OptionalNamedType('i-realm', Realm().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))), namedtype.OptionalNamedType('i-sname', PrincipalName().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 2))),
def testEmpty(self): s = univ.SequenceOf() s.clear() assert encoder.encode(s) == ints2octs((48, 128, 0, 0))
class Int(univ.Integer): pass class String(char.UTF8String): pass class ImgDescriptor(univ.Sequence): pass ImgDescriptor.componentType = namedtype.NamedTypes( namedtype.NamedType('id', String()), namedtype.NamedType('vendor-data', Bytes()), namedtype.NamedType('vendor-data-size', Int()), namedtype.NamedType('image-size', Int())) class Descriptor(univ.Sequence): pass Descriptor.componentType = namedtype.NamedTypes( namedtype.NamedType('num-of-images', \ univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 255))), namedtype.NamedType('descriptors-array', univ.SequenceOf(componentType=ImgDescriptor())) )
def testDefMode4(self): s = univ.SequenceOf() s.append(univ.OctetString('a')) s.append(univ.OctetString('b')) assert encoder.encode(s) == ints2octs( (48, 128, 4, 1, 97, 4, 1, 98, 0, 0))
CMCFailInfo.namedValues = namedval.NamedValues( ('badAlg', 0), ('badMessageCheck', 1), ('badRequest', 2), ('badTime', 3), ('badCertId', 4), ('unsupportedExt', 5), ('mustArchiveKeys', 6), ('badIdentity', 7), ('popRequired', 8), ('popFailed', 9), ('noKeyReuse', 10), ('internalCAError', 11), ('tryLater', 12), ('authDataFail', 13)) class CMCStatusInfoV2(univ.Sequence): pass CMCStatusInfoV2.componentType = namedtype.NamedTypes( namedtype.NamedType('cMCStatus', CMCStatus()), namedtype.NamedType('bodyList', univ.SequenceOf(componentType=BodyPartReference())), namedtype.OptionalNamedType('statusString', char.UTF8String()), namedtype.OptionalNamedType( 'otherInfo', univ.Choice(componentType=namedtype.NamedTypes( namedtype.NamedType('failInfo', CMCFailInfo()), namedtype.NamedType('pendInfo', PendInfo()), namedtype.NamedType( 'extendedFailInfo', univ.Sequence(componentType=namedtype.NamedTypes( namedtype.NamedType('failInfoOID', univ.ObjectIdentifier( )), namedtype.NamedType('failInfoValue', AttributeValue())))))))) class GetCRL(univ.Sequence):
def setUp(self): BaseTestCase.setUp(self) self.s = univ.SequenceOf(componentType=univ.OctetString())
class PKIHeader(univ.Sequence): """ PKIHeader ::= SEQUENCE { pvno INTEGER { cmp1999(1), cmp2000(2) }, sender GeneralName, recipient GeneralName, messageTime [0] GeneralizedTime OPTIONAL, protectionAlg [1] AlgorithmIdentifier OPTIONAL, senderKID [2] KeyIdentifier OPTIONAL, recipKID [3] KeyIdentifier OPTIONAL, transactionID [4] OCTET STRING OPTIONAL, senderNonce [5] OCTET STRING OPTIONAL, recipNonce [6] OCTET STRING OPTIONAL, freeText [7] PKIFreeText OPTIONAL, generalInfo [8] SEQUENCE SIZE (1..MAX) OF InfoTypeAndValue OPTIONAL } """ componentType = namedtype.NamedTypes( namedtype.NamedType( 'pvno', univ.Integer( namedValues=namedval.NamedValues(('cmp1999', 1), ('cmp2000', 2)))), namedtype.NamedType('sender', rfc2459.GeneralName()), namedtype.NamedType('recipient', rfc2459.GeneralName()), namedtype.OptionalNamedType( 'messageTime', useful.GeneralizedTime().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatSimple, 0))), namedtype.OptionalNamedType( 'protectionAlg', rfc2459.AlgorithmIdentifier().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 1))), namedtype.OptionalNamedType( 'senderKID', rfc2459.KeyIdentifier().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatSimple, 2))), namedtype.OptionalNamedType( 'recipKID', rfc2459.KeyIdentifier().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatSimple, 3))), namedtype.OptionalNamedType( 'transactionID', univ.OctetString().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatSimple, 4))), namedtype.OptionalNamedType( 'senderNonce', univ.OctetString().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatSimple, 5))), namedtype.OptionalNamedType( 'recipNonce', univ.OctetString().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatSimple, 6))), namedtype.OptionalNamedType( 'freeText', PKIFreeText().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 7))), namedtype.OptionalNamedType( 'generalInfo', univ.SequenceOf(componentType=InfoTypeAndValue().subtype( subtypeSpec=constraint.ValueSizeConstraint(1, MAX), explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 8)))))
tag.tagClassContext, tag.tagFormatConstructed, 2)))) class AttributeCertificateInfo(univ.Sequence): pass AttributeCertificateInfo.componentType = namedtype.NamedTypes( namedtype.NamedType('version', AttCertVersion()), namedtype.NamedType('holder', Holder()), namedtype.NamedType('issuer', AttCertIssuer()), namedtype.NamedType('signature', rfc3280.AlgorithmIdentifier()), namedtype.NamedType('serialNumber', rfc3280.CertificateSerialNumber()), namedtype.NamedType('attrCertValidityPeriod', AttCertValidityPeriod()), namedtype.NamedType('attributes', univ.SequenceOf(componentType=rfc3280.Attribute())), namedtype.OptionalNamedType('issuerUniqueID', rfc3280.UniqueIdentifier()), namedtype.OptionalNamedType('extensions', rfc3280.Extensions())) class AttributeCertificate(univ.Sequence): pass AttributeCertificate.componentType = namedtype.NamedTypes( namedtype.NamedType('acinfo', AttributeCertificateInfo()), namedtype.NamedType('signatureAlgorithm', rfc3280.AlgorithmIdentifier()), namedtype.NamedType('signatureValue', univ.BitString())) id_mod = _buildOid(rfc3280.id_pkix, 0)
class ESSCertID(univ.Sequence): pass ESSCertID.componentType = namedtype.NamedTypes( namedtype.NamedType('certHash', Hash()), namedtype.OptionalNamedType('issuerSerial', IssuerSerial())) class SigningCertificate(univ.Sequence): pass SigningCertificate.componentType = namedtype.NamedTypes( namedtype.NamedType('certs', univ.SequenceOf(componentType=ESSCertID())), namedtype.OptionalNamedType( 'policies', univ.SequenceOf(componentType=PolicyInformation()))) # Mail List Expansion History Attribute id_aa_mlExpandHistory = univ.ObjectIdentifier('1.2.840.113549.1.9.16.2.3') ub_ml_expansion_history = univ.Integer(64) class EntityIdentifier(univ.Choice): pass EntityIdentifier.componentType = namedtype.NamedTypes(
class NoticeReference(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('organization', DisplayText()), namedtype.NamedType('noticeNumbers', univ.SequenceOf(componentType=univ.Integer())) )
class NameType(Int32): pass class PrincipalName(univ.Sequence): pass PrincipalName.componentType = namedtype.NamedTypes( namedtype.NamedType( 'name-type', NameType().subtype( explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))), namedtype.NamedType( 'name-string', univ.SequenceOf(componentType=KerberosString()).subtype( explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))) class Realm(KerberosString): pass class AD_KDCIssued(univ.Sequence): pass AD_KDCIssued.componentType = namedtype.NamedTypes( namedtype.NamedType( 'ad-checksum', Checksum().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
class CRLListID(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('crls', univ.SequenceOf(componentType=CrlValidatedID())) )
certid = CertID() request['reqCert'] = certid certid['hashAlgorithm'] = rfc2459.AlgorithmIdentifier()\ .setComponentByName('algorithm', rfc2437.id_sha1)\ # .setComponentByName('parameters', univ.Any(hexValue='0500')) # certid['issuerNameHash'] = univ.OctetString(hexValue='01cb3044531fa8618a68d3c60596ab0555866b09') certid['issuerNameHash'] = univ.OctetString( hexValue='54e857e287d993fb6c0001fa3739b6e35c0e2c21') # certid['issuerKeyHash'] = univ.OctetString(hexValue='31c3791bbaf553d717e0897a2d176c0ab32b9d33') certid['issuerKeyHash'] = univ.OctetString( hexValue='1819c3646d8a358624911ee83dd5a78e509d555d') certid['serialNumber'] = rfc2459.CertificateSerialNumber(10000616) encoder.encode(certid['serialNumber']) req['tbsRequest']['requestList'] = univ.SequenceOf( componentType=Request()).setComponentByPosition(0, request) # reqExts = rfc2459.Extensions().subtype( # explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)) # reqExt = rfc2459.Extension() # reqExt['extnID'] = univ.ObjectIdentifier('1.3.6.1.5.5.7.48.1.2') # reqExt['critical'] = univ.Boolean('False') # reqExt['extnValue'] = univ.Any(hexValue='04120410236e5193af7958f49edcc756ed6c6dd3') # reqExts[0] = reqExt # req['tbsRequest']['requestExtensions'] = reqExts print(req.prettyPrint()) print(encoder.encode(req)) else: with open(sys.argv[1], 'rb') as fp: for t in decoder.decode(fp.read(), asn1Spec=OCSPRequest()): if hasattr(t, 'prettyPrint'):
def testIndefModeChunked(self): s = univ.SequenceOf() s.setComponentByPosition(0, univ.OctetString('quick brown')) assert encoder.encode( s, defMode=False, maxChunkSize=4 ) == ints2octs((48, 128, 36, 128, 4, 4, 113, 117, 105, 99, 4, 4, 107, 32, 98, 114, 4, 3, 111, 119, 110, 0, 0, 0, 0))