class AttributeCertificateInfoV1(univ.Sequence): pass AttributeCertificateInfoV1.componentType = namedtype.NamedTypes( namedtype.DefaultedNamedType('version', AttCertVersionV1().subtype(value="v1")), namedtype.NamedType( 'subject', univ.Choice(componentType=namedtype.NamedTypes( namedtype.NamedType( 'baseCertificateID', rfc3281.IssuerSerial().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatSimple, 0))), namedtype.NamedType( 'subjectName', rfc5280.GeneralNames().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatSimple, 1)))))), namedtype.NamedType('issuer', rfc5280.GeneralNames()), namedtype.NamedType('signature', rfc5280.AlgorithmIdentifier()), namedtype.NamedType('serialNumber', rfc5280.CertificateSerialNumber()), namedtype.NamedType('attCertValidityPeriod', rfc3281.AttCertValidityPeriod()), namedtype.NamedType('attributes', univ.SequenceOf(componentType=rfc5280.Attribute())), namedtype.OptionalNamedType('issuerUniqueID', rfc5280.UniqueIdentifier()), namedtype.OptionalNamedType('extensions', rfc5280.Extensions())) class AttributeCertificateV1(univ.Sequence): pass
if isinstance(x, univ.ObjectIdentifier): output.extend(list(x)) else: output.append(int(x)) return univ.ObjectIdentifier(output) class ObjectDigestInfo(univ.Sequence): pass ObjectDigestInfo.componentType = namedtype.NamedTypes( namedtype.NamedType('digestedObjectType', univ.Enumerated( namedValues=namedval.NamedValues(('publicKey', 0), ('publicKeyCert', 1), ('otherObjectTypes', 2)))), namedtype.OptionalNamedType('otherObjectTypeID', univ.ObjectIdentifier()), namedtype.NamedType('digestAlgorithm', rfc3280.AlgorithmIdentifier()), namedtype.NamedType('objectDigest', univ.BitString()) ) class IssuerSerial(univ.Sequence): pass IssuerSerial.componentType = namedtype.NamedTypes( namedtype.NamedType('issuer', rfc3280.GeneralNames()), namedtype.NamedType('serial', rfc3280.CertificateSerialNumber()), namedtype.OptionalNamedType('issuerUID', rfc3280.UniqueIdentifier()) )
class VarBind(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('name', rfc1902.ObjectName()), namedtype.NamedType('', _BindValue()))
class ScopedPDU(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('contextEngineId', univ.OctetString()), namedtype.NamedType('contextName', univ.OctetString()), namedtype.NamedType('data', rfc1905.PDUs()))
def setUp(self): self.s1 = univ.Sequence(componentType=namedtype.NamedTypes( namedtype.NamedType('name', univ.OctetString('')), namedtype.OptionalNamedType('nick', univ.OctetString('')), namedtype.DefaultedNamedType('age', univ.Integer(34))))
class NetworkAddress(univ.Choice): componentType = namedtype.NamedTypes( namedtype.NamedType('internet', IpAddress()))
class ObjectSyntax(univ.Choice): componentType = namedtype.NamedTypes( namedtype.NamedType('simple', SimpleSyntax()), namedtype.NamedType('application-wide', ApplicationSyntax()))
class SearchResultEntry(univ.Sequence): tagSet = univ.Sequence.tagSet.tagImplicitly( tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 4)) componentType = namedtype.NamedTypes( namedtype.NamedType('objectName', LDAPDN()), namedtype.NamedType('attributes', PartialAttributeList()))
class AddRequest(DefaultSequenceAndSetBaseMixin, univ.Sequence): tagSet = univ.Sequence.tagSet.tagImplicitly( tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 8)) componentType = namedtype.NamedTypes( namedtype.NamedType('entry', LDAPDN()), namedtype.NamedType('attributes', AttributeList()))
class PartialAttribute(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('type', AttributeDescription()), namedtype.NamedType('vals', univ.SetOf(componentType=AttributeValue())))
class SaslCredentials(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('mechanism', LDAPString()), namedtype.OptionalNamedType('credentials', univ.OctetString()))
class AttributeValueAssertion(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('attributeDesc', AttributeDescription()), namedtype.NamedType('assertionValue', AssertionValue()))
Filter.componentType = namedtype.NamedTypes( namedtype.NamedType( 'and', univ.SetOf(componentType=Filter()).subtype( implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))), namedtype.NamedType( 'or', univ.SetOf(componentType=Filter()).subtype( implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))), namedtype.NamedType( 'not', univ.SetOf(componentType=Filter()).subtype( implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)) #Filter().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 2)) ), namedtype.NamedType( 'equalityMatch', AttributeValueAssertion().subtype(implicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 3))), namedtype.NamedType( 'substrings', SubstringFilter().subtype(implicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 4))), namedtype.NamedType( 'greaterOrEqual', AttributeValueAssertion().subtype(implicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 5))), namedtype.NamedType( 'lessOrEqual', AttributeValueAssertion().subtype(implicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 6))), namedtype.NamedType( 'present', AttributeDescription().subtype( implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 7))), namedtype.NamedType( 'approxMatch', AttributeValueAssertion().subtype(implicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 8))), namedtype.NamedType( 'extensibleMatch', MatchingRuleAssertion().subtype(implicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 9))))
class RefreshResponseValue(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType( 'responseTtl', univ.Integer().subtype(implicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatSimple, 1))))
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)))))
class CompareRequest(DefaultSequenceAndSetBaseMixin, univ.Sequence): tagSet = univ.Sequence.tagSet.tagImplicitly( tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 14)) componentType = namedtype.NamedTypes( namedtype.NamedType('entry', LDAPDN()), namedtype.NamedType('ava', AttributeValueAssertion()))
class CertReq(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('certReqId', univ.Integer()))
class SDFlagsControlValue(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType( 'flags', univ.Integer().subtype( subtypeSpec=constraint.ValueRangeConstraint(0, maxInt))), )
class SimpleSyntax(TypeCoercionHackMixIn, univ.Choice): componentType = namedtype.NamedTypes( namedtype.NamedType('number', univ.Integer()), namedtype.NamedType('string', univ.OctetString()), namedtype.NamedType('object', univ.ObjectIdentifier()), namedtype.NamedType('empty', univ.Null()))
cmsContentTypesMap = opentypemap.get('cmsContentTypesMap') otherNamesMap = opentypemap.get('otherNamesMap') MAX = float('inf') class HardwareSerialEntry(univ.Choice): pass HardwareSerialEntry.componentType = namedtype.NamedTypes( namedtype.NamedType('all', univ.Null()), namedtype.NamedType('single', univ.OctetString()), namedtype.NamedType( 'block', univ.Sequence(componentType=namedtype.NamedTypes( namedtype.NamedType('low', univ.OctetString()), namedtype.NamedType('high', univ.OctetString()))))) class HardwareModules(univ.Sequence): pass HardwareModules.componentType = namedtype.NamedTypes( namedtype.NamedType('hwType', univ.ObjectIdentifier()), namedtype.NamedType('hwSerialEntries', univ.SequenceOf(componentType=HardwareSerialEntry())))
class CompressionAlgorithmIdentifier(rfc5280.AlgorithmIdentifier): pass # The CMS Compressed Data Content Type id_ct_compressedData = univ.ObjectIdentifier('1.2.840.113549.1.9.16.1.9') class CompressedData(univ.Sequence): pass CompressedData.componentType = namedtype.NamedTypes( namedtype.NamedType('version', rfc5652.CMSVersion()), # Always set to 0 namedtype.NamedType('compressionAlgorithm', CompressionAlgorithmIdentifier()), namedtype.NamedType('encapContentInfo', rfc5652.EncapsulatedContentInfo())) # Algorithm identifier for the zLib Compression Algorithm # This includes cpa_zlibCompress as defined in RFC 6268, # from https://www.rfc-editor.org/rfc/rfc6268.txt id_alg_zlibCompress = univ.ObjectIdentifier('1.2.840.113549.1.9.16.3.8') cpa_zlibCompress = rfc5280.AlgorithmIdentifier() cpa_zlibCompress['algorithm'] = id_alg_zlibCompress # cpa_zlibCompress['parameters'] are absent # Map of Content Type OIDs to Content Types # To be added to the ones that are in rfc5652.py
class AttributeTypeAndValue(univ.Sequence): """ASN.1 Attribute type and value class""" componentType = namedtype.NamedTypes( namedtype.NamedType('type', AttributeType()), namedtype.NamedType('value', AttributeValue()), )
class ScopedPduData(univ.Choice): componentType = namedtype.NamedTypes( namedtype.NamedType('plaintext', ScopedPDU()), namedtype.NamedType('encryptedPDU', univ.OctetString()), )
class Name(univ.Choice): """ASN.1 name class""" componentType = namedtype.NamedTypes( namedtype.NamedType('', RDNSequence()), )
def setUp(self): self.s1 = univ.Set(componentType=namedtype.NamedTypes( namedtype.NamedType('name', univ.OctetString('')), namedtype.OptionalNamedType('null', univ.Null('')), namedtype.DefaultedNamedType('age', univ.Integer(34)))) self.s2 = self.s1.clone()
class PKIBody(univ.Choice): """ PKIBody ::= CHOICE { -- message-specific body elements ir [0] CertReqMessages, --Initialization Request ip [1] CertRepMessage, --Initialization Response cr [2] CertReqMessages, --Certification Request cp [3] CertRepMessage, --Certification Response p10cr [4] CertificationRequest, --imported from [PKCS10] popdecc [5] POPODecKeyChallContent, --pop Challenge popdecr [6] POPODecKeyRespContent, --pop Response kur [7] CertReqMessages, --Key Update Request kup [8] CertRepMessage, --Key Update Response krr [9] CertReqMessages, --Key Recovery Request krp [10] KeyRecRepContent, --Key Recovery Response rr [11] RevReqContent, --Revocation Request rp [12] RevRepContent, --Revocation Response ccr [13] CertReqMessages, --Cross-Cert. Request ccp [14] CertRepMessage, --Cross-Cert. Response ckuann [15] CAKeyUpdAnnContent, --CA Key Update Ann. cann [16] CertAnnContent, --Certificate Ann. rann [17] RevAnnContent, --Revocation Ann. crlann [18] CRLAnnContent, --CRL Announcement pkiconf [19] PKIConfirmContent, --Confirmation nested [20] NestedMessageContent, --Nested Message genm [21] GenMsgContent, --General Message genp [22] GenRepContent, --General Response error [23] ErrorMsgContent, --Error Message certConf [24] CertConfirmContent, --Certificate confirm pollReq [25] PollReqContent, --Polling request pollRep [26] PollRepContent --Polling response """ componentType = namedtype.NamedTypes( namedtype.NamedType( 'ir', rfc2511.CertReqMessages().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 0))), namedtype.NamedType( 'ip', CertRepMessage().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 1))), namedtype.NamedType( 'cr', rfc2511.CertReqMessages().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 2))), namedtype.NamedType( 'cp', CertRepMessage().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 3))), namedtype.NamedType( 'p10cr', rfc2314.CertificationRequest().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 4))), namedtype.NamedType( 'popdecc', POPODecKeyChallContent().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 5))), namedtype.NamedType( 'popdecr', POPODecKeyRespContent().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 6))), namedtype.NamedType( 'kur', rfc2511.CertReqMessages().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 7))), namedtype.NamedType( 'kup', CertRepMessage().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 8))), namedtype.NamedType( 'krr', rfc2511.CertReqMessages().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 9))), namedtype.NamedType( 'krp', KeyRecRepContent().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 10))), namedtype.NamedType( 'rr', RevReqContent().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 11))), namedtype.NamedType( 'rp', RevRepContent().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 12))), namedtype.NamedType( 'ccr', rfc2511.CertReqMessages().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 13))), namedtype.NamedType( 'ccp', CertRepMessage().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 14))), namedtype.NamedType( 'ckuann', CAKeyUpdAnnContent().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 15))), namedtype.NamedType( 'cann', CertAnnContent().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 16))), namedtype.NamedType( 'rann', RevAnnContent().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 17))), namedtype.NamedType( 'crlann', CRLAnnContent().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 18))), namedtype.NamedType( 'pkiconf', PKIConfirmContent().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 19))), namedtype.NamedType('nested', nestedMessageContent), # namedtype.NamedType('nested', NestedMessageContent().subtype( # explicitTag=tag.Tag(tag.tagClassContext,tag.tagFormatConstructed,20) # ) # ), namedtype.NamedType( 'genm', GenMsgContent().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 21))), namedtype.NamedType( 'gen', GenRepContent().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 22))), namedtype.NamedType( 'error', ErrorMsgContent().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 23))), namedtype.NamedType( 'certConf', CertConfirmContent().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 24))), namedtype.NamedType( 'pollReq', PollReqContent().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 25))), namedtype.NamedType( 'pollRep', PollRepContent().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 26))))
class AsnPubKey(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('modulus', univ.Integer()), namedtype.NamedType('publicExponent', univ.Integer()))
class CertReq(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('certReqId', univ.Integer()), namedtype.NamedType('checkAfter', univ.Integer()), namedtype.OptionalNamedType('reason', PKIFreeText()))
class SignatureSequence(PrettySequence): componentType = namedtype.NamedTypes( namedtype.NamedType('params', KeyDataSet()), namedtype.NamedType('sign', SignatureParamsSequence()), namedtype.NamedType('meta', FileMetaSequence()))
SignatureAlgorithmIdentifier = rfc5652.SignatureAlgorithmIdentifier # CMS Algorithm Protection attribute id_aa_cmsAlgorithmProtect = univ.ObjectIdentifier('1.2.840.113549.1.9.52') class CMSAlgorithmProtection(univ.Sequence): pass CMSAlgorithmProtection.componentType = namedtype.NamedTypes( namedtype.NamedType('digestAlgorithm', DigestAlgorithmIdentifier()), namedtype.OptionalNamedType('signatureAlgorithm', SignatureAlgorithmIdentifier().subtype( implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))), namedtype.OptionalNamedType('macAlgorithm', MessageAuthenticationCodeAlgorithm().subtype( implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))) ) CMSAlgorithmProtection.subtypeSpec = constraint.ConstraintsUnion( constraint.WithComponentsConstraint( ('signatureAlgorithm', constraint.ComponentPresentConstraint()), ('macAlgorithm', constraint.ComponentAbsentConstraint())), constraint.WithComponentsConstraint( ('signatureAlgorithm', constraint.ComponentAbsentConstraint()), ('macAlgorithm', constraint.ComponentPresentConstraint())) )